Skip to content

Commit 03e7c21

Browse files
committed
skip adding IPs to trunk ENI; enable Custom Networking before SGPP
1 parent 190fad2 commit 03e7c21

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pkg/ipamd/datastore/data_store.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,8 @@ func (ds *DataStore) GetENINeedsIP(maxIPperENI int, skipPrimary bool) *ENI {
978978
ds.lock.Lock()
979979
defer ds.lock.Unlock()
980980
for _, eni := range ds.eniPool {
981-
if skipPrimary && eni.IsPrimary {
982-
ds.log.Debugf("Skip the primary ENI for need IP check")
981+
if (skipPrimary && eni.IsPrimary) || eni.IsTrunk {
982+
ds.log.Debugf("Skip needs IP check for trunk ENI of primary ENI when Custom Networking is enabled")
983983
continue
984984
}
985985
if len(eni.AvailableIPv4Cidrs) < maxIPperENI {

pkg/ipamd/ipamd.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ func (c *IPAMContext) nodeInit() error {
455455
return err
456456
}
457457

458-
if c.enablePodENI {
459-
// Try to patch CNINode with Security Groups for Pods feature.
460-
c.tryEnableSecurityGroupsForPods(ctx)
461-
}
462-
463458
if c.enableIPv6 {
459+
// Security Groups for Pods cannot be enabled for IPv4 at this point, as Custom Networking must be enabled first.
460+
if c.enablePodENI {
461+
// Try to patch CNINode with Security Groups for Pods feature.
462+
c.tryEnableSecurityGroupsForPods(ctx)
463+
}
464464
// We will not support upgrading/converting an existing IPv4 cluster to operate in IPv6 mode. So, we will always
465465
// start with a clean slate in IPv6 mode. We also do not have to deal with dynamic update of Prefix Delegation
466466
// feature in IPv6 mode as we do not support (yet) a non-PD v6 option. In addition, we do not support custom
@@ -540,6 +540,11 @@ func (c *IPAMContext) nodeInit() error {
540540
}
541541
}
542542

543+
// Now that Custom Networking is (potentially) enabled, Security Groups for Pods can be enabled for IPv4 nodes.
544+
if c.enablePodENI {
545+
c.tryEnableSecurityGroupsForPods(ctx)
546+
}
547+
543548
// On node init, check if datastore pool needs to be increased. If so, attach CIDRs from existing ENIs and attach new ENIs.
544549
datastorePoolTooLow, _ := c.isDatastorePoolTooLow()
545550
if !c.disableENIProvisioning && datastorePoolTooLow {

0 commit comments

Comments
 (0)