From 42d63b49553dab6635c88aac808d8d249e8adecd Mon Sep 17 00:00:00 2001 From: Yunkon Kim Date: Fri, 12 Aug 2022 11:05:03 +0900 Subject: [PATCH 1/2] Remove the peer state check on update - It's needed to update other peers state --- poc-cb-net/cmd/agent/agent.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/poc-cb-net/cmd/agent/agent.go b/poc-cb-net/cmd/agent/agent.go index 2cc9fe1..0683f9e 100644 --- a/poc-cb-net/cmd/agent/agent.go +++ b/poc-cb-net/cmd/agent/agent.go @@ -506,7 +506,7 @@ func watchPeers(ctx context.Context, etcdClient *clientv3.Client, wg *sync.WaitG } // Store peers to synchronize and use it in local - prevThisPeer := CBNet.ThisPeer + // prevThisPeer := CBNet.ThisPeer CBNet.StorePeer(peer) // Initialize or update networking rule @@ -536,12 +536,12 @@ func watchPeers(ctx context.Context, etcdClient *clientv3.Client, wg *sync.WaitG } else if peer.State == netstate.Tunneling { - // Update networking rule if it's not a simple state chanage of this peer - if prevThisPeer.State == peer.State { - // Update the networking rule for this peer - CBLogger.Debug("Update the networking rule for this peer") - updateNetworkingRule(CBNet.ThisPeer, CBNet.OtherPeers, ruleType, etcdClient) - } + // // Update networking rule if it's not a simple state chanage of this peer + // if prevThisPeer.State == peer.State { + // Update the networking rule for this peer + CBLogger.Debug("Update the networking rule for this peer") + updateNetworkingRule(CBNet.ThisPeer, CBNet.OtherPeers, ruleType, etcdClient) + // } } else { CBLogger.Debugf("Skip to update the networking rule (this peer's state: %v)", peer.State) @@ -673,7 +673,7 @@ func updatePeerInNetworkingRule(thisPeer model.Peer, otherPeer model.Peer, ruleT } CBLogger.Tracef("The CLADNet spec: %v", cladnetSpec) - // Create networking rule table for each peer + // Update networking rule for the peer // Select destination IP selectedIP, peerScope, err := cbnet.SelectDestinationByRuleType(ruleType, thisPeer, otherPeer) From 2b4d940389b11e2942fef4e5792d33712cf0bda7 Mon Sep 17 00:00:00 2001 From: Yunkon Kim Date: Fri, 12 Aug 2022 11:05:41 +0900 Subject: [PATCH 2/2] Remove duplicated code block to get cladnet spec --- poc-cb-net/cmd/agent/agent.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/poc-cb-net/cmd/agent/agent.go b/poc-cb-net/cmd/agent/agent.go index 0683f9e..6b4f3ab 100644 --- a/poc-cb-net/cmd/agent/agent.go +++ b/poc-cb-net/cmd/agent/agent.go @@ -657,22 +657,6 @@ func updatePeerInNetworkingRule(thisPeer model.Peer, otherPeer model.Peer, ruleT networkingRule := CBNet.NetworkingRule - // Get a specification of a cloud adaptive network - keyCLADNetSpec := fmt.Sprint(etcdkey.CLADNetSpecification + "/" + thisPeer.CladnetID) - CBLogger.Tracef("Get - %v", keyCLADNetSpec) - - respCLADNetSpec, etcdErr := etcdClient.Get(context.Background(), keyCLADNetSpec) - if etcdErr != nil { - CBLogger.Error(etcdErr) - } - CBLogger.Tracef("GetResponse: %v", respCLADNetSpec) - - var cladnetSpec model.CLADNetSpecification - if err := json.Unmarshal(respCLADNetSpec.Kvs[0].Value, &cladnetSpec); err != nil { - CBLogger.Error(err) - } - CBLogger.Tracef("The CLADNet spec: %v", cladnetSpec) - // Update networking rule for the peer // Select destination IP