-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Support multiple health checks per service #591
Conversation
One thing that has also changed is that check registrations will be rejected if the service ID they are associated with does not exist. Shouldn't be a big deal and prevents a weird case where the agent tries to anti-entropy the check in to consul and the fsm rejects it. |
Awesome! This LGTM! I think this also fixes the issue of registering a check after the service is already created too? |
@@ -137,6 +137,7 @@ type RegisterRequest struct { | |||
Address string | |||
Service *NodeService | |||
Check *HealthCheck | |||
Checks HealthChecks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the FSM / State Store handle this, so I think you need to make changes to the RegisterRequest path too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you are right. I added this in 97c5d53, is that what you meant?
LGTM! The only thing I wonder about is a newer client (0.5.0) with an older server (0.4.1) will have issues potentially. I think we document in the upgrade notes that servers must be upgraded first (typically the case with our updates anyways). |
@armon Hm, yeah I think that is the case. We could modify the code path to continue passing the single |
d12b8c1
to
360e1ec
Compare
I've made a few adjustments in here after some experimentation. What we have now should be compatible with older versions of Consul by using We also solve the issues @armon mentioned earlier by batching service sync operations with check syncs where appropriate. Basically, if a check is to be synced, and is associated with a service, we attach the service to the One final change is that we batch all checks which are not associated with any service together to reduce the number of RPC requests required to perform anti-entropy. |
for _, check := range checks { | ||
l.checkStatus[check.CheckID] = syncStatus{inSync: true} | ||
l.logger.Printf( | ||
"[WARN] agent: Check '%s' registration blocked by ACLs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should warn about the service registration (once) not the checks. Since Checks cannot be blocked currently.
1470c86
to
1c64970
Compare
@armon I ended up reverting |
LGTM! Killing it. 👍 |
eef4633
to
46d5dcf
Compare
Support multiple health checks per service
I couldn't get Travis to pass with this PR due to some Makefile changes recently, even after brute-forcing the rebuild button. They do pass locally. I'm going to address this outside of this PR. |
This feature seems not documented on https://www.consul.io/docs/agent/http/agent.html#agent_check_register But request is worked
|
Also bring Dockerfile from releases repo here so the Dockerfiles are together.
Allows multiple health checks to be registered for a single service. Preserves backwards compatibility of configs by using a new
checks
field. Registering multiple health checks can be done in a few different ways:Embedded in service definitions in the
checks
key. If there is only a single check, the check ID will beservice:<service name>
. If there are multiple checks, the service IDs will beservice:<service name>:<n>
.In check configuration files using the
service_id
key. This allows additive configuration of service checks in aconsul.d
-style directory:From the HTTP API by specifying
service_id
in the check definition. This allows adding additional health checks at runtime, and utilizes the new service/check persistence logic to restore the checks on later agent starts:Fixes #230.