Skip to content

Commit 3f73002

Browse files
author
code
authored
remove expired runtime flag: envoy.reloadable_features.validate_detailed_override_host_statuses (envoyproxy#30446)
Commit Message: remove expired runtime flag: envoy.reloadable_features.validate_detailed_override_host_statuses Additional Description: Fixes envoyproxy#29103. Signed-off-by: wbpcode <[email protected]>
1 parent 5d9b101 commit 3f73002

File tree

5 files changed

+5
-200
lines changed

5 files changed

+5
-200
lines changed

changelogs/current.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ removed_config_or_runtime:
2626
Removed the deprecated ``envoy.reloadable_features.prohibit_route_refresh_after_response_headers_sent``
2727
runtime flag and legacy code path.
2828
29+
- area: upstream
30+
change: |
31+
Removed the deprecated ``envoy.reloadable_features.validate_detailed_override_host_statuses``
32+
runtime flag and legacy code path.
33+
2934
new_features:
3035

3136
deprecated:

source/common/runtime/runtime_features.cc

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ RUNTIME_GUARD(envoy_reloadable_features_upstream_wait_for_response_headers_befor
8989
RUNTIME_GUARD(envoy_reloadable_features_use_cluster_cache_for_alt_protocols_filter);
9090
RUNTIME_GUARD(envoy_reloadable_features_use_http3_header_normalisation);
9191
RUNTIME_GUARD(envoy_reloadable_features_validate_connect);
92-
RUNTIME_GUARD(envoy_reloadable_features_validate_detailed_override_host_statuses);
9392
RUNTIME_GUARD(envoy_reloadable_features_validate_grpc_header_before_log_grpc_status);
9493
RUNTIME_GUARD(envoy_reloadable_features_validate_upstream_headers);
9594
RUNTIME_GUARD(envoy_restart_features_send_goaway_for_premature_rst_streams);

source/common/upstream/cluster_manager_impl.h

-8
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,6 @@ class ClusterManagerImpl : public ClusterManager,
654654
// * 0b010000: envoy::config::core::v3::HealthStatus::TIMEOUT
655655
// * 0b100000: envoy::config::core::v3::HealthStatus::DEGRADED
656656
//
657-
// If runtime flag `envoy.reloadable_features.validate_detailed_override_host_statuses` is
658-
// disabled, the old coarse health status Host::Health will be used. The specific
659-
// correspondence is shown below:
660-
//
661-
// * 0b001: Host::Health::Unhealthy
662-
// * 0b010: Host::Health::Degraded
663-
// * 0b100: Host::Health::Healthy
664-
//
665657
// If multiple bit fields are set, it is acceptable as long as the status of override host is
666658
// in any of these statuses.
667659
const HostUtility::HostStatusSet override_host_statuses_{};

source/common/upstream/host_utility.cc

-43
Original file line numberDiff line numberDiff line change
@@ -97,38 +97,6 @@ HostUtility::HostStatusSet HostUtility::createOverrideHostStatus(
9797
const envoy::config::cluster::v3::Cluster::CommonLbConfig& common_config) {
9898
HostStatusSet override_host_status;
9999

100-
if (!Runtime::runtimeFeatureEnabled(
101-
"envoy.reloadable_features.validate_detailed_override_host_statuses")) {
102-
// Old code path that should be removed once the runtime flag is removed directly.
103-
// Coarse health status is used here.
104-
105-
if (!common_config.has_override_host_status()) {
106-
// No override host status and 'Healthy' and 'Degraded' will be applied by default.
107-
override_host_status.set(static_cast<size_t>(Host::Health::Healthy));
108-
override_host_status.set(static_cast<size_t>(Host::Health::Degraded));
109-
return override_host_status;
110-
}
111-
112-
for (auto single_status : common_config.override_host_status().statuses()) {
113-
switch (static_cast<envoy::config::core::v3::HealthStatus>(single_status)) {
114-
PANIC_ON_PROTO_ENUM_SENTINEL_VALUES;
115-
case envoy::config::core::v3::HealthStatus::UNKNOWN:
116-
case envoy::config::core::v3::HealthStatus::HEALTHY:
117-
override_host_status.set(static_cast<size_t>(Host::Health::Healthy));
118-
break;
119-
case envoy::config::core::v3::HealthStatus::UNHEALTHY:
120-
case envoy::config::core::v3::HealthStatus::DRAINING:
121-
case envoy::config::core::v3::HealthStatus::TIMEOUT:
122-
override_host_status.set(static_cast<size_t>(Host::Health::Unhealthy));
123-
break;
124-
case envoy::config::core::v3::HealthStatus::DEGRADED:
125-
override_host_status.set(static_cast<size_t>(Host::Health::Degraded));
126-
break;
127-
}
128-
}
129-
return override_host_status;
130-
}
131-
132100
if (!common_config.has_override_host_status()) {
133101
// No override host status and [UNKNOWN, HEALTHY, DEGRADED] will be applied by default.
134102
override_host_status.set(static_cast<uint32_t>(envoy::config::core::v3::HealthStatus::UNKNOWN));
@@ -179,17 +147,6 @@ HostConstSharedPtr HostUtility::selectOverrideHost(const HostMap* host_map, Host
179147
HostConstSharedPtr host = host_iter->second;
180148
ASSERT(host != nullptr);
181149

182-
if (!Runtime::runtimeFeatureEnabled(
183-
"envoy.reloadable_features.validate_detailed_override_host_statuses")) {
184-
// Old code path that should be removed once the runtime flag is removed directly.
185-
// Coarse health status is used here.
186-
187-
if (status[static_cast<size_t>(host->coarseHealth())]) {
188-
return host;
189-
}
190-
return nullptr;
191-
}
192-
193150
if (status[static_cast<uint32_t>(host->healthStatus())]) {
194151
return host;
195152
}

test/common/upstream/host_utility_test.cc

-148
Original file line numberDiff line numberDiff line change
@@ -225,154 +225,6 @@ TEST(HostUtilityTest, SelectOverrideHostTest) {
225225
}
226226
}
227227

228-
TEST(HostUtilityTest, CreateOverrideHostStatusWithRuntimeFlagFlase) {
229-
TestScopedRuntime scoped_runtime;
230-
scoped_runtime.mergeValues(
231-
{{"envoy.reloadable_features.validate_detailed_override_host_statuses", "false"}});
232-
233-
// Deprecated status that will be removed after runtime flag is removed.
234-
static constexpr HostUtility::HostStatusSet UnhealthyStatus =
235-
1u << static_cast<size_t>(Host::Health::Unhealthy);
236-
static constexpr HostUtility::HostStatusSet DegradedStatus =
237-
1u << static_cast<size_t>(Host::Health::Degraded);
238-
static constexpr HostUtility::HostStatusSet HealthyStatus =
239-
1u << static_cast<size_t>(Host::Health::Healthy);
240-
241-
{
242-
envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config;
243-
lb_config.mutable_override_host_status()->add_statuses(
244-
::envoy::config::core::v3::HealthStatus::UNKNOWN);
245-
lb_config.mutable_override_host_status()->add_statuses(
246-
::envoy::config::core::v3::HealthStatus::HEALTHY);
247-
EXPECT_EQ(HostUtility::createOverrideHostStatus(lb_config), HealthyStatus);
248-
}
249-
{
250-
envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config;
251-
lb_config.mutable_override_host_status()->add_statuses(
252-
::envoy::config::core::v3::HealthStatus::UNHEALTHY);
253-
lb_config.mutable_override_host_status()->add_statuses(
254-
::envoy::config::core::v3::HealthStatus::DRAINING);
255-
lb_config.mutable_override_host_status()->add_statuses(
256-
::envoy::config::core::v3::HealthStatus::TIMEOUT);
257-
258-
EXPECT_EQ(HostUtility::createOverrideHostStatus(lb_config), UnhealthyStatus);
259-
}
260-
{
261-
envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config;
262-
lb_config.mutable_override_host_status()->add_statuses(
263-
::envoy::config::core::v3::HealthStatus::DEGRADED);
264-
EXPECT_EQ(HostUtility::createOverrideHostStatus(lb_config), DegradedStatus);
265-
}
266-
{
267-
envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config;
268-
EXPECT_EQ(HostUtility::createOverrideHostStatus(lb_config), 0b110u);
269-
}
270-
{
271-
envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config;
272-
lb_config.mutable_override_host_status()->add_statuses(
273-
::envoy::config::core::v3::HealthStatus::UNHEALTHY);
274-
lb_config.mutable_override_host_status()->add_statuses(
275-
::envoy::config::core::v3::HealthStatus::DRAINING);
276-
lb_config.mutable_override_host_status()->add_statuses(
277-
::envoy::config::core::v3::HealthStatus::TIMEOUT);
278-
lb_config.mutable_override_host_status()->add_statuses(
279-
::envoy::config::core::v3::HealthStatus::UNKNOWN);
280-
lb_config.mutable_override_host_status()->add_statuses(
281-
::envoy::config::core::v3::HealthStatus::HEALTHY);
282-
283-
EXPECT_EQ(HostUtility::createOverrideHostStatus(lb_config), 0b101u);
284-
}
285-
286-
{
287-
envoy::config::cluster::v3::Cluster::CommonLbConfig lb_config;
288-
lb_config.mutable_override_host_status()->add_statuses(
289-
::envoy::config::core::v3::HealthStatus::UNHEALTHY);
290-
lb_config.mutable_override_host_status()->add_statuses(
291-
::envoy::config::core::v3::HealthStatus::DRAINING);
292-
lb_config.mutable_override_host_status()->add_statuses(
293-
::envoy::config::core::v3::HealthStatus::TIMEOUT);
294-
lb_config.mutable_override_host_status()->add_statuses(
295-
::envoy::config::core::v3::HealthStatus::UNKNOWN);
296-
lb_config.mutable_override_host_status()->add_statuses(
297-
::envoy::config::core::v3::HealthStatus::HEALTHY);
298-
lb_config.mutable_override_host_status()->add_statuses(
299-
::envoy::config::core::v3::HealthStatus::DEGRADED);
300-
EXPECT_EQ(HostUtility::createOverrideHostStatus(lb_config), 0b111u);
301-
}
302-
}
303-
304-
TEST(HostUtilityTest, SelectOverrideHostTestRuntimeFlagFlase) {
305-
TestScopedRuntime scoped_runtime;
306-
scoped_runtime.mergeValues(
307-
{{"envoy.reloadable_features.validate_detailed_override_host_statuses", "false"}});
308-
309-
// Deprecated status that will be removed after runtime flag is removed.
310-
static constexpr HostUtility::HostStatusSet UnhealthyStatus =
311-
1u << static_cast<size_t>(Host::Health::Unhealthy);
312-
static constexpr HostUtility::HostStatusSet DegradedStatus =
313-
1u << static_cast<size_t>(Host::Health::Degraded);
314-
static constexpr HostUtility::HostStatusSet HealthyStatus =
315-
1u << static_cast<size_t>(Host::Health::Healthy);
316-
317-
NiceMock<Upstream::MockLoadBalancerContext> context;
318-
319-
const HostUtility::HostStatusSet all_health_statuses =
320-
UnhealthyStatus | DegradedStatus | HealthyStatus;
321-
322-
{
323-
// No valid host map.
324-
EXPECT_EQ(nullptr, HostUtility::selectOverrideHost(nullptr, all_health_statuses, &context));
325-
}
326-
{
327-
// No valid load balancer context.
328-
auto host_map = std::make_shared<HostMap>();
329-
EXPECT_EQ(nullptr,
330-
HostUtility::selectOverrideHost(host_map.get(), all_health_statuses, nullptr));
331-
}
332-
{
333-
// No valid expected host.
334-
EXPECT_CALL(context, overrideHostToSelect()).WillOnce(Return(absl::nullopt));
335-
auto host_map = std::make_shared<HostMap>();
336-
EXPECT_EQ(nullptr,
337-
HostUtility::selectOverrideHost(host_map.get(), all_health_statuses, &context));
338-
}
339-
{
340-
// The host map does not contain the expected host.
341-
LoadBalancerContext::OverrideHost override_host{"1.2.3.4"};
342-
EXPECT_CALL(context, overrideHostToSelect())
343-
.WillOnce(Return(absl::make_optional(override_host)));
344-
auto host_map = std::make_shared<HostMap>();
345-
EXPECT_EQ(nullptr, HostUtility::selectOverrideHost(host_map.get(), HealthyStatus, &context));
346-
}
347-
{
348-
// The status of host is not as expected.
349-
auto mock_host = std::make_shared<NiceMock<MockHost>>();
350-
EXPECT_CALL(*mock_host, coarseHealth()).WillOnce(Return(Host::Health::Unhealthy));
351-
352-
LoadBalancerContext::OverrideHost override_host{"1.2.3.4"};
353-
EXPECT_CALL(context, overrideHostToSelect())
354-
.WillOnce(Return(absl::make_optional(override_host)));
355-
356-
auto host_map = std::make_shared<HostMap>();
357-
host_map->insert({"1.2.3.4", mock_host});
358-
EXPECT_EQ(nullptr, HostUtility::selectOverrideHost(host_map.get(), HealthyStatus, &context));
359-
}
360-
{
361-
// Get expected host.
362-
auto mock_host = std::make_shared<NiceMock<MockHost>>();
363-
EXPECT_CALL(*mock_host, coarseHealth()).WillOnce(Return(Host::Health::Degraded));
364-
365-
LoadBalancerContext::OverrideHost override_host{"1.2.3.4"};
366-
EXPECT_CALL(context, overrideHostToSelect())
367-
.WillOnce(Return(absl::make_optional(override_host)));
368-
369-
auto host_map = std::make_shared<HostMap>();
370-
host_map->insert({"1.2.3.4", mock_host});
371-
EXPECT_EQ(mock_host, HostUtility::selectOverrideHost(host_map.get(),
372-
HealthyStatus | DegradedStatus, &context));
373-
}
374-
}
375-
376228
} // namespace
377229
} // namespace Upstream
378230
} // namespace Envoy

0 commit comments

Comments
 (0)