Allow random UUID
This commit is contained in:
parent
a7dad8b86f
commit
6910678c21
|
@ -639,7 +639,7 @@ func (c *Client) getAllocRunners() map[string]*AllocRunner {
|
|||
func (c *Client) nodeID() (id, secret string, err error) {
|
||||
var hostID string
|
||||
hostInfo, err := host.Info()
|
||||
if err == nil && helper.IsUUID(hostInfo.HostID) {
|
||||
if !c.config.NoHostUUID && err == nil && helper.IsUUID(hostInfo.HostID) {
|
||||
hostID = hostInfo.HostID
|
||||
} else {
|
||||
// Generate a random hostID if no constant ID is available on
|
||||
|
|
|
@ -165,6 +165,10 @@ type Config struct {
|
|||
|
||||
// LogLevel is the level of the logs to putout
|
||||
LogLevel string
|
||||
|
||||
// NoHostUUID disables using the host's UUID and will force generation of a
|
||||
// random UUID.
|
||||
NoHostUUID bool
|
||||
}
|
||||
|
||||
func (c *Config) Copy() *Config {
|
||||
|
|
|
@ -312,6 +312,7 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) {
|
|||
conf.GCInterval = a.config.Client.GCInterval
|
||||
conf.GCDiskUsageThreshold = a.config.Client.GCDiskUsageThreshold
|
||||
conf.GCInodeUsageThreshold = a.config.Client.GCInodeUsageThreshold
|
||||
conf.NoHostUUID = a.config.Client.NoHostUUID
|
||||
|
||||
return conf, nil
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ client {
|
|||
gc_interval = "6s"
|
||||
gc_disk_usage_threshold = 82
|
||||
gc_inode_usage_threshold = 91
|
||||
no_host_uuid = true
|
||||
}
|
||||
server {
|
||||
enabled = true
|
||||
|
|
|
@ -209,6 +209,10 @@ type ClientConfig struct {
|
|||
// GCInodeUsageThreshold is the inode usage threshold beyond which the Nomad
|
||||
// client triggers GC of the terminal allocations
|
||||
GCInodeUsageThreshold float64 `mapstructure:"gc_inode_usage_threshold"`
|
||||
|
||||
// NoHostUUID disables using the host's UUID and will force generation of a
|
||||
// random UUID.
|
||||
NoHostUUID bool `mapstructure:"no_host_uuid"`
|
||||
}
|
||||
|
||||
// ServerConfig is configuration specific to the server mode
|
||||
|
@ -931,6 +935,9 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig {
|
|||
if b.GCInodeUsageThreshold != 0 {
|
||||
result.GCInodeUsageThreshold = b.GCInodeUsageThreshold
|
||||
}
|
||||
if b.NoHostUUID {
|
||||
result.NoHostUUID = b.NoHostUUID
|
||||
}
|
||||
|
||||
// Add the servers
|
||||
result.Servers = append(result.Servers, b.Servers...)
|
||||
|
|
|
@ -344,6 +344,7 @@ func parseClient(result **ClientConfig, list *ast.ObjectList) error {
|
|||
"gc_interval",
|
||||
"gc_disk_usage_threshold",
|
||||
"gc_inode_usage_threshold",
|
||||
"no_host_uuid",
|
||||
}
|
||||
if err := checkHCLKeys(listVal, valid); err != nil {
|
||||
return err
|
||||
|
|
|
@ -73,6 +73,7 @@ func TestConfig_Parse(t *testing.T) {
|
|||
GCInterval: 6 * time.Second,
|
||||
GCDiskUsageThreshold: 82,
|
||||
GCInodeUsageThreshold: 91,
|
||||
NoHostUUID: true,
|
||||
},
|
||||
Server: &ServerConfig{
|
||||
Enabled: true,
|
||||
|
|
|
@ -7,6 +7,7 @@ data_dir = "/tmp/client2"
|
|||
# Enable the client
|
||||
client {
|
||||
enabled = true
|
||||
no_host_uuid = true
|
||||
|
||||
# For demo assume we are talking to server1. For production,
|
||||
# this should be like "nomad.service.consul:4647" and a system
|
||||
|
|
|
@ -92,6 +92,9 @@ client {
|
|||
- `gc_inode_usage_threshold` `(float: 70)` - Specifies the inode usage percent
|
||||
which Nomad tries to maintain by garbage collecting terminal allocations.
|
||||
|
||||
- `no_host_uuid` `(bool: false)` - Force the UUID generated by the client to be
|
||||
randomly generated and not be based on the host's UUID.
|
||||
|
||||
### `chroot_env` Parameters
|
||||
|
||||
Drivers based on [isolated fork/exec](/docs/drivers/exec.html) implement file
|
||||
|
|
Loading…
Reference in New Issue