Prechádzať zdrojové kódy

fix merge conflicts

Abhishek Kondur 2 rokov pred
rodič
commit
23f55ae206
2 zmenil súbory, kde vykonal 24 pridanie a 25 odobranie
  1. 22 23
      controllers/ext_client.go
  2. 2 2
      mq/publishers.go

+ 22 - 23
controllers/ext_client.go

@@ -397,10 +397,7 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
 	logger.Log(0, r.Header.Get("user"), "created new ext client on network", networkName)
 	w.WriteHeader(http.StatusOK)
 	go func() {
-		go mq.BroadcastExtClient(host, &node)
-		// if err := mq.PublishPeerUpdate(); err != nil {
-		// 	logger.Log(1, "error setting ext peers on "+nodeid+": "+err.Error())
-		// }
+		mq.BroadcastExtClient(host, &node)
 		f, err := logic.GetFwUpdate(host)
 		if err == nil {
 			mq.PublishFwUpdate(host, &f)
@@ -498,30 +495,32 @@ func updateExtClient(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 	logger.Log(0, r.Header.Get("user"), "updated ext client", update.ClientID)
-	if ingressNode, err := logic.GetNodeByID(newclient.IngressGatewayID); err == nil {
-		if ingressHost, err := logic.GetHost(ingressNode.HostID.String()); err == nil {
-			if replaceOldClient || !update.Enabled {
-				go mq.BroadcastDelExtClient(ingressHost, &ingressNode, oldExtClient)
-			}
-			if replaceOldClient || changedEnabled {
-				// broadcast update
-				go mq.BroadcastExtClient(ingressHost, &ingressNode)
-			}
-			f, err := logic.GetFwUpdate(ingressHost)
-			if err == nil {
-				mq.PublishFwUpdate(ingressHost, &f)
-			}
-		}
-	}
 	w.WriteHeader(http.StatusOK)
 	json.NewEncoder(w).Encode(newclient)
-	if changedID {
-		go func() {
+
+	go func() {
+		if ingressNode, err := logic.GetNodeByID(newclient.IngressGatewayID); err == nil {
+			if ingressHost, err := logic.GetHost(ingressNode.HostID.String()); err == nil {
+				if replaceOldClient || !update.Enabled {
+					mq.BroadcastDelExtClient(ingressHost, &ingressNode, currentClient)
+				}
+				if replaceOldClient || changedEnabled {
+					// broadcast update
+					mq.BroadcastExtClient(ingressHost, &ingressNode)
+				}
+				f, err := logic.GetFwUpdate(ingressHost)
+				if err == nil {
+					mq.PublishFwUpdate(ingressHost, &f)
+				}
+			}
+		}
+		if changedID {
 			if err := mq.PublishExtClientDNSUpdate(currentClient, *newclient, networkName); err != nil {
 				logger.Log(1, "error pubishing dns update for extcient update", err.Error())
 			}
-		}()
-	}
+		}
+	}()
+
 }
 
 // swagger:route DELETE /api/extclients/{network}/{clientid} ext_client deleteExtClient

+ 2 - 2
mq/publishers.go

@@ -283,7 +283,7 @@ func BroadcastAddOrUpdatePeer(host *models.Host, node *models.Node, update bool)
 	return nil
 }
 
-// BroadcastExtClient - adds ext client to peers in the network
+// BroadcastExtClient - publishes msg to add/updates ext client in the network
 func BroadcastExtClient(ingressHost *models.Host, ingressNode *models.Node) error {
 
 	nodes, err := logic.GetNetworkNodes(ingressNode.Network)
@@ -298,7 +298,7 @@ func BroadcastExtClient(ingressHost *models.Host, ingressNode *models.Node) erro
 	return nil
 }
 
-// BroadcastDelExtClient - removes ext client from network
+// BroadcastDelExtClient - published msg to remove ext client from network
 func BroadcastDelExtClient(ingressHost *models.Host, ingressNode *models.Node, extclient models.ExtClient) error {
 	// TODO - send fw update
 	go BroadcastAddOrUpdatePeer(ingressHost, ingressNode, true)