From 292d9a9af356bec8954fb8d57b89968a00014454 Mon Sep 17 00:00:00 2001 From: venu iyer Date: Tue, 8 Sep 2020 14:53:25 -0700 Subject: [PATCH] Allow the default-route to be empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In https://docs.google.com/document/d/1Ny03h6IDVy_e_vmElOqR7UdTPAG_RNydhVE1Kx54kFQ, section 4.1.2.1.9, " 4.1.2.1.9 “default-route” Default route selection for a particular attachment This optional key with value of type string-array is used to explicitly select which attachment will receive the default route. The value of items in the “default-route” array are intended to be gateways, e.g. an IP address to which packets that do not match any other routes are sent. This key must only be set on one item in the Network Attachment Selection Annotation. This list may be empty. " However en empty list will fail currently; this change accommodates an empty "default-route" by retaining the default route added by the delegate. Signed-off-by: venugopal iyer --- multus/multus.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/multus/multus.go b/multus/multus.go index 9640dfda8..c97eeba68 100644 --- a/multus/multus.go +++ b/multus/multus.go @@ -581,7 +581,11 @@ func cmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c logging.Debugf("Marked interface %v for gateway deletion", ifName) } else { // Otherwise, determine if this interface now gets our default route. - if delegate.GatewayRequest != nil { + // According to + // https://docs.google.com/document/d/1Ny03h6IDVy_e_vmElOqR7UdTPAG_RNydhVE1Kx54kFQ (4.1.2.1.9) + // the list can be empty; if it is, we'll assume the CNI's config for the default gateway holds, + // else we'll update the defaultgateway to the one specified. + if delegate.GatewayRequest != nil && delegate.GatewayRequest[0] != nil { deletegateway = true adddefaultgateway = true logging.Debugf("Detected gateway override on interface %v to %v", ifName, delegate.GatewayRequest)