User specifiable kill timeout and operator configurable max

This commit is contained in:
Alex Dadgar
2015-12-22 16:10:30 -08:00
parent e0cf0a0928
commit 9f44780f89
21 changed files with 300 additions and 89 deletions

View File

@@ -208,6 +208,13 @@ func (a *Agent) setupClient() error {
if a.config.Client.NetworkSpeed != 0 {
conf.NetworkSpeed = a.config.Client.NetworkSpeed
}
if a.config.Client.MaxKillTimeout != "" {
dur, err := time.ParseDuration(a.config.Client.MaxKillTimeout)
if err != nil {
return fmt.Errorf("Error parsing retry interval: %s", err)
}
conf.MaxKillTimeout = dur
}
// Setup the node
conf.Node = new(structs.Node)

View File

@@ -156,6 +156,9 @@ type ClientConfig struct {
// The network link speed to use if it can not be determined dynamically.
NetworkSpeed int `hcl:"network_speed"`
// MaxKillTimeout allows capping the user-specifiable KillTimeout.
MaxKillTimeout string `hcl:"max_kill_timeout"`
}
// ServerConfig is configuration specific to the server mode
@@ -281,8 +284,9 @@ func DefaultConfig() *Config {
AdvertiseAddrs: &AdvertiseAddrs{},
Atlas: &AtlasConfig{},
Client: &ClientConfig{
Enabled: false,
NetworkSpeed: 100,
Enabled: false,
NetworkSpeed: 100,
MaxKillTimeout: "30s",
},
Server: &ServerConfig{
Enabled: false,
@@ -500,6 +504,9 @@ func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig {
if b.NetworkSpeed != 0 {
result.NetworkSpeed = b.NetworkSpeed
}
if b.MaxKillTimeout != "" {
result.MaxKillTimeout = b.MaxKillTimeout
}
// Add the servers
result.Servers = append(result.Servers, b.Servers...)

View File

@@ -40,7 +40,8 @@ func TestConfig_Merge(t *testing.T) {
Options: map[string]string{
"foo": "bar",
},
NetworkSpeed: 100,
NetworkSpeed: 100,
MaxKillTimeout: "20s",
},
Server: &ServerConfig{
Enabled: false,
@@ -105,7 +106,8 @@ func TestConfig_Merge(t *testing.T) {
"foo": "bar",
"baz": "zip",
},
NetworkSpeed: 100,
NetworkSpeed: 105,
MaxKillTimeout: "50s",
},
Server: &ServerConfig{
Enabled: true,