mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
User specifiable kill timeout and operator configurable max
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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...)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user