Skip to content

Commit 7c5292d

Browse files
committed
fix: endpointID for Stateless CNI should add ifName if the NiCType is DelegatedNIC to cover for SwiftV2
1 parent 560cf9a commit 7c5292d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

cni/network/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,11 +712,11 @@ func (plugin *NetPlugin) createEpInfo(opt *createEpInfoOpt) (*network.EndpointIn
712712
if opt.ifInfo.NICType == cns.InfraNIC && !*opt.infraSeen {
713713
// so we do not break existing scenarios, only the first infra gets the original endpoint id generation
714714
ifName = opt.args.IfName
715-
endpointID = plugin.nm.GetEndpointID(opt.args.ContainerID, ifName)
715+
endpointID = plugin.nm.GetEndpointID(opt.args.ContainerID, ifName, opt.ifInfo.NICType)
716716
*opt.infraSeen = true
717717
} else {
718718
ifName = "eth" + strconv.Itoa(opt.endpointIndex)
719-
endpointID = plugin.nm.GetEndpointID(opt.args.ContainerID, ifName)
719+
endpointID = plugin.nm.GetEndpointID(opt.args.ContainerID, ifName, opt.ifInfo.NICType)
720720
}
721721

722722
endpointInfo := network.EndpointInfo{
@@ -1096,7 +1096,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
10961096
// for when the endpoint is not created, but the ips are already allocated (only works if single network, single infra)
10971097
// this block is not applied to stateless CNI
10981098
if len(epInfos) == 0 {
1099-
endpointID := plugin.nm.GetEndpointID(args.ContainerID, args.IfName)
1099+
endpointID := plugin.nm.GetEndpointID(args.ContainerID, args.IfName, cns.InfraNIC)
11001100
if !nwCfg.MultiTenancy {
11011101
logger.Warn("Could not query endpoint",
11021102
zap.String("endpoint", endpointID),

network/manager.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ type NetworkManager interface {
115115
DetachEndpoint(networkID string, endpointID string) error
116116
UpdateEndpoint(networkID string, existingEpInfo *EndpointInfo, targetEpInfo *EndpointInfo) error
117117
GetNumberOfEndpoints(ifName string, networkID string) int
118-
GetEndpointID(containerID, ifName string) string
118+
GetEndpointID(containerID, ifName string, nicType cns.NICType) string
119119
IsStatelessCNIMode() bool
120120
SaveState(eps []*endpoint) error
121121
DeleteState(epInfos []*EndpointInfo) error
@@ -732,8 +732,11 @@ func (nm *networkManager) GetNumberOfEndpoints(ifName string, networkId string)
732732
}
733733

734734
// GetEndpointID returns a unique endpoint ID based on the CNI mode.
735-
func (nm *networkManager) GetEndpointID(containerID, ifName string) string {
735+
func (nm *networkManager) GetEndpointID(containerID, ifName string, nicType cns.NICType) string {
736736
if nm.IsStatelessCNIMode() {
737+
if nicType == cns.DelegatedVMNIC {
738+
return containerID + "-" + ifName
739+
}
737740
return containerID
738741
}
739742
if len(containerID) > ContainerIDLength {

0 commit comments

Comments
 (0)