Skip to content

Commit

Permalink
further documentation on the edge interval behavior
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Juchem <juchem@gmail.com>
  • Loading branch information
juchem committed Apr 30, 2018
1 parent 90b3e33 commit 7b34697
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion include/envoy/upstream/health_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ namespace Upstream {

enum class HealthState { Unhealthy, Healthy };

enum class HealthTransition { Unchanged, Changed, ChangePending };
enum class HealthTransition {
/**
* Used when the health state of a host hasn't changed.
*/
Unchanged,
/**
* Used when the health state of a host has changed.
*/
Changed,
/**
* Used when the health check result differs from the health state of a host, but a change to the
* latter is delayed due to healthy/unhealthy threshold settings.
*/
ChangePending
};

/**
* Wraps active health checking of an upstream cluster.
Expand Down
9 changes: 9 additions & 0 deletions source/common/upstream/health_checker_base_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ 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::ChangePending
Expand Down

0 comments on commit 7b34697

Please sign in to comment.