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 b7ce09fd49.
This commit is contained in:
Saksham Mittal 2024-09-11 21:19:07 -07:00 коммит произвёл GitHub
Родитель 60ddd3531a
Коммит ce617a7589
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 2 добавлений и 16 удалений

Просмотреть файл

@ -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)