-
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
changing xDS APIs to take abs::Satus #29439
Conversation
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
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.
Thanks for cleaning up the exceptions usage!
Overall LGTM, left a few small nits.
@@ -51,7 +51,7 @@ class RouteConfigProvider { | |||
/** | |||
* Callback used to notify RouteConfigProvider about configuration changes. | |||
*/ | |||
virtual void onConfigUpdate() PURE; | |||
virtual absl::Status onConfigUpdate() 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.
nit: update the doc-string to include returned value.
@@ -215,7 +225,7 @@ void FilterConfigProviderManagerImplBase::applyLastOrDefaultConfig( | |||
bool last_config_valid = false; | |||
if (subscription->lastConfig()) { | |||
TRY_ASSERT_MAIN_THREAD { | |||
provider.validateTypeUrl(subscription->lastTypeUrl()); | |||
THROW_IF_NOT_OK(provider.validateTypeUrl(subscription->lastTypeUrl())) |
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.
OOC why doesn't the validateMessage()
in the line below needs the same THROW_IF_NOT_OK wrapper?
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.
Looking further in this PR, I guess this is going to be a future change.
auto status = provider.onConfigUpdate(*subscription->lastConfig(), | ||
subscription->lastVersionInfo(), nullptr); | ||
if (!status.ok()) { | ||
throw EnvoyException(std::string(status.message())); | ||
} |
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: can THROW_IF_NOT_OK be used here?
auto status = onConfigUpdate(*default_configuration_, "", nullptr); | ||
if (!status.ok()) { | ||
throw EnvoyException(std::string(status.message())); | ||
} |
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: can THROW_IF_NOT_OK be used here?
auto status = route_config_provider_->onConfigUpdate(); | ||
if (!status.ok()) { | ||
throw EnvoyException(std::string(status.message())); | ||
} |
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: can THROW_IF_NOT_OK be used here?
source/common/router/scoped_rds.cc
Outdated
ConfigSubscriptionCommonBase::onConfigUpdate(); | ||
if (any_applied) { | ||
bool any_applied = false; | ||
absl::Status scopes = addOrUpdateScopes( |
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: rename scopes
to scopes_status
BTW: why not use StatusOr for the return value? just to clarify that any_applied is a return val)?
const std::vector<Envoy::Config::DecodedResourceRef>& resources, Init::Manager& init_manager, | ||
const std::string& version_info) { | ||
bool any_applied = 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.
I think setting to false
is still needed, in case the passed value is true
, but nothing will be applied
source/common/router/vhds.cc
Outdated
auto status = route_config_provider_->onConfigUpdate(); | ||
|
||
if (!status.ok()) { | ||
throw EnvoyException(std::string(status.message())); | ||
} |
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: can THROW_IF_NOT_OK be used here?
envoy/common/exception.h
Outdated
absl::Status status = status_fn; \ | ||
if (!status.ok()) { \ | ||
throw EnvoyException(std::string(status.message())); \ | ||
} |
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.
Consider adding this inside an inner scope, to allow reuse of status
variable name in the same block.
return; | ||
} | ||
|
||
EXPECT_THROW_WITH_MESSAGE( | ||
config_discovery_test.callbacks_->onConfigUpdate(decoded_resources.refvec_, | ||
response.version_info()), | ||
EXPECT_TRUE(config_discovery_test.callbacks_ |
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.
A bit confusing (expect throw, while expecting a successful return value), but I guess this is just to satisfy the linter.
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.
yeah and they're mostly all changing in the follow-up PR.
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 at a high level. I live now in the land of ?
so looking at all of this is pretty painful. 😉
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
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.
Thanks, LGTM!
Left a couple of small const nits, that I think can be done in a future PR.
if (!status_or_applied.status().ok()) { | ||
return status_or_applied.status(); | ||
} | ||
bool any_applied = status_or_applied.value(); |
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 here and places above and below (defer for future PR)
@@ -12,6 +12,14 @@ class EnvoyException : public std::runtime_error { | |||
EnvoyException(const std::string& message) : std::runtime_error(message) {} | |||
}; | |||
|
|||
#define THROW_IF_NOT_OK(status_fn) \ | |||
{ \ | |||
absl::Status status = status_fn; \ |
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 (defer to future PR)
Thanks for the fast turnaround! I'll address the last two nits in the follow-up (removing throws) which I have staged to go |
follow up to #29439 using the new status return code Risk Level: medium Testing: updated tests Docs Changes: n/a Release Notes: n/a envoyproxy/envoy-mobile#176 Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
follow up to envoyproxy#29439 using the new status return code Risk Level: medium Testing: updated tests Docs Changes: n/a Release Notes: n/a envoyproxy/envoy-mobile#176 Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Relates: envoyproxy/envoy#29439 Signed-off-by: Tam Mach <tam.mach@cilium.io>
Unlike many of the throw->status PRs I'm doing xDS in two parts - one is a pure API change, and the follow-up(s) will change the throw over to returning non-Ok stauts. This PR is large enough already I didn't want to do them all at once.
Risk Level: low (but will cause downstream churn, sorry)
Testing: updated tests
Docs Changes: n/a
Release Notes: n/a
envoyproxy/envoy-mobile#176