mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
client: enhance CNI address handling for backward compatibility
Add fallback logic in cniToAllocNet to populate the Address field with the IPv6 address when no IPv4 address is available. This change ensures compatibility with existing code that relies on the Address field for service registration, particularly in scenarios where only IPv6 addresses are present.
This commit is contained in:
@@ -507,6 +507,13 @@ func (c *cniNetworkConfigurator) cniToAllocNet(res *cni.Result) (*structs.AllocN
|
||||
|
||||
}
|
||||
|
||||
// Fallback: if no IPv4 address but we have IPv6, copy it to Address field
|
||||
// for backward compatibility with code that only checks Address field
|
||||
// (e.g. service registration with address_mode="alloc")
|
||||
if netStatus.Address == "" && netStatus.AddressIPv6 != "" {
|
||||
netStatus.Address = netStatus.AddressIPv6
|
||||
}
|
||||
|
||||
// Use the first DNS results, if non-empty
|
||||
if len(res.DNS) > 0 {
|
||||
cniDNS := res.DNS[0]
|
||||
|
||||
Reference in New Issue
Block a user