Skip to content
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

Merged
merged 5 commits into from
Sep 7, 2023
Merged

Conversation

alyssawilk
Copy link
Contributor

@alyssawilk alyssawilk commented Sep 5, 2023

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

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #29439 was opened by alyssawilk.

see: more, trace.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Contributor

@adisuissa adisuissa left a 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;
Copy link
Contributor

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()))
Copy link
Contributor

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?

Copy link
Contributor

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.

Comment on lines 240 to 244
auto status = provider.onConfigUpdate(*subscription->lastConfig(),
subscription->lastVersionInfo(), nullptr);
if (!status.ok()) {
throw EnvoyException(std::string(status.message()));
}
Copy link
Contributor

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?

Comment on lines +128 to +131
auto status = onConfigUpdate(*default_configuration_, "", nullptr);
if (!status.ok()) {
throw EnvoyException(std::string(status.message()));
}
Copy link
Contributor

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?

Comment on lines 86 to 89
auto status = route_config_provider_->onConfigUpdate();
if (!status.ok()) {
throw EnvoyException(std::string(status.message()));
}
Copy link
Contributor

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?

ConfigSubscriptionCommonBase::onConfigUpdate();
if (any_applied) {
bool any_applied = false;
absl::Status scopes = addOrUpdateScopes(
Copy link
Contributor

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;
Copy link
Contributor

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

Comment on lines 94 to 98
auto status = route_config_provider_->onConfigUpdate();

if (!status.ok()) {
throw EnvoyException(std::string(status.message()));
}
Copy link
Contributor

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?

Comment on lines 16 to 19
absl::Status status = status_fn; \
if (!status.ok()) { \
throw EnvoyException(std::string(status.message())); \
}
Copy link
Contributor

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_
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Member

@mattklein123 mattklein123 left a 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>
Copy link
Contributor

@adisuissa adisuissa left a 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();
Copy link
Contributor

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; \
Copy link
Contributor

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)

@alyssawilk alyssawilk enabled auto-merge (squash) September 7, 2023 13:30
@alyssawilk
Copy link
Contributor Author

Thanks for the fast turnaround! I'll address the last two nits in the follow-up (removing throws) which I have staged to go

@alyssawilk alyssawilk merged commit e6ee1cf into envoyproxy:main Sep 7, 2023
114 of 115 checks passed
alyssawilk added a commit that referenced this pull request Sep 19, 2023
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>
sayboras added a commit to sayboras/proxy that referenced this pull request Oct 22, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Oct 22, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Oct 22, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Oct 22, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Nov 11, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
alyssawilk added a commit to alyssawilk/envoy that referenced this pull request Nov 30, 2023
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>
sayboras added a commit to sayboras/proxy that referenced this pull request Dec 2, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Dec 6, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Dec 10, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Dec 12, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Dec 27, 2023
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Jan 23, 2024
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Jan 29, 2024
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Jan 29, 2024
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to cilium/proxy that referenced this pull request Jan 29, 2024
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
sayboras added a commit to sayboras/proxy that referenced this pull request Jan 29, 2024
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
github-merge-queue bot pushed a commit to cilium/proxy that referenced this pull request Jan 30, 2024
Relates: envoyproxy/envoy#29439
Signed-off-by: Tam Mach <tam.mach@cilium.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants