Skip to content

Commit

Permalink
fix release ips when create a container without nictype using older c…
Browse files Browse the repository at this point in the history
…ni and then upgrade cni and delete

if we create a pod with an older cni version, it won't have a nictype
if we upgrade cni and then delete, we should treat an empty nictype as an infra nictype and
call the invoker delete
  • Loading branch information
QxBytes committed May 25, 2024
1 parent 8fed0ec commit 17c3fa0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
zap.String("endpointID", epInfo.EndpointID))
sendEvent(plugin, fmt.Sprintf("Deleting endpoint:%v", epInfo.EndpointID))

if !nwCfg.MultiTenancy && epInfo.NICType == cns.InfraNIC {
if !nwCfg.MultiTenancy && epInfo.NICType != cns.DelegatedVMNIC {
// Delegated/secondary nic ips are statically allocated so we don't need to release
// Call into IPAM plugin to release the endpoint's addresses.
for i := range epInfo.IPAddresses {
Expand Down
1 change: 0 additions & 1 deletion cni/network/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/Azure/azure-container-networking/cns"
"github.com/Azure/azure-container-networking/network"
"github.com/Azure/azure-container-networking/network/policy"
cniSkel "github.com/containernetworking/cni/pkg/skel"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/100"
)

Expand Down
2 changes: 2 additions & 0 deletions network/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@ func cnsEndpointInfotoCNIEpInfos(endpointInfo restserver.EndpointInfo, endpointI
return ret
}

// gets all endpoint infos associated with a container id and populates the network id field
// nictype may be empty in which case it is likely of type "infra"
func (nm *networkManager) GetEndpointInfosFromContainerID(containerID string) []*EndpointInfo {
ret := []*EndpointInfo{}
for _, extIf := range nm.ExternalInterfaces {
Expand Down

0 comments on commit 17c3fa0

Please sign in to comment.