Skip to content

Commit 2c746a4

Browse files
committed
Updated ipam to only send macaddr
revert
1 parent 98e4976 commit 2c746a4

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

azure-ipam/ipam.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,24 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error {
143143
cniResult.IPs[i] = ipConfig
144144
}
145145

146-
cniResult.Interfaces = make([]*types100.Interface, 1)
147-
interfaceMap := make(map[string]bool)
148-
cniResult.Interfaces = make([]*types100.Interface, 0, len(resp.PodIPInfo))
146+
cniResult.Interfaces = []*types100.Interface{}
147+
seenInterfaces := map[string]bool{}
148+
149149
for _, podIPInfo := range resp.PodIPInfo {
150-
if _, exists := interfaceMap[podIPInfo.InterfaceName]; !exists {
151-
cniResult.Interfaces = append(cniResult.Interfaces, &types100.Interface{
152-
Name: podIPInfo.InterfaceName, // Populate interface name based on MacAddress
153-
Mac: podIPInfo.MacAddress,
154-
})
155-
interfaceMap[podIPInfo.InterfaceName] = true
150+
if seenInterfaces[podIPInfo.MacAddress] {
151+
continue
152+
}
153+
154+
infMac, err := net.ParseMAC(podIPInfo.MacAddress)
155+
if err != nil {
156+
p.logger.Error("Failed to parse interface MAC address", zap.Error(err), zap.String("macAddress", podIPInfo.MacAddress))
157+
return cniTypes.NewError(cniTypes.ErrUnsupportedField, err.Error(), "failed to parse interface MAC address")
156158
}
159+
160+
cniResult.Interfaces = append(cniResult.Interfaces, &types100.Interface{
161+
Mac: infMac.String(),
162+
})
163+
seenInterfaces[podIPInfo.MacAddress] = true
157164
}
158165

159166
// Get versioned result

cns/restserver/util.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(req cns.CreateNetw
171171
hostVersion = "-1"
172172
}
173173

174-
hostVersion = req.Version
175-
176174
// Remove the auth token before saving the containerStatus to cns json file
177175
createNetworkContainerRequest := req
178176
createNetworkContainerRequest.AuthorizationToken = ""

0 commit comments

Comments
 (0)