-
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
router: correct cluster name for ads in routes #2449
router: correct cluster name for ads in routes #2449
Conversation
Signed-off-by: Rama <[email protected]>
source/common/router/rds_impl.cc
Outdated
@@ -75,6 +75,8 @@ RdsRouteConfigProviderImpl::RdsRouteConfigProviderImpl( | |||
// then there is no actual RDS server, and hence no RDS cluster name. | |||
if (rds.has_config_source() && rds.config_source().has_api_config_source()) { | |||
cluster_name_ = rds.config_source().api_config_source().cluster_names()[0]; | |||
} else if (rds.has_config_source() && rds.config_source().has_ads()) { | |||
cluster_name_ = "ADS_CLUSTER"; |
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 tried to get the actual ads cluster name, but looks like it requires a bigger change, like adding ads cluster name while building the ClusterManager
and have to introduce a public method in ClusterManager
which may be overkill for this. Please let me know if you would like me to do it or if there is a simpler way to get the actual ads cluster name.
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.
This is actually pretty tricky for a few reasons:
- We're migrating
envoy.api.v2.ApiConfigSource
(by which ADS) is configured away from using raw cluster names toenvoy.api.v2.GrpcService
. - The ADS
GrpcService
might either use a cluster name (when using Envoy gRPC) or a raw address (when using Google gRPC). There is astat_prefix
in the latter case, which could be used for reporting, but I think this would be confusing semantics here.
I think including cluster name in the admin console is not the way to go long term. What we should do perhaps is include a JSON serialization of rds.config_source().api_config_source()
, or elide it completely.
@junr03 can probably comment further on the original intention of this field and what it might be used for in a post-cluster centric view of gRPC endpoints.
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.
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.
The original purpose of that field was to be able to give a sense to someone operating the admin interface where the RDS config came from, given that the configuration might have come from an LDS response.
In general, #2421 and #2172 show that there is a need to be able to understand what is currently loaded in envoy and where it came from. There are a couple segmented pieces here and there but a comprehensive solution would be great.
As far as this particular change goes, I am ok with it in order to make the output of the /routes admin endpoint correct and more clear for now.
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.
What about just dumping the full rds.config_source.api_config_source()
proto instead of cluster name? It seems this would kill multiple birds with one stone.
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.
Sorry, in my comment above I meant it
to mean your suggestion of dumping rds.config_source().api_config_source()
-- I elided a sentence. However, I would do rds.config_source()
so all three sources are covered by default?
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.
SGTM
Signed-off-by: Rama <[email protected]>
Signed-off-by: Rama <[email protected]>
source/common/router/rds_impl.h
Outdated
@@ -130,7 +130,7 @@ class RdsRouteConfigProviderImpl | |||
Upstream::ClusterManager& cm_; | |||
std::unique_ptr<Envoy::Config::Subscription<envoy::api::v2::RouteConfiguration>> subscription_; | |||
ThreadLocal::SlotPtr tls_; | |||
std::string cluster_name_; | |||
std::string cluster_config_; |
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.
@junr03 i have changed this variable name and method name to mean what we are doing here. let me know if you want to use any better names
@ramaraochavali this LGTM in general. Can you provide an example of the admin endpoint output from curl? I'm mostly wonder if it looks OK or if we should try to do some pretty printing. (I can't recall whether we have that capability or not easily in the proto conversion path). cc @junr03 @htuch |
source/common/router/rds_impl.cc
Outdated
} else { | ||
cluster_name_ = "NOT_USING_CLUSTER"; | ||
cluster_config_ = "NOT_USING_CLUSTER"; | ||
} | ||
} |
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.
This whole if
statement should now just be:
if (rds.has_config_source()) {
cluster_source_ = MessageUtil::getJsonStringFromMessage(rds.config_source());
}
include/envoy/router/rds.h
Outdated
*/ | ||
virtual const std::string& clusterName() const PURE; | ||
virtual const std::string& clusterConfig() const PURE; |
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.
Rename to configSource()
, the cluster aspect is no longer true in general, this could be a non-cluster destination GrpcService
.
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 like the improvement happening here, thanks @ramaraochavali!
Signed-off-by: Rama <[email protected]>
@htuch changed it to |
@mattklein123 Here is the curl output
|
Signed-off-by: Rama <[email protected]>
OK I guess it's no worse than the route table dump output. In the future I wonder if we should pretty print, they I suppose the output can easily be piped through a JSON formatter. |
Signed-off-by: Rama <[email protected]>
@mattklein123 implemented the pretty print support for JSON. Here is the output of
|
@mattklein123 once we agree on the format and code changes I will make changes to the rds_impl test to adhere to this format |
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.
LGTM modulo minor rename.
source/common/router/rds_impl.cc
Outdated
} else { | ||
cluster_name_ = "NOT_USING_CLUSTER"; | ||
config_source_ = "NOT_USING_CLUSTER"; |
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.
Change this to NO_CONFIG_SOURCE
.
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.
Awesome! LGTM other than small comments.
source/common/protobuf/utility.h
Outdated
* @return std::string of formatted JSON object. | ||
*/ | ||
static std::string getJsonStringFromMessage(const Protobuf::Message& message, | ||
const bool pretty_print); |
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.
nit: I would just add pretty_print
to the other definition and default it to false, then just remove this version.
Signed-off-by: Rama <[email protected]>
@mattklein123 @htuch addressed the minor comments. Fixed the test case to validate against the new format. Should be good to go. let me know if any thing else is missing on this. |
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.
very nice, thanks. Tiny nit.
include/envoy/router/rds.h
Outdated
@@ -51,10 +51,10 @@ class RdsRouteConfigProvider : public RouteConfigProvider { | |||
virtual const std::string& routeConfigName() const PURE; | |||
|
|||
/** | |||
* @return const std::string& the name of the cluster the RdsRouteConfigProvider is issuing RDS | |||
* requests to. | |||
* @return const std::string& the configuration of service the RdsRouteConfigProvider is |
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.
tiny nit: "the service"
Signed-off-by: Rama <[email protected]>
@mattklein123 changed. PTAL. |
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.
Sorry, just one more thing..
source/common/protobuf/utility.h
Outdated
*/ | ||
static std::string getJsonStringFromMessage(const Protobuf::Message& message); | ||
static std::string getJsonStringFromMessage(const Protobuf::Message& message, | ||
const bool pretty_print = false); |
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.
Nit: const
on method declarations doesn't do anything (it's OK in the definition though).
source/common/router/rds_impl.cc
Outdated
} else { | ||
cluster_name_ = "NOT_USING_CLUSTER"; | ||
config_source_ = "NO_CONFIG_SOURCE"; |
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.
Should this actually be an empty dictionary {}
on second thoughts; JSON parsing will barf on this won't it?
@htuch made those changes..PTAL. |
@htuch wait a min. looks like some problem. will correct that in a bit. |
Signed-off-by: Rama <[email protected]>
Signed-off-by: Rama <[email protected]>
5a6aadb
to
8b8078d
Compare
@mattklein123 @htuch should be good to go now.PTAL. |
source/common/router/rds_impl.cc
Outdated
} else { | ||
cluster_name_ = "NOT_USING_CLUSTER"; | ||
config_source_ = "{}"; |
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.
Sorry quick question: Is there a test that should have caught this (switching to {}
)? Is it easy to add one?
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.
@mattklein123 there is no test. Will look in to adding it. One more thing, /routes is not working for routes defined statically. It is only iterating through the RdsRouteConfigProviders. https://github.com/envoyproxy/envoy/blob/master/source/common/router/rds_impl.cc#L215. Also it does not store the StaticRouteConfigProviders any where. Is this intentional or a bug? @htuch your thoughts?
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.
and the else block changing config_source = {}, I think we can get rid of the else block completely because if rds is configured, with out config_source, EnvoyException will be thrown. And that is validated with this test https://github.com/envoyproxy/envoy/blob/master/test/common/router/rds_impl_test.cc#L126.
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.
Also it does not store the StaticRouteConfigProviders any where. Is this intentional or a bug?
It just wasn't implemented. In the context of #2421 we will want to revisit this.
and the else block changing config_source = {}, I think we can get rid of the else block completely because if rds is configured, with out config_source, EnvoyException will be thrown.
Yup, great catch. If the code can't be hit just delete it and remove the if statement entirely. Thanks!
Signed-off-by: Rama <[email protected]>
@mattklein123 fixed. removed the comment as well as it is confusing there. PTAL. So |
@ramaraochavali I can give context. yes /routes was implemented only for RDS given that you could get a dump of the static routes by looking at your config file. As Matt mentioned in the issue above. We would like to unify all of these disparate outputs into a more comprehensive solution. |
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.
Thank you! Very nice.
This file is often skipped when updating Envoy SHA in WORKSPACE. Signed-off-by: Piotr Sikora <[email protected]>
Signed-off-by: GitHub Action <[email protected]> Co-authored-by: jpsim <[email protected]> Signed-off-by: JP Simard <[email protected]>
Signed-off-by: GitHub Action <[email protected]> Co-authored-by: jpsim <[email protected]> Signed-off-by: JP Simard <[email protected]>
Signed-off-by: Rama [email protected]
Fix Cluster name for ADS configured RDS in routes
Description:
When admin/routes displays the route table, configured with RDS, it shows the cluster name as
"NOT_USING_CLUSTER"
. Fixed it to display"ADS_CLUSTER"
Risk Level: Low
Testing: Manual
Docs Changes: N/A
Release Notes: N/A