From 2428c3caf4739c21e7095842edda4bcc3acf1294 Mon Sep 17 00:00:00 2001 From: tamanoha Date: Thu, 8 Sep 2022 16:25:20 -0700 Subject: [PATCH] Removed getting gatewayIP from cns and passing to cni in result structure --- azure-ipam/ipam.go | 14 ++------------ azure-ipam/ipconfig/ipconfig.go | 12 +++--------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/azure-ipam/ipam.go b/azure-ipam/ipam.go index a0042e0193..b3803a3c7d 100644 --- a/azure-ipam/ipam.go +++ b/azure-ipam/ipam.go @@ -80,12 +80,12 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error { p.logger.Debug("Received CNS IP config response", zap.Any("response", resp)) // Get Pod IP and gateway IP from ip config response - podIPNet, gwIP, err := ipconfig.ProcessIPConfigResp(resp) + podIPNet, err := ipconfig.ProcessIPConfigResp(resp) if err != nil { p.logger.Error("Failed to interpret CNS IPConfigResponse", zap.Error(err), zap.Any("response", resp)) return cniTypes.NewError(ErrProcessIPConfigResponse, err.Error(), "failed to interpret CNS IPConfigResponse") } - p.logger.Debug("Parsed pod IP and gateway IP", zap.String("podIPNet", podIPNet.String()), zap.String("gwIP", gwIP.String())) + p.logger.Debug("Parsed pod IP", zap.String("podIPNet", podIPNet.String())) cniResult := &types100.Result{ IPs: []*types100.IPConfig{ @@ -94,16 +94,6 @@ func (p *IPAMPlugin) CmdAdd(args *cniSkel.CmdArgs) error { IP: net.ParseIP(podIPNet.Addr().String()), Mask: net.CIDRMask(podIPNet.Bits(), 32), // nolint }, - Gateway: net.ParseIP(gwIP.String()), - }, - }, - Routes: []*cniTypes.Route{ - { - Dst: net.IPNet{ - IP: net.IPv4zero, - Mask: net.IPv4Mask(0, 0, 0, 0), - }, - GW: net.ParseIP(gwIP.String()), }, }, } diff --git a/azure-ipam/ipconfig/ipconfig.go b/azure-ipam/ipconfig/ipconfig.go index a560d44743..9bfe2525ae 100644 --- a/azure-ipam/ipconfig/ipconfig.go +++ b/azure-ipam/ipconfig/ipconfig.go @@ -39,7 +39,7 @@ func CreateIPConfigReq(args *cniSkel.CmdArgs) (cns.IPConfigRequest, error) { } // ProcessIPConfigResp processes the IPConfigResponse from the CNS. -func ProcessIPConfigResp(resp *cns.IPConfigResponse) (*netip.Prefix, *netip.Addr, error) { +func ProcessIPConfigResp(resp *cns.IPConfigResponse) (*netip.Prefix, error) { podCIDR := fmt.Sprintf( "%s/%d", resp.PodIpInfo.PodIPConfig.IPAddress, @@ -47,16 +47,10 @@ func ProcessIPConfigResp(resp *cns.IPConfigResponse) (*netip.Prefix, *netip.Addr ) podIPNet, err := netip.ParsePrefix(podCIDR) if err != nil { - return nil, nil, errors.Wrapf(err, "cns returned invalid pod CIDR %q", podCIDR) + return nil, errors.Wrapf(err, "cns returned invalid pod CIDR %q", podCIDR) } - ncGatewayIPAddress := resp.PodIpInfo.NetworkContainerPrimaryIPConfig.GatewayIPAddress - gwIP, err := netip.ParseAddr(ncGatewayIPAddress) - if err != nil { - return nil, nil, errors.Wrapf(err, "cns returned an invalid gateway address %q", ncGatewayIPAddress) - } - - return &podIPNet, &gwIP, nil + return &podIPNet, nil } type k8sPodEnvArgs struct {