@@ -311,17 +311,31 @@ func (ca *cloudCIDRAllocator) updateCIDRAllocation(nodeName string) error {
311
311
312
312
cidrStrings := make ([]string , 0 )
313
313
314
- if len (instance .NetworkInterfaces ) == 0 || (len (instance .NetworkInterfaces ) == 1 && len (instance .NetworkInterfaces [0 ].AliasIpRanges ) == 0 ) {
314
+ // if there are no interfaces or there is 1 interface
315
+ // but does not have IP alias or IPv6 ranges no CIDR
316
+ // can be allocated
317
+ if len (instance .NetworkInterfaces ) == 0 ||
318
+ (len (instance .NetworkInterfaces ) == 1 &&
319
+ len (instance .NetworkInterfaces [0 ].AliasIpRanges ) == 0 &&
320
+ ca .cloud .GetIPV6Address (instance .NetworkInterfaces [0 ]) == nil ) {
315
321
nodeutil .RecordNodeStatusChange (ca .recorder , node , "CIDRNotAvailable" )
316
322
return fmt .Errorf ("failed to allocate cidr: Node %v has no ranges from which CIDRs can be allocated" , node .Name )
317
323
}
318
324
319
325
// sets the v1.NodeNetworkUnavailable condition to False
320
326
ca .setNetworkCondition (node )
321
327
322
- // nodes in clusters WITHOUT multi-networking are expected to have only 1 network-interface with 1 alias IP range.
323
- if len (instance .NetworkInterfaces ) == 1 && len (instance .NetworkInterfaces [0 ].AliasIpRanges ) == 1 {
324
- cidrStrings = append (cidrStrings , instance .NetworkInterfaces [0 ].AliasIpRanges [0 ].IpCidrRange )
328
+ // nodes in clusters WITHOUT multi-networking are expected to have
329
+ // only 1 network-interface and 1 alias IPv4 range or/and 1 IPv6 address
330
+ // multi-network cluster may have 1 interface with multiple alias
331
+ if len (instance .NetworkInterfaces ) == 1 &&
332
+ (len (instance .NetworkInterfaces [0 ].AliasIpRanges ) == 1 ||
333
+ ca .cloud .GetIPV6Address (instance .NetworkInterfaces [0 ]) != nil ) {
334
+ // with 1 alias IPv4 range on single IPv4 or dual stack clusters
335
+ if len (instance .NetworkInterfaces [0 ].AliasIpRanges ) == 1 {
336
+ cidrStrings = append (cidrStrings , instance .NetworkInterfaces [0 ].AliasIpRanges [0 ].IpCidrRange )
337
+ }
338
+ // with 1 IPv6 range on single IPv6 or dual stack cluster
325
339
ipv6Addr := ca .cloud .GetIPV6Address (instance .NetworkInterfaces [0 ])
326
340
if ipv6Addr != nil {
327
341
cidrStrings = append (cidrStrings , ipv6Addr .String ())
0 commit comments