Skip to content

Commit

Permalink
Revert "Add join VNET call for every AZR NC unpublish call" (#3008)
Browse files Browse the repository at this point in the history
Revert "Add join VNET call for every AZR NC unpublish call (#2983)"

This reverts commit b7ce09f.
  • Loading branch information
smittal22 authored Sep 12, 2024
1 parent 60ddd35 commit ce617a7
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions cns/restserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ce617a7

Please sign in to comment.