-
Notifications
You must be signed in to change notification settings - Fork 5.5k
config: Implement both versions of onConfigUpdate() everywhere #6879
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
Changes from 4 commits
7c16e12
53bc44b
8be158a
fe65b32
cd22fd2
2e9f5f2
1e4af0d
8aa5f95
94529c2
22d8df6
3c65309
0b0b3ea
b0afa6a
d340ca8
99e78ac
9fa75e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,16 +93,9 @@ void RdsRouteConfigSubscription::onConfigUpdate( | |
| const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
| const std::string& version_info) { | ||
| last_updated_ = time_source_.systemTime(); | ||
|
|
||
| if (resources.empty()) { | ||
| ENVOY_LOG(debug, "Missing RouteConfiguration for {} in onConfigUpdate()", route_config_name_); | ||
| stats_.update_empty_.inc(); | ||
| init_target_.ready(); | ||
| if (!validateUpdateSize(resources.size())) { | ||
| return; | ||
| } | ||
| if (resources.size() != 1) { | ||
| throw EnvoyException(fmt::format("Unexpected RDS resource length: {}", resources.size())); | ||
| } | ||
| auto route_config = MessageUtil::anyConvert<envoy::api::v2::RouteConfiguration>(resources[0]); | ||
| MessageUtil::validate(route_config); | ||
| // TODO(PiotrSikora): Remove this hack once fixed internally. | ||
|
|
@@ -126,12 +119,37 @@ void RdsRouteConfigSubscription::onConfigUpdate( | |
| init_target_.ready(); | ||
| } | ||
|
|
||
| void RdsRouteConfigSubscription::onConfigUpdate( | ||
| const Protobuf::RepeatedPtrField<envoy::api::v2::Resource>& resources, | ||
| const Protobuf::RepeatedPtrField<std::string>&, const std::string&) { | ||
| if (!validateUpdateSize(resources.size())) { | ||
| return; | ||
| } | ||
| Protobuf::RepeatedPtrField<ProtobufWkt::Any> unwrapped_resource; | ||
| *unwrapped_resource.Add() = resources[0].resource(); | ||
| onConfigUpdate(unwrapped_resource, resources[0].version()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, the way it works today is that we only get an In the delta world, we can add resources as they arrive. If we get a removal request, what do we do? Should we be resetting the configuration back to empty? The semantics are a bit different here to SOTW, since with SOTW, we are cool with missing config implying latching, here we have an explicit removal operation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My guess would be to have a removal request reset the configuration, since RDS is one of the types that does have a "name" to it. If the server wanted to update, it should just send an updated version. If it's sending an update explicitly naming the resource as being gone, it makes sense to get rid of that resource. Although, it sounds like when the RDS client gets started, it already has a name in mind, and only that name is valid. So removing the config should be more like shutting down.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you plan to address the code changes for this in this PR?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I ended up logging an error and ignoring the remove request. It seems like it basically doesn't make sense for the server to even try a removal here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think this becomes more interesting with on-demand, where you have the possibility the management server decides to remove a resource and have the client lazily fetch (and maybe recreate it on that path). Since we don't support that, I think it's fine to error out for now, but I'd like to make this a TODO and link to an on-demand tracking issue (do we have one?) so that folks know this is subject to change in terms of behavior.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see, yes. Left a TODO. Looks like there is #2500. |
||
| } | ||
|
|
||
| void RdsRouteConfigSubscription::onConfigUpdateFailed(const EnvoyException*) { | ||
| // We need to allow server startup to continue, even if we have a bad | ||
| // config. | ||
| init_target_.ready(); | ||
| } | ||
|
|
||
| bool RdsRouteConfigSubscription::validateUpdateSize(int num_resources) { | ||
| if (num_resources == 0) { | ||
| ENVOY_LOG(debug, "Missing RouteConfiguration for {} in onConfigUpdate()", route_config_name_); | ||
| stats_.update_empty_.inc(); | ||
| init_target_.ready(); | ||
| return false; | ||
| } | ||
| if (num_resources != 1) { | ||
| throw EnvoyException(fmt::format("Unexpected RDS resource length: {}", num_resources)); | ||
| // (would be a return false here) | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| RdsRouteConfigProviderImpl::RdsRouteConfigProviderImpl( | ||
| RdsRouteConfigSubscriptionSharedPtr&& subscription, | ||
| Server::Configuration::FactoryContext& factory_context) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.