Skip to content

Commit

Permalink
ignore default values for retry interval
Browse files Browse the repository at this point in the history
add additional validation case
  • Loading branch information
chelseakomlo committed May 29, 2018
1 parent b02a881 commit 9343891
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 9 additions & 2 deletions command/agent/retry_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@ 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" {
return fmt.Errorf("server_join and retry_interval cannot both be defined; prefer setting the server_join parameter")
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 len(config.Server.ServerJoin.RetryJoin) != 0 && len(config.Server.ServerJoin.StartJoin) != 0 {
return fmt.Errorf("server_join and start_join cannot both be defined in the same stanza")
}
}

Expand Down
15 changes: 15 additions & 0 deletions command/agent/retry_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,21 @@ func TestRetryJoin_Validate(t *testing.T) {
isValid: true,
reason: "server deprecated retry_join configuration should be valid",
},
{
config: &Config{
Server: &ServerConfig{
RetryInterval: "30s",
ServerJoin: &ServerJoin{
RetryJoin: []string{"127.0.0.1"},
RetryMaxAttempts: 0,
RetryInterval: time.Duration(20) * time.Second,
StartJoin: []string{},
},
},
},
isValid: true,
reason: "ignore default value for retry interval",
},
}

joiner := retryJoiner{}
Expand Down

0 comments on commit 9343891

Please sign in to comment.