Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new config to make script checks opt-in, updates documentation. #3284

Merged
merged 7 commits into from
Jul 17, 2017

Conversation

slackpad
Copy link
Contributor

Fixes #3087.

@slackpad slackpad requested a review from magiconair July 17, 2017 02:18
Copy link
Contributor

@magiconair magiconair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

}

// Ensure we don't have a check mapping
_, ok := a.state.Checks()["mem"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just check for nil

t.Parallel()

cfg := TestConfig()
cfg.CheckEnableExec = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that the default?

Update: I think this should use the normal default and tests that uses Script tests should set this flag to `true. The test config should use faster timings and in-mem storage but should otherwise have the same behavior than the default runtime config.

agent/config.go Outdated
@@ -625,6 +625,10 @@ type Config struct {
// true, we ignore the leave, and rejoin the cluster on start.
RejoinAfterLeave bool `mapstructure:"rejoin_after_leave"`

// CheckEnableExec controls whether health checks which execute scripts
// are enabled. This includes regular script checks and Docker checks.
CheckEnableExec bool `mapstructure:"check_enable_exec"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other toggles are EnableXXX or DisableXXX. We also have a DisableRemoteExec flag which seems to be related to events but I'm not sure whether it relates to this as well. I suggest EnableScriptChecks (or Check singular) instead unless you have other checks in mind which involve execution of external commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good feedback. I went around on this a bit and sort of went with something that would go with a check in structure if we ever made one but your suggestion fits more with what we have. I'll change this.

@@ -47,6 +47,11 @@ func (c *CheckType) Valid() bool {
return c.IsTTL() || c.IsMonitor() || c.IsHTTP() || c.IsTCP() || c.IsDocker()
}

// IsExec checks if this is a check that execs some kind of script.
func (c *CheckType) IsExec() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/IsExec/IsScript/

@@ -314,6 +314,7 @@ func TestConfig() *Config {
cfg.Datacenter = "dc1"
cfg.Bootstrap = true
cfg.Server = true
cfg.CheckEnableExec = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? can't we just add it to the handful of tests that need it? It is the new default after all. We should see what breaks.

@@ -124,7 +125,8 @@ func defaultServerConfig() *TestServerConfig {
Server: randomPort(),
RPC: randomPort(),
},
ReadyTimeout: 10 * time.Second,
CheckEnableExec: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

The check should be paired with an invocation interval. The shell on which the check
has to be performed is configurable which makes it possible to run containers which
have different shells on the same host. Check output for Docker is limited to
4K. Any output larger than this will be truncated. In Consul 0.9.0 and later, the agent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/4K/4KB/

have different shells on the same host. Check output for Docker is limited to
4K. Any output larger than this will be truncated. In Consul 0.9.0 and later, the agent
must be configured with [`check_enable_exec`](/docs/agent/options.html#_check_enable_exec)
set to `true` in order to enable script checks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any other way to perform (other than a script check) to perform this Docker check? If not, then the last sentence should be to enable Docker health checks.

@@ -81,7 +81,7 @@ All together, these settings yield a
```text
vagrant@n1:~$ consul agent -server -bootstrap-expect=1 \
-data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 \
-config-dir=/etc/consul.d
-check-enable-exec=true -config-dir=/etc/consul.d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required for this example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we add a script check on the following example so it's needed to make that work. Same for the other one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a note about why it's there in-line.

@@ -102,7 +102,7 @@ All together, these settings yield a

```text
vagrant@n2:~$ consul agent -data-dir=/tmp/consul -node=agent-two \
-bind=172.20.20.11 -config-dir=/etc/consul.d
-bind=172.20.20.11 -check-enable-exec=true -config-dir=/etc/consul.d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@magiconair
Copy link
Contributor

LGTM

@slackpad slackpad merged commit 1791d99 into master Jul 17, 2017
@slackpad slackpad deleted the issue-3087 branch July 17, 2017 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants