mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
client: Add a preferred address family option for network-interface (#23389)
to prefer ipv4 or ipv6 when deducing IP from network interface Co-authored-by: Daniel Bennett <dbennett@hashicorp.com>
This commit is contained in:
@@ -116,6 +116,7 @@ func (c *Command) readConfig() *Config {
|
||||
flags.StringVar(&servers, "servers", "", "")
|
||||
flags.Var((*flaghelper.StringFlag)(&meta), "meta", "")
|
||||
flags.StringVar(&cmdConfig.Client.NetworkInterface, "network-interface", "", "")
|
||||
flags.StringVar((*string)(&cmdConfig.Client.PreferredAddressFamily), "preferred-address-family", "", "ipv4 or ipv6")
|
||||
flags.IntVar(&cmdConfig.Client.NetworkSpeed, "network-speed", 0, "")
|
||||
|
||||
// General options
|
||||
@@ -485,6 +486,14 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if err := config.Client.PreferredAddressFamily.Validate(); err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Invalid preferred-address-family value: %s (valid values: %s, %s)",
|
||||
config.Client.PreferredAddressFamily,
|
||||
structs.NodeNetworkAF_IPv4, structs.NodeNetworkAF_IPv6),
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if !config.DevMode {
|
||||
// Ensure that we have the directories we need to run.
|
||||
if config.Server.Enabled && config.DataDir == "" {
|
||||
@@ -1549,6 +1558,11 @@ Client Options:
|
||||
|
||||
-network-interface
|
||||
Forces the network fingerprinter to use the specified network interface.
|
||||
|
||||
-preferred-address-family
|
||||
Specify which IP family to prefer when selecting an IP address of the
|
||||
network interface. Valid values are "ipv4" and "ipv6". When not specified,
|
||||
the agent will not sort the addresses and use the first one.
|
||||
|
||||
-network-speed
|
||||
The default speed for network interfaces in MBits if the link speed can not
|
||||
|
||||
Reference in New Issue
Block a user