-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
health check: overriding health threshold for edge intervals #3174
Merged
+304
−36
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d7b288b
health check: overriding health threshold for edge intervals
juchem 5b08ace
fixing implementation to follow HAProxy's behavior
juchem 90b3e33
improving comments formatting in tests
juchem 7b34697
further documentation on the edge interval behavior
juchem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,25 @@ std::chrono::milliseconds HealthCheckerImplBase::interval(HealthState state, | |
// refer to the HealthCheck API documentation for more details. | ||
uint64_t base_time_ms; | ||
if (cluster_.info()->stats().upstream_cx_total_.used()) { | ||
// When healthy/unhealthy threshold is configured the health transition of a host will be | ||
// delayed. In this situation Envoy should use the edge interval settings between health checks. | ||
// | ||
// Example scenario for an unhealthy host with healthy_threshold set to 3: | ||
// - check fails, host is still unhealthy and next check happens after unhealthy_interval; | ||
// - check succeeds, host is still unhealthy and next check happens after healthy_edge_interval; | ||
// - check succeeds, host is still unhealthy and next check happens after healthy_edge_interval; | ||
// - check succeeds, host is now healthy and next check happens after interval; | ||
// - check succeeds, host is still healthy and next check happens after interval. | ||
switch (state) { | ||
case HealthState::Unhealthy: | ||
base_time_ms = changed_state == HealthTransition::Changed ? unhealthy_edge_interval_.count() | ||
: unhealthy_interval_.count(); | ||
base_time_ms = changed_state == HealthTransition::ChangePending | ||
? unhealthy_edge_interval_.count() | ||
: unhealthy_interval_.count(); | ||
break; | ||
default: | ||
base_time_ms = changed_state == HealthTransition::Changed ? healthy_edge_interval_.count() | ||
: interval_.count(); | ||
base_time_ms = changed_state == HealthTransition::ChangePending | ||
? healthy_edge_interval_.count() | ||
: interval_.count(); | ||
break; | ||
} | ||
} else { | ||
|
@@ -189,6 +200,8 @@ void HealthCheckerImplBase::ActiveHealthCheckSession::handleSuccess() { | |
host_->healthFlagClear(Host::HealthFlag::FAILED_ACTIVE_HC); | ||
parent_.incHealthy(); | ||
changed_state = HealthTransition::Changed; | ||
} else { | ||
changed_state = HealthTransition::ChangePending; | ||
} | ||
} | ||
|
||
|
@@ -210,6 +223,8 @@ HealthTransition HealthCheckerImplBase::ActiveHealthCheckSession::setUnhealthy(F | |
host_->healthFlagSet(Host::HealthFlag::FAILED_ACTIVE_HC); | ||
parent_.decHealthy(); | ||
changed_state = HealthTransition::Changed; | ||
} else { | ||
changed_state = HealthTransition::ChangePending; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same reasoning as above |
||
} | ||
} | ||
|
||
|
This file contains 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
Oops, something went wrong.
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.
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 specifically wanted to respect the former semantics of
changed_state
, when it was a boolean.Changed
is only set where beforechanged_state
would be set to true. Given that all places that used to check for truth-ness ofchanged_state
have been changed tochanged_state == HealthTransition::Changed
in a previous PR, truth-ness checks still hold:Where
changed_state
would have been false, it's now eitherChangePending
orUnchanged
. Therefore new state would only affect false-ness checks. Since there are no such checks, the addition of the new state shouldn't be a problem:With the above in mind, the semantics should still hold.