diff --git a/client/allocrunner/networking_cni.go b/client/allocrunner/networking_cni.go index ae31d68ec..60a5ec451 100644 --- a/client/allocrunner/networking_cni.go +++ b/client/allocrunner/networking_cni.go @@ -480,8 +480,8 @@ func (c *cniNetworkConfigurator) cniToAllocNet(res *cni.Result) (*structs.AllocN } } - // found a good interface, so we're done - if netStatus.Address != "" { + // found a good interface (with either IPv4 or IPv6), so we're done + if netStatus.Address != "" || netStatus.AddressIPv6 != "" { netStatus.InterfaceName = name return } @@ -493,7 +493,7 @@ func (c *cniNetworkConfigurator) cniToAllocNet(res *cni.Result) (*structs.AllocN // If no IP address was found, use the first interface with an address // found as a fallback - if netStatus.Address == "" { + if netStatus.Address == "" && netStatus.AddressIPv6 == "" { setStatus(false) c.logger.Debug("no sandbox interface with an address found CNI result, using first available", "interface", netStatus.InterfaceName, @@ -501,8 +501,8 @@ func (c *cniNetworkConfigurator) cniToAllocNet(res *cni.Result) (*structs.AllocN ) } - // If no IP address could be found, return an error - if netStatus.Address == "" { + // If no IP address (IPv4 or IPv6) could be found, return an error + if netStatus.Address == "" && netStatus.AddressIPv6 == "" { return nil, fmt.Errorf("failed to configure network: no interface with an address") } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index d8cbf921c..4f99b92dd 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -12292,7 +12292,7 @@ func (a *AllocNetworkStatus) IsZero() bool { if a == nil { return true } - if a.InterfaceName != "" || a.Address != "" { + if a.InterfaceName != "" || a.Address != "" || a.AddressIPv6 != "" { return false } if !a.DNS.IsZero() {