Skip to content

Commit ce617a7

Browse files
authored
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 b7ce09f.
1 parent 60ddd35 commit ce617a7

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

cns/restserver/api.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/Azure/azure-container-networking/cns/types"
2121
"github.com/Azure/azure-container-networking/cns/wireserver"
2222
"github.com/Azure/azure-container-networking/common"
23-
"github.com/Azure/azure-container-networking/nmagent"
2423
"github.com/pkg/errors"
2524
)
2625

@@ -1030,20 +1029,7 @@ func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter,
10301029

10311030
ctx := r.Context()
10321031

1033-
var unpublishBody nmagent.DeleteContainerRequest
1034-
if req.DeleteNetworkContainerRequestBody != nil {
1035-
err = json.Unmarshal(req.DeleteNetworkContainerRequestBody, &unpublishBody)
1036-
if err != nil {
1037-
http.Error(w, fmt.Sprintf("could not unmarshal delete network container body: %v", err), http.StatusBadRequest)
1038-
return
1039-
}
1040-
}
1041-
1042-
/* For AZR scenarios, if NMAgent is restarted, it loses state and does not know what VNETs to subscribe to.
1043-
As it no longer has VNET state, delete nc calls would fail. We need to add join VNET call for all AZR
1044-
nc unpublish calls just like publish nc calls.
1045-
*/
1046-
if unpublishBody.AZREnabled || !service.isNetworkJoined(req.NetworkID) {
1032+
if !service.isNetworkJoined(req.NetworkID) {
10471033
joinResp, err := service.wsproxy.JoinNetwork(ctx, req.NetworkID) //nolint:govet // ok to shadow
10481034
if err != nil {
10491035
resp := cns.UnpublishNetworkContainerResponse{
@@ -1076,7 +1062,7 @@ func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter,
10761062
}
10771063

10781064
service.setNetworkStateJoined(req.NetworkID)
1079-
logger.Printf("[Azure-CNS] joined vnet %s during nc %s unpublish. AZREnabled: %t, wireserver response: %v", req.NetworkID, req.NetworkContainerID, unpublishBody.AZREnabled, string(joinBytes))
1065+
logger.Printf("[Azure-CNS] joined vnet %s during nc %s unpublish. wireserver response: %v", req.NetworkID, req.NetworkContainerID, string(joinBytes))
10801066
}
10811067

10821068
publishResp, err := service.wsproxy.UnpublishNC(ctx, ncParams, req.DeleteNetworkContainerRequestBody)

0 commit comments

Comments
 (0)