Skip to content

Commit f3eb36f

Browse files
author
Rahul Sharma
committed
use slaac ranges as well in evaluation
1 parent 122b25d commit f3eb36f

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

cloud/nodeipam/ipam/cloud_allocator.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,19 @@ func (c *cloudAllocator) occupyCIDRs(ctx context.Context, node *v1.Node) error {
324324
return nil
325325
}
326326

327+
// getIPv6RangeFromInterface extracts the IPv6 range from a Linode instance configuration interface.
328+
func getIPv6RangeFromInterface(iface linodego.InstanceConfigInterface) string {
329+
if ipv6 := iface.IPv6; ipv6 != nil {
330+
if len(ipv6.SLAAC) > 0 {
331+
return ipv6.SLAAC[0].Range
332+
}
333+
if len(ipv6.Ranges) > 0 {
334+
return ipv6.Ranges[0].Range
335+
}
336+
}
337+
return ""
338+
}
339+
327340
// allocateIPv6CIDR allocates an IPv6 CIDR for the given node.
328341
// It retrieves the instance configuration for the node and extracts the IPv6 range.
329342
// It then creates a new net.IPNet with the IPv6 address and mask size defined
@@ -351,8 +364,9 @@ func (c *cloudAllocator) allocateIPv6CIDR(ctx context.Context, node *v1.Node) (*
351364
ipv6Range := ""
352365
for _, iface := range configs[0].Interfaces {
353366
if iface.Purpose == linodego.InterfacePurposeVPC {
354-
if iface.IPv6 != nil && iface.IPv6.Ranges != nil && len(iface.IPv6.Ranges) > 0 {
355-
ipv6Range = iface.IPv6.Ranges[0].Range
367+
ipv6Range = getIPv6RangeFromInterface(iface)
368+
if ipv6Range != "" {
369+
break
356370
}
357371
}
358372
}

0 commit comments

Comments
 (0)