Repository navigation
Add property for the initial status of the health check - #1055
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
Consul sets every newly registered check to critical until the first HTTP check runs or, for a TTL check, until the first heartbeat arrives. Tooling that reacts to critical services, such as Consul watches that terminate unhealthy instances, can therefore act on an instance that has only just started. Add spring.cloud.consul.discovery.health-check-initial-status, which sets the Status of the HTTP or TTL check created by ConsulAutoRegistration.createCheck, so it also applies to the check of a separately registered management service. The property is bound to Check.CheckStatus, so IDEs offer the valid values. Consul only accepts passing, warning and critical, so unknown is rejected when the check is created rather than failing the registration request. Document the property in the discovery guide and the configuration properties appendix. Fixes spring-cloudgh-383 Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Consul sets every newly registered check to
criticaluntil the first HTTP check runs or, for a TTL check, until the first heartbeat arrives. Tooling that reacts to critical services, such as the Consul watch in #383 that terminates EC2 instances, can act on an instance that has only just started. Consul lets you set a different initial status, andNewService.Checkalready has theStatusfield, but nothing sets it.Solution
A new discovery property sets the initial status of the registered check:
spring.cloud.consul.discovery.health-check-initial-statuspassing,warningorcritical). Consul sets new checks tocriticalwhen this is not set.ConsulAutoRegistration.createChecksets the status, so it applies to both HTTP and TTL checks, and to the check of a separately registered management service.Check.CheckStatusenum, so the generated configuration metadata gives IDEs the valid values. Consul rejectsunknownas a check status, socreateCheckfails with a message that names the property instead of letting the registration request fail.The discovery docs have a new "Initial Health Check Status" section, and the property is listed in the appendix.
Testing
ConsulAutoRegistrationHealthCheckInitialStatusTests(new) registers a service against Consul and checks that Consul reports the configured status for the check. It uses a TTL check with the heartbeat auto-configuration excluded, so only the initial status can set the check's status and the test is deterministic.ConsulAutoRegistrationInitialStatusCheckTests(new) covers:unknowncreateCheck, three of the new tests fail.serviceregistrytests andConsulDiscoveryPropertiesTestspass against a Consul 1.22 agent (78 tests, 1 skipped).spring-javaformat:validatepass.Fixes #383