diff --git a/command/agent/command.go b/command/agent/command.go index 4abdfcc51e4..ffa1da9f279 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -589,6 +589,10 @@ func (c *Command) Run(args []string) int { } if config.Client.Enabled && config.Client.ServerJoin != nil { + // COMPAT: Remove in 0.10 set the default RetryInterval value, as the + // ServerJoin stanza is not part of a default config for an agent. + config.Client.ServerJoin.RetryInterval = time.Duration(30) * time.Second + joiner := retryJoiner{ discover: &discover.Discover{}, errCh: c.retryJoinErrCh, diff --git a/command/agent/config.go b/command/agent/config.go index 1bc21bb2969..07e67b52626 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -1116,6 +1116,9 @@ func (a *ServerConfig) Merge(b *ServerConfig) *ServerConfig { result.EncryptKey = b.EncryptKey } if b.ServerJoin != nil { + // // COMPAT: Remove in 0.10 - ServerJoin is not defined by default on an + // agent config, this should be eventually moved to DefaultConfig + result.ServerJoin = getDefaultServerJoin() result.ServerJoin = result.ServerJoin.Merge(b.ServerJoin) } @@ -1135,6 +1138,12 @@ func (a *ServerConfig) Merge(b *ServerConfig) *ServerConfig { return &result } +func getDefaultServerJoin() *ServerJoin { + return &ServerJoin{ + RetryInterval: time.Duration(30) * time.Second, + } +} + // Merge is used to merge two client configs together func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig { result := *a @@ -1226,7 +1235,10 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig { } if b.ServerJoin != nil { - result.ServerJoin = b.ServerJoin + // // COMPAT: Remove in 0.10 - ServerJoin is not defined by default on an + // agent config, this should be eventually moved to DefaultConfig + result.ServerJoin = getDefaultServerJoin() + result.ServerJoin = result.ServerJoin.Merge(b.ServerJoin) } return &result diff --git a/command/agent/retry_join.go b/command/agent/retry_join.go index c3e9bf4754a..e49412d8c80 100644 --- a/command/agent/retry_join.go +++ b/command/agent/retry_join.go @@ -69,11 +69,8 @@ func (r *retryJoiner) Validate(config *Config) error { if config.Server.RetryMaxAttempts != 0 { return fmt.Errorf("server_join and retry_max cannot both be defined; try defining only server_join") } - if config.Server.RetryInterval != "0" && config.Server.RetryInterval != "" { - // 30s is the default value that is set, ignore if this is the case - if config.Server.RetryInterval != "30s" { - return fmt.Errorf("server_join and retry_interval cannot both be defined; prefer setting the server_join parameter") - } + if config.Server.RetryInterval != "30s" { + return fmt.Errorf("server_join and retry_interval cannot both be defined; prefer setting the server_join parameter") } if len(config.Server.ServerJoin.RetryJoin) != 0 && len(config.Server.ServerJoin.StartJoin) != 0 { diff --git a/command/agent/retry_join_test.go b/command/agent/retry_join_test.go index d5479cfb06a..f1eb7fd3541 100644 --- a/command/agent/retry_join_test.go +++ b/command/agent/retry_join_test.go @@ -339,7 +339,7 @@ func TestRetryJoin_Validate(t *testing.T) { }, StartJoin: []string{}, RetryMaxAttempts: 0, - RetryInterval: "0", + RetryInterval: "30s", RetryJoin: []string{}, }, },