From 9332807d65fe4fff8af59a98b01cf37ae97e794f Mon Sep 17 00:00:00 2001 From: Jaeryn Date: Thu, 8 Sep 2022 09:25:18 -0700 Subject: [PATCH] Use 169.254.1.1 gw for cni in overlay mode --- cni/network/invoker_cns.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cni/network/invoker_cns.go b/cni/network/invoker_cns.go index 717fd45838..952f4ad0f2 100644 --- a/cni/network/invoker_cns.go +++ b/cni/network/invoker_cns.go @@ -20,8 +20,9 @@ import ( ) var ( - errEmptyCNIArgs = errors.New("empty CNI cmd args not allowed") - errInvalidArgs = errors.New("invalid arg(s)") + errEmptyCNIArgs = errors.New("empty CNI cmd args not allowed") + errInvalidArgs = errors.New("invalid arg(s)") + overlayGatewayIP = "169.254.1.1" ) type CNSIPAMInvoker struct { @@ -99,8 +100,12 @@ func (invoker *CNSIPAMInvoker) Add(addConfig IPAMAddConfig) (IPAMAddResult, erro log.Printf("[cni-invoker-cns] Received info %+v for pod %v", info, podInfo) ncgw := net.ParseIP(info.ncGatewayIPAddress) - if ncgw == nil && invoker.ipamMode != util.V4Overlay { - return IPAMAddResult{}, errors.Wrap(errInvalidArgs, "%w: Gateway address "+info.ncGatewayIPAddress+" from response is invalid") + if ncgw == nil { + if invoker.ipamMode != util.V4Overlay { + return IPAMAddResult{}, errors.Wrap(errInvalidArgs, "%w: Gateway address "+info.ncGatewayIPAddress+" from response is invalid") + } + + ncgw = net.ParseIP(overlayGatewayIP) } // set result ipconfigArgument from CNS Response Body