mirror of
https://github.com/status-im/consul.git
synced 2025-02-04 09:55:49 +00:00
Changes sense of option to "reap" and uses nil for "not set".
This commit is contained in:
parent
2b257c922e
commit
0b1c346990
@ -643,10 +643,11 @@ func (c *Command) Run(args []string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable child process reaping
|
// Enable child process reaping
|
||||||
if !config.DisableReap && (os.Getpid() == 1) {
|
if (config.Reap != nil && *config.Reap) || (config.Reap == nil && os.Getpid() == 1) {
|
||||||
logger := c.agent.logger
|
logger := c.agent.logger
|
||||||
if !reap.IsSupported() {
|
if !reap.IsSupported() {
|
||||||
logger.Printf("[WARN] Running as PID 1 but child process reaping is not supported on this platform, disabling")
|
c.Ui.Error("Child process reaping is not supported on this platform (set reap=false)")
|
||||||
|
return 1
|
||||||
} else {
|
} else {
|
||||||
logger.Printf("[DEBUG] Automatically reaping child processes")
|
logger.Printf("[DEBUG] Automatically reaping child processes")
|
||||||
|
|
||||||
|
@ -423,11 +423,11 @@ type Config struct {
|
|||||||
SessionTTLMin time.Duration `mapstructure:"-"`
|
SessionTTLMin time.Duration `mapstructure:"-"`
|
||||||
SessionTTLMinRaw string `mapstructure:"session_ttl_min"`
|
SessionTTLMinRaw string `mapstructure:"session_ttl_min"`
|
||||||
|
|
||||||
// DisableReap controls automatic reaping of child processes, useful if
|
// Reap controls automatic reaping of child processes, useful if running
|
||||||
// running as PID 1 in a Docker container. This defaults to false, and
|
// as PID 1 in a Docker container. This defaults to nil which will make
|
||||||
// reaping will be automatically enabled if this is false and Consul's
|
// Consul reap only if it detects it's running as PID 1. If non-nil,
|
||||||
// PID is 1.
|
// then this will be used to decide if reaping is enabled.
|
||||||
DisableReap bool `mapstructure:"disable_reap"`
|
Reap *bool `mapstructure:"reap"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnixSocketPermissions contains information about a unix socket, and
|
// UnixSocketPermissions contains information about a unix socket, and
|
||||||
@ -1146,8 +1146,8 @@ func MergeConfig(a, b *Config) *Config {
|
|||||||
result.RetryJoinWan = append(result.RetryJoinWan, a.RetryJoinWan...)
|
result.RetryJoinWan = append(result.RetryJoinWan, a.RetryJoinWan...)
|
||||||
result.RetryJoinWan = append(result.RetryJoinWan, b.RetryJoinWan...)
|
result.RetryJoinWan = append(result.RetryJoinWan, b.RetryJoinWan...)
|
||||||
|
|
||||||
if b.DisableReap {
|
if b.Reap != nil {
|
||||||
result.DisableReap = true
|
result.Reap = b.Reap
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result
|
return &result
|
||||||
|
@ -778,15 +778,25 @@ func TestDecodeConfig(t *testing.T) {
|
|||||||
t.Fatalf("bad: %s %#v", config.SessionTTLMin.String(), config)
|
t.Fatalf("bad: %s %#v", config.SessionTTLMin.String(), config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableReap
|
// Reap
|
||||||
input = `{"disable_reap": true}`
|
input = `{"reap": true}`
|
||||||
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.DisableReap != true {
|
if config.Reap == nil || *config.Reap != true {
|
||||||
t.Fatalf("bad: reap not disabled: %#v", config)
|
t.Fatalf("bad: reap not enabled: %#v", config)
|
||||||
|
}
|
||||||
|
|
||||||
|
input = `{}`
|
||||||
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Reap != nil {
|
||||||
|
t.Fatalf("bad: reap not tri-stated: %#v", config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1168,7 +1178,6 @@ func TestMergeConfig(t *testing.T) {
|
|||||||
CheckUpdateIntervalRaw: "8m",
|
CheckUpdateIntervalRaw: "8m",
|
||||||
RetryIntervalRaw: "10s",
|
RetryIntervalRaw: "10s",
|
||||||
RetryIntervalWanRaw: "10s",
|
RetryIntervalWanRaw: "10s",
|
||||||
DisableReap: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b := &Config{
|
b := &Config{
|
||||||
@ -1278,8 +1287,9 @@ func TestMergeConfig(t *testing.T) {
|
|||||||
RPC: &net.TCPAddr{},
|
RPC: &net.TCPAddr{},
|
||||||
RPCRaw: "127.0.0.5:1233",
|
RPCRaw: "127.0.0.5:1233",
|
||||||
},
|
},
|
||||||
DisableReap: true,
|
Reap: new(bool),
|
||||||
}
|
}
|
||||||
|
*b.Reap = true
|
||||||
|
|
||||||
c := MergeConfig(a, b)
|
c := MergeConfig(a, b)
|
||||||
|
|
||||||
|
@ -407,10 +407,6 @@ definitions support being updated during a reload.
|
|||||||
`disable_anonymous_signature`</a> Disables providing an anonymous signature for de-duplication
|
`disable_anonymous_signature`</a> Disables providing an anonymous signature for de-duplication
|
||||||
with the update check. See [`disable_update_check`](#disable_update_check).
|
with the update check. See [`disable_update_check`](#disable_update_check).
|
||||||
|
|
||||||
* <a name="disable_reap"></a><a href="#disable_reap">
|
|
||||||
`disable_reap`</a> will prevent Consul from automatically reaping child processes if it
|
|
||||||
detects it is running as PID 1, such as in a Docker container.
|
|
||||||
|
|
||||||
* <a name="disable_remote_exec"></a><a href="#disable_remote_exec">`disable_remote_exec`</a>
|
* <a name="disable_remote_exec"></a><a href="#disable_remote_exec">`disable_remote_exec`</a>
|
||||||
Disables support for remote execution. When set to true, the agent will ignore any incoming
|
Disables support for remote execution. When set to true, the agent will ignore any incoming
|
||||||
remote exec requests.
|
remote exec requests.
|
||||||
@ -508,6 +504,11 @@ definitions support being updated during a reload.
|
|||||||
* <a name="protocol"></a><a href="#protocol">`protocol`</a> Equivalent to the
|
* <a name="protocol"></a><a href="#protocol">`protocol`</a> Equivalent to the
|
||||||
[`-protocol` command-line flag](#_protocol).
|
[`-protocol` command-line flag](#_protocol).
|
||||||
|
|
||||||
|
* <a name="reap"></a><a href="#reap">`reap`</a> controls Consul's automatic reaping of child processes, which
|
||||||
|
is useful if Consul is running as PID 1 in a Docker container. If this isn't specified, then Consul will
|
||||||
|
automatically reap child processes if it detects it is running as PID 1. If this is specified, then it
|
||||||
|
controls reaping regardless of Consul's PID.
|
||||||
|
|
||||||
* <a name="recursor"></a><a href="#recursor">`recursor`</a> Provides a single recursor address.
|
* <a name="recursor"></a><a href="#recursor">`recursor`</a> Provides a single recursor address.
|
||||||
This has been deprecated, and the value is appended to the [`recursors`](#recursors) list for
|
This has been deprecated, and the value is appended to the [`recursors`](#recursors) list for
|
||||||
backwards compatibility.
|
backwards compatibility.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user