From ce617a75898e86aabce56069fdca39fefa90cdc8 Mon Sep 17 00:00:00 2001 From: Saksham Mittal <111590532+smittal22@users.noreply.github.com> Date: Wed, 11 Sep 2024 21:19:07 -0700 Subject: [PATCH] Revert "Add join VNET call for every AZR NC unpublish call" (#3008) Revert "Add join VNET call for every AZR NC unpublish call (#2983)" This reverts commit b7ce09fd4973e7231784760dcb8dd7577e3e9f86. --- cns/restserver/api.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/cns/restserver/api.go b/cns/restserver/api.go index 639cf2939..07cfc283c 100644 --- a/cns/restserver/api.go +++ b/cns/restserver/api.go @@ -20,7 +20,6 @@ import ( "github.com/Azure/azure-container-networking/cns/types" "github.com/Azure/azure-container-networking/cns/wireserver" "github.com/Azure/azure-container-networking/common" - "github.com/Azure/azure-container-networking/nmagent" "github.com/pkg/errors" ) @@ -1030,20 +1029,7 @@ func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter, ctx := r.Context() - var unpublishBody nmagent.DeleteContainerRequest - if req.DeleteNetworkContainerRequestBody != nil { - err = json.Unmarshal(req.DeleteNetworkContainerRequestBody, &unpublishBody) - if err != nil { - http.Error(w, fmt.Sprintf("could not unmarshal delete network container body: %v", err), http.StatusBadRequest) - return - } - } - - /* For AZR scenarios, if NMAgent is restarted, it loses state and does not know what VNETs to subscribe to. - As it no longer has VNET state, delete nc calls would fail. We need to add join VNET call for all AZR - nc unpublish calls just like publish nc calls. - */ - if unpublishBody.AZREnabled || !service.isNetworkJoined(req.NetworkID) { + if !service.isNetworkJoined(req.NetworkID) { joinResp, err := service.wsproxy.JoinNetwork(ctx, req.NetworkID) //nolint:govet // ok to shadow if err != nil { resp := cns.UnpublishNetworkContainerResponse{ @@ -1076,7 +1062,7 @@ func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter, } service.setNetworkStateJoined(req.NetworkID) - logger.Printf("[Azure-CNS] joined vnet %s during nc %s unpublish. AZREnabled: %t, wireserver response: %v", req.NetworkID, req.NetworkContainerID, unpublishBody.AZREnabled, string(joinBytes)) + logger.Printf("[Azure-CNS] joined vnet %s during nc %s unpublish. wireserver response: %v", req.NetworkID, req.NetworkContainerID, string(joinBytes)) } publishResp, err := service.wsproxy.UnpublishNC(ctx, ncParams, req.DeleteNetworkContainerRequestBody)