Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSPP] EdgeMesh supports high availability architecture Design and Implementation #372

Merged
merged 47 commits into from Sep 20, 2022

Conversation

NKDYX
Copy link
Contributor

@NKDYX NKDYX commented Sep 8, 2022

What type of PR is this?

/kind feature

#353

#362

What this PR does / why we need it:

[OSPP] Code for EdgeMesh supports high availability architecture Design and Implementation

Main part of OSPP high availability (ha) feature. In this project we combined edgemesh-server and edgemesh-agent into a new structure--EdgeTunnel, which helps to relay and hole punch. The project contains new functions like Boostrap-Connection、mDNS-Discovery 、DHT-Discovery 、Relay-HeartBeat etc.

Poorunga and others added 29 commits August 17, 2022 20:01
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
…p-circuit

Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
…nodes

Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
…cture

Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
Signed-off-by: Poorunga <2744323@qq.com>
@kubeedge-bot kubeedge-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 8, 2022
@Poorunga Poorunga force-pushed the feature-ha branch 3 times, most recently from 32b2b50 to 17336dc Compare September 19, 2022 08:00

import (
"fmt"
"github.com/libp2p/go-libp2p-core/peer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the import order recommended by go, please import in the following order:

  1. built-in packages
  2. third-party packages
  3. this project packages

"testing"
)

/**
Copy link
Member

@Poorunga Poorunga Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**/ is not the function comment method recommended by go, please replace it with //


}

/**
Copy link
Member

@Poorunga Poorunga Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**/ is not the structure comment method recommended by go, please replace it with //, and comments and code are not related.

}

func TestAddCircuitAddrsToPeer(t *testing.T) {
want := "{12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg: [/ip4/5.5.5.5/tcp/9000/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg /ip4/5.5.5.5/udp/9000/quic/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg /ip4/5.5.5.5/tcp/9000/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/5.5.5.5/udp/9000/quic/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/tcp/9000/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/udp/9000/quic/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/tcp/9000/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/udp/9000/quic/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/tcp/9000/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/udp/9000/quic/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/5.5.5.5/tcp/9000/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/5.5.5.5/udp/9000/quic/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/tcp/9000/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/udp/9000/quic/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/tcp/9000/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/udp/9000/quic/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/tcp/9000/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/udp/9000/quic/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit]}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A too long code, It is recommended to read this data from a file.

}
//test AddCircuitAddrsToPeer
AddCircuitAddrsToPeer(&relayPeer, relayList)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this err is not return by AddCircuitAddrsToPeer(&relayPeer, relayList)

func TestAddCircuitAddrsToPeer(t *testing.T) {
want := "{12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg: [/ip4/5.5.5.5/tcp/9000/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg /ip4/5.5.5.5/udp/9000/quic/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg /ip4/5.5.5.5/tcp/9000/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/5.5.5.5/udp/9000/quic/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/tcp/9000/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/udp/9000/quic/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/tcp/9000/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/udp/9000/quic/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/tcp/9000/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/udp/9000/quic/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/5.5.5.5/tcp/9000/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/5.5.5.5/udp/9000/quic/p2p/12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/tcp/9000/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/6.6.6.6/udp/9000/quic/p2p/12D3KooWErZ4m27CEinjcnXNvem2KFUJUFRBcd9NdcWnYRqyr1Sn/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/tcp/9000/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/4.4.4.4/udp/9000/quic/p2p/12D3KooWSD4f5fZb5c9PQ6FPVd8Em4eKX3mRezcyqXSHUyomoy8S/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/tcp/9000/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit /ip4/8.8.8.8/udp/9000/quic/p2p/12D3KooWF3RB8SoMRZht7MDqF6GoipSPdFxVb9ESRLU7NuPX6ifH/p2p/12D3KooWQ4LGgA3djuvPt4Ao9YH2U39Yge5uzn3HwHXkDK23YDVg/p2p-circuit]}"
//节点列表
var Nodes = []*testNode{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using exported variables inside functions is bad

}

func TestAppendMultiaddrs(t *testing.T) {
//want :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete useless comments

}

func BenchmarkAddCircuitAddrsToPeer(b *testing.B) {
//节点列表
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use English comments

b.Errorf("AddAddress failed, err:%v", err)
}
b.Logf(relayPeer.String())
//b.Logf("the final got : %s", relayPeer.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete useless comments


// generate relayNode
priv, err := GenerateKeyPairWithString("MyNode")
assertEqualB(err, nil, b)
Copy link
Member

@Poorunga Poorunga Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to use assertions in benchmark tests. How the function returns an error, just terminate the benchmark test directly.

assertEqual(err, nil, t)
out, err := peer.IDFromPrivateKey(key)
assertEqual(err, nil, t)
if ans := peer.Encode(out); !assertEqual(ans, c.wanted, t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use expired functions: peer.Encode

return true
}

func assertTrue(t *testing.T, a bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete useless functions

key, err := GenerateKeyPairWithString(given)
b.StopTimer()
assertEqualB(err, nil, b)
out, err := peer.IDFromPrivateKey(key)
Copy link
Member

@Poorunga Poorunga Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to benchmark test, you must test a lot, refer to:

    for i := 0; i < b.N; i++ {
		_, err = peer.IDFromPrivateKey(key)
		if err != nil {
			b.Fatal(err)
		}
	}

Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
Signed-off-by: NKDYX <2374087322@qq.com>
@Poorunga
Copy link
Member

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 19, 2022
@kubeedge-bot
Copy link
Collaborator

@khalid-huang: changing LGTM is restricted to collaborators

In response to this:

/lgtm
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@khalid-huang
Copy link
Contributor

/lgtm
/approve

@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: khalid-jobs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 20, 2022
@kubeedge-bot kubeedge-bot merged commit 7fc16ec into kubeedge:main Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants