Skip to content

Commit 1f32c9f

Browse files
Remove parsing GatewayIP and passing down to CNI (#1590)
Removed getting gatewayIP from cns and passing to cni in result structure
1 parent ffc1c87 commit 1f32c9f

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

azure-ipam/ipam.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error {
8080
p.logger.Debug("Received CNS IP config response", zap.Any("response", resp))
8181

8282
// Get Pod IP and gateway IP from ip config response
83-
podIPNet, gwIP, err := ipconfig.ProcessIPConfigResp(resp)
83+
podIPNet, err := ipconfig.ProcessIPConfigResp(resp)
8484
if err != nil {
8585
p.logger.Error("Failed to interpret CNS IPConfigResponse", zap.Error(err), zap.Any("response", resp))
8686
return cniTypes.NewError(ErrProcessIPConfigResponse, err.Error(), "failed to interpret CNS IPConfigResponse")
8787
}
88-
p.logger.Debug("Parsed pod IP and gateway IP", zap.String("podIPNet", podIPNet.String()), zap.String("gwIP", gwIP.String()))
88+
p.logger.Debug("Parsed pod IP", zap.String("podIPNet", podIPNet.String()))
8989

9090
cniResult := &types100.Result{
9191
IPs: []*types100.IPConfig{
@@ -94,16 +94,6 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error {
9494
IP: net.ParseIP(podIPNet.Addr().String()),
9595
Mask: net.CIDRMask(podIPNet.Bits(), 32), // nolint
9696
},
97-
Gateway: net.ParseIP(gwIP.String()),
98-
},
99-
},
100-
Routes: []*cniTypes.Route{
101-
{
102-
Dst: net.IPNet{
103-
IP: net.IPv4zero,
104-
Mask: net.IPv4Mask(0, 0, 0, 0),
105-
},
106-
GW: net.ParseIP(gwIP.String()),
10797
},
10898
},
10999
}

azure-ipam/ipconfig/ipconfig.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,18 @@ func CreateIPConfigReq(args *cniSkel.CmdArgs) (cns.IPConfigRequest, error) {
3939
}
4040

4141
// ProcessIPConfigResp processes the IPConfigResponse from the CNS.
42-
func ProcessIPConfigResp(resp *cns.IPConfigResponse) (*netip.Prefix, *netip.Addr, error) {
42+
func ProcessIPConfigResp(resp *cns.IPConfigResponse) (*netip.Prefix, error) {
4343
podCIDR := fmt.Sprintf(
4444
"%s/%d",
4545
resp.PodIpInfo.PodIPConfig.IPAddress,
4646
resp.PodIpInfo.NetworkContainerPrimaryIPConfig.IPSubnet.PrefixLength,
4747
)
4848
podIPNet, err := netip.ParsePrefix(podCIDR)
4949
if err != nil {
50-
return nil, nil, errors.Wrapf(err, "cns returned invalid pod CIDR %q", podCIDR)
50+
return nil, errors.Wrapf(err, "cns returned invalid pod CIDR %q", podCIDR)
5151
}
5252

53-
ncGatewayIPAddress := resp.PodIpInfo.NetworkContainerPrimaryIPConfig.GatewayIPAddress
54-
gwIP, err := netip.ParseAddr(ncGatewayIPAddress)
55-
if err != nil {
56-
return nil, nil, errors.Wrapf(err, "cns returned an invalid gateway address %q", ncGatewayIPAddress)
57-
}
58-
59-
return &podIPNet, &gwIP, nil
53+
return &podIPNet, nil
6054
}
6155

6256
type k8sPodEnvArgs struct {

0 commit comments

Comments
 (0)