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

router: allowing request-header-based retry checks #8449

Merged
merged 4 commits into from
Oct 3, 2019

Conversation

alyssawilk
Copy link
Contributor

Risk Level: Low (new code is config guarded)
Testing: new unit tests
Docs Changes: n/a
Release Notes: yes

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #8449 was opened by alyssawilk.

see: more, trace.

Signed-off-by: Alyssa Wilk <[email protected]>
@@ -931,10 +931,13 @@ message RetryPolicy {
// describes Envoy's back-off algorithm.
RetryBackOff retry_back_off = 8;

// HTTP headers that trigger a retry if present in the response. A retry will be
// HTTP response headers that trigger a retry if present in the response. A retry will be
// triggered if any of the header matches match the upstream response headers.
// The field is only consulted if 'retriable-headers' retry policy is active.
repeated HeaderMatcher retriable_headers = 9;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in retrospect this probably should have been called retriable_response_headers :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htuch shall we handle field rename like this in protoxform when upgrade to next-major-version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should add this capability as an annotation or comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will be adding annotations for this later. For now, you can use [#next-major-version:] or file an explicit GitHub issue and put it in the v3 API label.

@@ -69,6 +78,7 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry
ProtobufMessage::ValidationVisitor& validation_visitor)
: retriable_headers_(
Http::HeaderUtility::buildHeaderMatcherVector(retry_policy.retriable_headers())),
retriable_request_headers_(optionalHeaderMatcher(retry_policy.retriable_request_headers())),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should retriable_headers_ also be optional and use the optionalHeaderMatcher helper? is there a reason for these two to be different?

@@ -260,6 +264,7 @@ class RetryPolicyImpl : public RetryPolicy {
uint32_t host_selection_attempts_{1};
std::vector<uint32_t> retriable_status_codes_;
std::vector<Http::HeaderMatcherSharedPtr> retriable_headers_;
absl::optional<std::vector<Http::HeaderMatcherSharedPtr>> retriable_request_headers_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if having it be optional a memory optimization? iirc making it optional doesn't decrease its size: https://github.com/abseil/abseil-cpp/blob/master/absl/types/optional.h#L91

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, I assumed naively that it saved memory. TIL.

I do worry about the memory impact of feature creep on the retry state, but given it's include not apis we can always switch to pointers (which definitely don't take as much space) at some point in the future, so I'll stick with the types we're already using for now.

Http::TestHeaderMapImpl request_headers{{"x-envoy-retry-on", "5xx"}};
setup(request_headers);
EXPECT_FALSE(state_->enabled());
EXPECT_EQ(RetryStatus::No, state_->shouldRetryReset(overflow_reset_, callback_));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not needed to check this?

Signed-off-by: Alyssa Wilk <[email protected]>
snowp
snowp previously approved these changes Oct 3, 2019
Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alyssawilk alyssawilk added the api-review-required API review required by @envoyproxy/api-shepherds label Oct 3, 2019
mattklein123
mattklein123 previously approved these changes Oct 3, 2019
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!

@@ -931,10 +931,13 @@ message RetryPolicy {
// describes Envoy's back-off algorithm.
RetryBackOff retry_back_off = 8;

// HTTP headers that trigger a retry if present in the response. A retry will be
// HTTP response headers that trigger a retry if present in the response. A retry will be
// triggered if any of the header matches match the upstream response headers.
// The field is only consulted if 'retriable-headers' retry policy is active.
repeated HeaderMatcher retriable_headers = 9;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should add this capability as an annotation or comment.

absl::optional<std::chrono::milliseconds> baseInterval() const override {
return absl::nullopt;
}
absl::optional<std::chrono::milliseconds> maxInterval() const override { return absl::nullopt; }

const std::vector<uint32_t> retriable_status_codes_{};
const std::vector<Http::HeaderMatcherSharedPtr> retriable_headers_{};
const std::vector<Http::HeaderMatcherSharedPtr> retriable_request_headers_{};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: The {} is not needed on any of these.

Signed-off-by: Alyssa Wilk <[email protected]>
@alyssawilk alyssawilk dismissed stale reviews from mattklein123 and snowp via 4a88d4b October 3, 2019 17:37
@mattklein123 mattklein123 merged commit ae74010 into envoyproxy:master Oct 3, 2019
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
nandu-vinodan pushed a commit to nandu-vinodan/envoy that referenced this pull request Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review-required API review required by @envoyproxy/api-shepherds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants