Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cni/network/invoker_cns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down