Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
91d6826
add body to unpublishNC calls and pass azID and enableAZR in it
smittal22 Jan 30, 2023
3327594
fix test
smittal22 Jan 30, 2023
ca82111
add body to unpublishNC calls and pass azID and enableAZR in it
smittal22 Jan 30, 2023
a88adfd
fix test
smittal22 Jan 30, 2023
1ff1186
fix: [NPM-LINUX] resiliency for several non-retriable errors (#1566)
huntergregory Nov 23, 2022
c54514e
feat: cns writes cni conflist (#1702)
thatmattlong Nov 29, 2022
895b95e
Fix failure to start CNS when setting WireserverIP (#1707)
timraymond Nov 30, 2022
c0efe9c
fix variable ordering in hackfile (#1697)
rbtr Dec 1, 2022
68c0778
add v1 conflist to dropgz (#1701)
rbtr Dec 1, 2022
9943b5d
fix: cns to use controller runtime (cached) clients in reconcilers (#…
rbtr Dec 6, 2022
f358e9a
feat: expose getHomeAzInfo api in cns to retrieve node home az infos …
ZetaoZhuang Dec 8, 2022
6655588
fix: [NPM-Win] Get local endpoints for updatepod, but all endpoints f…
vakalapa Dec 13, 2022
c368e6c
log: [NPM] warn instead of error on invalid Pod IPs (#1718)
huntergregory Dec 14, 2022
60d4ab4
Fix incorrect empty body provided to Wireserver (#1728)
timraymond Dec 16, 2022
44b3bdd
Network name as an optional variable (#1730)
pjohnst5 Dec 20, 2022
c43b9cc
Image name and tag print in makefile (#1734)
pjohnst5 Dec 22, 2022
33c7ccf
Enable auto updates for windows aks-engine clusters (#1732)
pjohnst5 Dec 30, 2022
812e5d8
remove windows 2004 aks-e tests from pipeline (#1736)
estebancams Jan 4, 2023
4106cf7
Revert linux e2e removal (#1731)
aegal Jan 4, 2023
1b36288
deps: bump sigs.k8s.io/controller-tools from 0.10.0 to 0.11.1 in /bui…
dependabot[bot] Jan 5, 2023
ccf369f
Updated aks-engine to unblock the pipeline. (#1745)
csfmomo Jan 6, 2023
a10c355
fix: repair windows cni lock issue (#1712)
behzad-mir Jan 7, 2023
2d36595
Fix broken NC publishing due to type mismatch (#1740)
pjohnst5 Jan 9, 2023
2651c74
deps: bump go.uber.org/zap from 1.23.0 to 1.24.0 in /zapai (#1709)
dependabot[bot] Jan 9, 2023
d57ca71
deps: bump go.uber.org/zap from 1.23.0 to 1.24.0 in /dropgz (#1710)
dependabot[bot] Jan 10, 2023
fe9cedd
deps: bump sigs.k8s.io/controller-runtime from 0.12.3 to 0.14.1 (#1749)
dependabot[bot] Jan 11, 2023
13ad6de
refactor and move the nmagentConfig code from cns to namgent package.…
ZetaoZhuang Jan 11, 2023
106f739
deps: bump github.com/spf13/viper from 1.12.0 to 1.14.0 (#1753)
dependabot[bot] Jan 11, 2023
1de29ca
deps: bump go.uber.org/zap from 1.23.0 to 1.24.0 in /azure-ipam (#1711)
dependabot[bot] Jan 11, 2023
ffe88be
deps: bump github.com/spf13/cobra from 1.6.0 to 1.6.1 (#1759)
dependabot[bot] Jan 12, 2023
31499ca
test: [NPM-LINUX] update linux conformance binary (#1748)
huntergregory Jan 17, 2023
9957809
update cilium version to fix pipelines (#1763)
rbtr Jan 19, 2023
c4e002c
Fix incorrect HTTP status from publish NC (#1757)
timraymond Jan 19, 2023
2533423
fix: [NPM] add NetworkPolicy validation for matchExpression values (#…
huntergregory Jan 19, 2023
e3e01b0
perf: [NPM-WIN] only track updatepods on-node (#1743)
huntergregory Jan 19, 2023
1b8f19d
fix: [NPM-WIN] ignore irrelevant errors from ipsetmanager (#1741)
huntergregory Jan 19, 2023
3b1cd16
nmagent get nv version list api V2 refactor (#1744)
csfmomo Jan 19, 2023
b447413
deps: bump github.com/containernetworking/plugins from 1.1.1 to 1.2.0…
dependabot[bot] Jan 19, 2023
36ecdad
deps: bump github.com/labstack/echo/v4 from 4.9.0 to 4.10.0 (#1737)
dependabot[bot] Jan 20, 2023
40207b8
deps: bump github.com/spf13/cobra from 1.5.0 to 1.6.1 in /dropgz (#1678)
dependabot[bot] Jan 23, 2023
eae967d
parameterize dependency versions in dropgz and update azcni (#1714)
rbtr Jan 24, 2023
288cd72
deps: bump google.golang.org/grpc from 1.50.1 to 1.52.0 (#1761)
dependabot[bot] Jan 25, 2023
e001b04
Merge branch 'saksham_azr_nc_delete' of https://github.com/smittal22/…
smittal22 Feb 3, 2023
5fdef3c
only unmarshal if body is not empty
smittal22 Feb 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cns/NetworkContainerContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,11 @@ type PublishNetworkContainerResponse struct {

// UnpublishNetworkContainerRequest specifies request to unpublish network container via NMAgent.
type UnpublishNetworkContainerRequest struct {
NetworkID string
NetworkContainerID string
JoinNetworkURL string
DeleteNetworkContainerURL string
NetworkID string
NetworkContainerID string
JoinNetworkURL string
DeleteNetworkContainerURL string
DeleteNetworkContainerRequestBody []byte
}

// UnpublishNetworkContainerResponse specifies the response to unpublish network container request.
Expand Down
43 changes: 32 additions & 11 deletions cns/restserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,32 @@ func (service *HTTPRestService) publishNetworkContainer(w http.ResponseWriter, r
logger.Response(service.Name, response, response.Response.ReturnCode, err)
}

//nolint:revive // the previous receiver naming "service" is bad, this is correct:
func (h *HTTPRestService) doUnpublish(ctx context.Context, req cns.UnpublishNetworkContainerRequest, dcr nmagent.DeleteContainerRequest) (string, types.ResponseCode) {
innerReqBytes := req.DeleteNetworkContainerRequestBody

if len(innerReqBytes) != 0 {
err := json.Unmarshal(innerReqBytes, &dcr)
if err != nil {
returnMessage := fmt.Sprintf("Failed to unmarshal NC unpublish request for NC %s, with error: %v", req.NetworkContainerID, err)
returnCode := types.NetworkContainerUnpublishFailed
logger.Errorf("[Azure-CNS] %s", returnMessage)
return returnMessage, returnCode
}
}

errDelete := h.nma.DeleteNetworkContainer(ctx, dcr)
// nolint:bodyclose // existing code needs refactoring
if errDelete != nil {
returnMessage := fmt.Sprintf("Failed to unpublish Network Container: %s. Error: %+v", req.NetworkContainerID, errDelete)
returnCode := types.NetworkContainerUnpublishFailed
logger.Errorf("[Azure-CNS] %s", returnMessage)
return returnMessage, returnCode
}

return "", types.Success
}

// Unpublish Network Container by calling nmagent
func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter, r *http.Request) {
logger.Printf("[Azure-CNS] UnpublishNetworkContainer")
Expand Down Expand Up @@ -1332,18 +1358,13 @@ func (service *HTTPRestService) unpublishNetworkContainer(w http.ResponseWriter,
}

if isNetworkJoined {
dcr := nmagent.DeleteContainerRequest{
NCID: req.NetworkContainerID,
PrimaryAddress: ncParameters.AssociatedInterfaceID,
AuthenticationToken: ncParameters.AuthToken,
}
var dcr nmagent.DeleteContainerRequest
dcr.NCID = req.NetworkContainerID
dcr.PrimaryAddress = ncParameters.AssociatedInterfaceID
dcr.AuthenticationToken = ncParameters.AuthToken

err = service.nma.DeleteNetworkContainer(ctx, dcr)
if err != nil {
returnMessage = fmt.Sprintf("Failed to unpublish Network Container: %s", req.NetworkContainerID)
returnCode = types.NetworkContainerUnpublishFailed
logger.Errorf("[Azure-CNS] %s", returnMessage)
}
// Unpublish Network Container
returnMessage, returnCode = service.doUnpublish(ctx, req, dcr)
}
default:
returnMessage = "UnpublishNetworkContainer API expects a POST"
Expand Down
9 changes: 5 additions & 4 deletions cns/restserver/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,11 @@ func unpublishNCViaCNS(networkID, networkContainerID, deleteNetworkContainerURL
joinNetworkURL := "http://" + nmagentEndpoint + "/dummyVnetURL"

unpublishNCRequest := &cns.UnpublishNetworkContainerRequest{
NetworkID: networkID,
NetworkContainerID: networkContainerID,
JoinNetworkURL: joinNetworkURL,
DeleteNetworkContainerURL: deleteNetworkContainerURL,
NetworkID: networkID,
NetworkContainerID: networkContainerID,
JoinNetworkURL: joinNetworkURL,
DeleteNetworkContainerURL: deleteNetworkContainerURL,
DeleteNetworkContainerRequestBody: []byte("{}"),
}

var body bytes.Buffer
Expand Down
4 changes: 3 additions & 1 deletion nmagent/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ var _ Request = DeleteContainerRequest{}
// DeleteContainerRequest represents all information necessary to request that
// NMAgent delete a particular network container
type DeleteContainerRequest struct {
NCID string `json:"-"` // the Network Container ID
NCID string `json:"-"` // the Network Container ID
AzID uint `json:"azID"` // home AZ of the Network Container
EnableAZR bool `json:"enableAZR"` // whether AZR is enabled or not

// PrimaryAddress is the primary customer address of the interface in the
// management VNET
Expand Down