From dd885f4f00d4628f18da2ddcc25babf99a85d08d Mon Sep 17 00:00:00 2001 From: Yan Xue <3491507+crazyxy@users.noreply.github.com> Date: Tue, 30 Jul 2019 15:25:14 -0700 Subject: [PATCH] Revert " admin: add host priority and hostname to cluster response" --- api/envoy/admin/v2alpha/clusters.proto | 6 ---- docs/root/intro/version_history.rst | 4 --- source/server/http/admin.cc | 7 ----- test/server/http/admin_test.cc | 40 ++++---------------------- 4 files changed, 5 insertions(+), 52 deletions(-) diff --git a/api/envoy/admin/v2alpha/clusters.proto b/api/envoy/admin/v2alpha/clusters.proto index 3271b31fdf0c..be7011be0303 100644 --- a/api/envoy/admin/v2alpha/clusters.proto +++ b/api/envoy/admin/v2alpha/clusters.proto @@ -65,12 +65,6 @@ message HostStatus { // The host's weight. If not configured, the value defaults to 1. uint32 weight = 5; - - // The hostname of the host, if applicable. - string hostname = 6; - - // The host's priority. If not configured, the value defaults to 0 (highest priority). - uint32 priority = 7; } // Health status for a host. diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index 3fe16e9f5ea9..8291ba9d384e 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -9,10 +9,6 @@ Version history * access log: added several new variables for exposing information about the downstream TLS connection to :ref:`file access logger` and :ref:`gRPC access logger`. * admin: the administration interface now includes a :ref:`/ready endpoint ` for easier readiness checks. * admin: extend :ref:`/runtime_modify endpoint ` to support parameters within the request body. -* admin: the :ref:`/listener endpoint ` now returns :ref:`listeners.proto` which includes listener names and ports. -* admin: added host priority to :http:get:`/clusters` and :http:get:`/clusters?format=json` end point response -* admin: the :ref:`/clusters endpoint ` now shows hostname - for each host, useful for DNS based clusters. * api: track and report requests issued since last load report. * build: releases are built with Clang and linked with LLD. * dubbo_proxy: support the :ref:`Dubbo proxy filter `. diff --git a/source/server/http/admin.cc b/source/server/http/admin.cc index a5afd3492189..8fb1fde7d74e 100644 --- a/source/server/http/admin.cc +++ b/source/server/http/admin.cc @@ -331,7 +331,6 @@ void AdminImpl::writeClustersAsJson(Buffer::Instance& response) { envoy::admin::v2alpha::HostStatus& host_status = *cluster_status.add_host_statuses(); Network::Utility::addressToProtobufAddress(*host->address(), *host_status.mutable_address()); - host_status.set_hostname(host->hostname()); std::vector sorted_counters; for (const Stats::CounterSharedPtr& counter : host->counters()) { sorted_counters.push_back(counter); @@ -380,8 +379,6 @@ void AdminImpl::writeClustersAsJson(Buffer::Instance& response) { } host_status.set_weight(host->weight()); - - host_status.set_priority(host->priority()); } } } @@ -419,8 +416,6 @@ void AdminImpl::writeClustersAsText(Buffer::Instance& response) { host->address()->asString(), stat.first, stat.second)); } - response.add(fmt::format("{}::{}::hostname::{}\n", cluster.second.get().info()->name(), - host->address()->asString(), host->hostname())); response.add(fmt::format("{}::{}::health_flags::{}\n", cluster.second.get().info()->name(), host->address()->asString(), Upstream::HostUtility::healthFlagsToString(*host))); @@ -437,8 +432,6 @@ void AdminImpl::writeClustersAsText(Buffer::Instance& response) { response.add(fmt::format("{}::{}::success_rate::{}\n", cluster.second.get().info()->name(), host->address()->asString(), host->outlierDetector().successRate())); - response.add(fmt::format("{}::{}::priority::{}\n", cluster.second.get().info()->name(), - host->address()->asString(), host->priority())); } } } diff --git a/test/server/http/admin_test.cc b/test/server/http/admin_test.cc index a51537efe6f8..2d8beddd793d 100644 --- a/test/server/http/admin_test.cc +++ b/test/server/http/admin_test.cc @@ -1051,8 +1051,6 @@ TEST_P(AdminInstanceTest, ClustersJson) { Network::Address::InstanceConstSharedPtr address = Network::Utility::resolveUrl("tcp://1.2.3.4:80"); ON_CALL(*host, address()).WillByDefault(Return(address)); - const std::string hostname = "foo.com"; - ON_CALL(*host, hostname()).WillByDefault(ReturnRef(hostname)); // Add stats in random order and validate that they come in order. Stats::IsolatedStoreImpl store; @@ -1077,7 +1075,6 @@ TEST_P(AdminInstanceTest, ClustersJson) { ON_CALL(host->outlier_detector_, successRate()).WillByDefault(Return(43.2)); ON_CALL(*host, weight()).WillByDefault(Return(5)); - ON_CALL(*host, priority()).WillByDefault(Return(6)); Buffer::OwnedImpl response; Http::HeaderMapImpl header_map; @@ -1139,9 +1136,7 @@ TEST_P(AdminInstanceTest, ClustersJson) { "success_rate": { "value": 43.2 }, - "weight": 5, - "hostname": "foo.com", - "priority": 6 + "weight": 5 } ] } @@ -1156,35 +1151,10 @@ TEST_P(AdminInstanceTest, ClustersJson) { EXPECT_THAT(output_proto, ProtoEq(expected_proto)); // Ensure that the normal text format is used by default. - Buffer::OwnedImpl response2; - EXPECT_EQ(Http::Code::OK, getCallback("/clusters", header_map, response2)); - const std::string expected_text = R"EOF(fake_cluster::outlier::success_rate_average::0 -fake_cluster::outlier::success_rate_ejection_threshold::6 -fake_cluster::default_priority::max_connections::1 -fake_cluster::default_priority::max_pending_requests::1024 -fake_cluster::default_priority::max_requests::1024 -fake_cluster::default_priority::max_retries::1 -fake_cluster::high_priority::max_connections::1 -fake_cluster::high_priority::max_pending_requests::1024 -fake_cluster::high_priority::max_requests::1024 -fake_cluster::high_priority::max_retries::1 -fake_cluster::added_via_api::true -fake_cluster::1.2.3.4:80::arest_counter::5 -fake_cluster::1.2.3.4:80::atest_gauge::10 -fake_cluster::1.2.3.4:80::rest_counter::10 -fake_cluster::1.2.3.4:80::test_counter::10 -fake_cluster::1.2.3.4:80::test_gauge::11 -fake_cluster::1.2.3.4:80::hostname::foo.com -fake_cluster::1.2.3.4:80::health_flags::/failed_active_hc/failed_outlier_check/degraded_active_hc/degraded_eds_health/pending_dynamic_removal -fake_cluster::1.2.3.4:80::weight::5 -fake_cluster::1.2.3.4:80::region::test_region -fake_cluster::1.2.3.4:80::zone::test_zone -fake_cluster::1.2.3.4:80::sub_zone::test_sub_zone -fake_cluster::1.2.3.4:80::canary::false -fake_cluster::1.2.3.4:80::success_rate::43.2 -fake_cluster::1.2.3.4:80::priority::6 -)EOF"; - EXPECT_EQ(expected_text, response2.toString()); + EXPECT_EQ(Http::Code::OK, getCallback("/clusters", header_map, response)); + std::string text_output = response.toString(); + envoy::admin::v2alpha::Clusters failed_conversion_proto; + EXPECT_THROW(MessageUtil::loadFromJson(text_output, failed_conversion_proto), EnvoyException); } TEST_P(AdminInstanceTest, GetRequest) {