mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Compare commits
3 Commits
df4e97dc94
...
4c2edb8ddf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c2edb8ddf | ||
|
|
1136fd342c | ||
|
|
d058761dc7 |
3
.changelog/26910.txt
Normal file
3
.changelog/26910.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
client: Fixed CNI bridge networking failure on IPv6-only interfaces
|
||||
```
|
||||
@@ -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")
|
||||
|
||||
}
|
||||
|
||||
@@ -498,6 +498,34 @@ func TestCNI_cniToAllocNet_Dualstack(t *testing.T) {
|
||||
test.Eq(t, "eth0", allocNet.InterfaceName)
|
||||
}
|
||||
|
||||
// TestCNI_cniToAllocNet_IPv6Only asserts that CNI results containing only IPv6
|
||||
// addresses work correctly. This is a regression test for a bug introduced in
|
||||
// GH-23882 where IPv6-only interfaces would fail with "no interface with an address".
|
||||
func TestCNI_cniToAllocNet_IPv6Only(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
cniResult := &cni.Result{
|
||||
Interfaces: map[string]*cni.Config{
|
||||
"eth0": {
|
||||
Sandbox: "nomad-sandbox",
|
||||
IPConfigs: []*cni.IPConfig{
|
||||
{IP: net.ParseIP("fd00:a110:c8::b")}, // only IPv6
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
c := &cniNetworkConfigurator{
|
||||
logger: testlog.HCLogger(t),
|
||||
}
|
||||
allocNet, err := c.cniToAllocNet(cniResult)
|
||||
must.NoError(t, err)
|
||||
must.NotNil(t, allocNet)
|
||||
test.Eq(t, "", allocNet.Address)
|
||||
test.Eq(t, "fd00:a110:c8::b", allocNet.AddressIPv6)
|
||||
test.Eq(t, "eth0", allocNet.InterfaceName)
|
||||
}
|
||||
|
||||
func TestCNI_addCustomCNIArgs(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
cniArgs := map[string]string{
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user