From c3cf220fcec32249cad5fe0c62c786090601fd47 Mon Sep 17 00:00:00 2001 From: komey Date: Wed, 18 Dec 2019 16:07:45 +0800 Subject: [PATCH 1/2] [FIX] add up ensure service cidr config within daemonModeENIMultiIP, (eniIPVirtualTypeIPVlan needed) --- daemon/k8s.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/daemon/k8s.go b/daemon/k8s.go index eed90116..8aa0a2e5 100644 --- a/daemon/k8s.go +++ b/daemon/k8s.go @@ -76,11 +76,13 @@ func newK8S(client kubernetes.Interface, svcCidr *net.IPNet, daemonMode string) if err != nil { return nil, errors.Wrap(err, "failed getting node cidr") } - if svcCidr == nil { - svcCidr, err = serviceCidrFromAPIServer(client) - if err != nil { - return nil, errors.Wrap(err, "failed getting service cidr") - } + } + + // fixme: mode ENIMultiIP with IPVlan need to ensure service cidr but Veth won't, should we add up a new daemonModeENIIPVlan ? + if svcCidr == nil && (daemonMode == daemonModeVPC || daemonMode == daemonModeENIMultiIP) { + svcCidr, err = serviceCidrFromAPIServer(client) + if err != nil { + return nil, errors.Wrap(err, "failed getting service cidr") } } From 9a00caa0a0d4ebebd5faf0a9b6ecc514f8ff132c Mon Sep 17 00:00:00 2001 From: komey Date: Wed, 18 Dec 2019 21:42:46 +0800 Subject: [PATCH 2/2] [FIX] add up ensure service cidr config --- daemon/k8s.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/daemon/k8s.go b/daemon/k8s.go index 8aa0a2e5..50bb217e 100644 --- a/daemon/k8s.go +++ b/daemon/k8s.go @@ -70,19 +70,18 @@ func newK8S(client kubernetes.Interface, svcCidr *net.IPNet, daemonMode string) return nil, errors.Wrap(err, "failed getting node name") } - var nodeCidr *net.IPNet - if daemonMode == daemonModeVPC { - nodeCidr, err = nodeCidrFromAPIServer(client, nodeName) + if svcCidr == nil { + svcCidr, err = serviceCidrFromAPIServer(client) if err != nil { - return nil, errors.Wrap(err, "failed getting node cidr") + return nil, errors.Wrap(err, "failed getting service cidr") } } - // fixme: mode ENIMultiIP with IPVlan need to ensure service cidr but Veth won't, should we add up a new daemonModeENIIPVlan ? - if svcCidr == nil && (daemonMode == daemonModeVPC || daemonMode == daemonModeENIMultiIP) { - svcCidr, err = serviceCidrFromAPIServer(client) + var nodeCidr *net.IPNet + if daemonMode == daemonModeVPC { + nodeCidr, err = nodeCidrFromAPIServer(client, nodeName) if err != nil { - return nil, errors.Wrap(err, "failed getting service cidr") + return nil, errors.Wrap(err, "failed getting node cidr") } }