mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
fingerprint: fix 'default' alias not added to interface specified by network_interface (#18096)
This commit is contained in:
3
.changelog/18096.txt
Normal file
3
.changelog/18096.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
fingerprint: fix 'default' alias not being added to interface specified by network_interface
|
||||
```
|
||||
@@ -247,18 +247,14 @@ func deriveAddressAliases(iface net.Interface, addr net.IP, config *config.Confi
|
||||
}
|
||||
}
|
||||
|
||||
if len(aliases) > 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if config.NetworkInterface != "" {
|
||||
if config.NetworkInterface == iface.Name {
|
||||
return []string{"default"}
|
||||
aliases = append(aliases, "default")
|
||||
}
|
||||
} else if ri, err := sockaddr.NewRouteInfo(); err == nil {
|
||||
defaultIface, err := ri.GetDefaultInterfaceName()
|
||||
if err == nil && iface.Name == defaultIface {
|
||||
return []string{"default"}
|
||||
aliases = append(aliases, "default")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -500,6 +500,9 @@ func TestNetworkFingerPrint_MultipleAliases(t *testing.T) {
|
||||
for alias := range cfg.HostNetworks {
|
||||
expected = append(expected, alias)
|
||||
}
|
||||
// eth3 matches the NetworkInterface and will then generate the 'default'
|
||||
// alias
|
||||
expected = append(expected, "default")
|
||||
sort.Strings(expected)
|
||||
sort.Strings(aliases)
|
||||
require.Equal(t, expected, aliases, "host networks should match aliases")
|
||||
@@ -537,7 +540,7 @@ func TestNetworkFingerPrint_HostNetworkReservedPorts(t *testing.T) {
|
||||
CIDR: "100.64.0.11/10",
|
||||
},
|
||||
},
|
||||
expected: []string{"", "", ""},
|
||||
expected: []string{"", "", "", ""},
|
||||
},
|
||||
{
|
||||
name: "reserved ports in some aliases",
|
||||
@@ -560,7 +563,7 @@ func TestNetworkFingerPrint_HostNetworkReservedPorts(t *testing.T) {
|
||||
CIDR: "100.64.0.11/10",
|
||||
},
|
||||
},
|
||||
expected: []string{"22", "80,3000-4000", ""},
|
||||
expected: []string{"22", "80,3000-4000", "", ""},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user