Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion api/envoy/config/core/v3/health_check.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum HealthStatus {
DEGRADED = 5;
}

// [#next-free-field: 24]
// [#next-free-field: 25]
message HealthCheck {
option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.HealthCheck";

Expand Down Expand Up @@ -284,6 +284,21 @@ message HealthCheck {
// The default value for "no traffic interval" is 60 seconds.
google.protobuf.Duration no_traffic_interval = 12 [(validate.rules).duration = {gt {}}];

// The "no traffic healthy interval" is a special health check interval that
// is used for hosts that are currently passing active health checking
// (including new hosts) when the cluster has received no traffic.
//
// This is useful for when we want to send frequent health checks with
// `no_traffic_interval` but then revert to lower frequency `no_traffic_healthy_interval` once
// a host in the cluster is marked as healthy.
//
// Once a cluster has been used for traffic routing, Envoy will shift back to using the
// standard health check interval that is defined.
//
// If no_traffic_healthy_interval is not set, it will default to the
// no traffic interval and send that interval regardless of health state.
google.protobuf.Duration no_traffic_healthy_interval = 24 [(validate.rules).duration = {gt {}}];

// The "unhealthy interval" is a health check interval that is used for hosts that are marked as
// unhealthy. As soon as the host is marked as healthy, Envoy will shift back to using the
// standard health check interval that is defined.
Expand Down
17 changes: 16 additions & 1 deletion api/envoy/config/core/v4alpha/health_check.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Removed Config or Runtime
New Features
------------
* grpc: implemented header value syntax support when defining :ref:`initial metadata <envoy_v3_api_field_config.core.v3.GrpcService.initial_metadata>` for gRPC-based `ext_authz` :ref:`HTTP <envoy_v3_api_field_extensions.filters.http.ext_authz.v3.ExtAuthz.grpc_service>` and :ref:`network <envoy_v3_api_field_extensions.filters.network.ext_authz.v3.ExtAuthz.grpc_service>` filters, and :ref:`ratelimit <envoy_v3_api_field_config.ratelimit.v3.RateLimitServiceConfig.grpc_service>` filters.
* health_check: added option to use :ref:`no_traffic_healthy_interval <envoy_v3_api_field_config.core.v3.HealthCheck.no_traffic_healthy_interval>` which allows a different no traffic interval when the host is healthy.

Deprecated
----------
17 changes: 16 additions & 1 deletion generated_api_shadow/envoy/config/core/v3/health_check.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion source/common/upstream/health_checker_base_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ HealthCheckerImplBase::HealthCheckerImplBase(const Cluster& cluster,
reuse_connection_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, reuse_connection, true)),
event_logger_(std::move(event_logger)), interval_(PROTOBUF_GET_MS_REQUIRED(config, interval)),
no_traffic_interval_(PROTOBUF_GET_MS_OR_DEFAULT(config, no_traffic_interval, 60000)),
no_traffic_healthy_interval_(PROTOBUF_GET_MS_OR_DEFAULT(config, no_traffic_healthy_interval,
no_traffic_interval_.count())),
initial_jitter_(PROTOBUF_GET_MS_OR_DEFAULT(config, initial_jitter, 0)),
interval_jitter_(PROTOBUF_GET_MS_OR_DEFAULT(config, interval_jitter, 0)),
interval_jitter_percent_(config.interval_jitter_percent()),
Expand Down Expand Up @@ -123,7 +125,10 @@ std::chrono::milliseconds HealthCheckerImplBase::interval(HealthState state,
break;
}
} else {
base_time_ms = no_traffic_interval_.count();
base_time_ms =
(state == HealthState::Healthy && changed_state != HealthTransition::ChangePending)
? no_traffic_healthy_interval_.count()
: no_traffic_interval_.count();
}
return intervalWithJitter(base_time_ms, interval_jitter_);
}
Expand Down
1 change: 1 addition & 0 deletions source/common/upstream/health_checker_base_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class HealthCheckerImplBase : public HealthChecker,
std::list<HostStatusCb> callbacks_;
const std::chrono::milliseconds interval_;
const std::chrono::milliseconds no_traffic_interval_;
const std::chrono::milliseconds no_traffic_healthy_interval_;
const std::chrono::milliseconds initial_jitter_;
const std::chrono::milliseconds interval_jitter_;
const uint32_t interval_jitter_percent_;
Expand Down
42 changes: 42 additions & 0 deletions test/common/upstream/health_checker_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,25 @@ class HttpHealthCheckerImplTest : public testing::Test, public HttpHealthChecker
addCompletionCallback();
}

void setupNoTrafficHealthyValidationHC() {
const std::string yaml = R"EOF(
timeout: 1s
interval: 1s
no_traffic_interval: 5s
no_traffic_healthy_interval: 10s
interval_jitter: 1s
unhealthy_threshold: 1
healthy_threshold: 1
http_health_check:
service_name_matcher:
prefix: locations
path: /healthcheck
)EOF";

allocHealthChecker(yaml);
addCompletionCallback();
}

void setupNoServiceValidationHCOneUnhealthy() {
const std::string yaml = R"EOF(
timeout: 1s
Expand Down Expand Up @@ -1487,6 +1506,29 @@ TEST_F(HttpHealthCheckerImplTest, SuccessNoTraffic) {
EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health());
}

// First start with an unhealthy cluster that moves to
// no_traffic_healthy_interval.
TEST_F(HttpHealthCheckerImplTest, UnhealthyTransitionNoTrafficHealthy) {
setupNoTrafficHealthyValidationHC();
cluster_->prioritySet().getMockHostSet(0)->hosts_ = {
makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")};
cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagSet(
Host::HealthFlag::FAILED_ACTIVE_HC);
expectSessionCreate();
expectStreamCreate(0);
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _));
health_checker_->start();

// Successful health check should now trigger the no_traffic_healthy_interval 10000ms.
EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed));
EXPECT_CALL(event_logger_, logAddHealthy(_, _, _));
EXPECT_CALL(*test_sessions_[0]->interval_timer_,
enableTimer(std::chrono::milliseconds(10000), _));
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer());
respond(0, "200", false, false, false, false);
EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health());
}

TEST_F(HttpHealthCheckerImplTest, SuccessStartFailedSuccessFirst) {
setupNoServiceValidationHC();
cluster_->prioritySet().getMockHostSet(0)->hosts_ = {
Expand Down