Skip to content

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

Merged
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
alyssawilk:retry
Oct 3, 2019
Merged

router: allowing request-header-based retry checks#8449
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
alyssawilk:retry

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

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

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

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 <alyssar@chromium.org>
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

ProtobufMessage::ValidationVisitor& validation_visitor)
: retriable_headers_(
Http::HeaderUtility::buildHeaderMatcherVector(retry_policy.retriable_headers())),
retriable_request_headers_(optionalHeaderMatcher(retry_policy.retriable_request_headers())),
Copy link
Copy Markdown
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?

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <alyssar@chromium.org>
snowp
snowp previously approved these changes Oct 3, 2019
Copy link
Copy Markdown
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
Copy Markdown
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!

// 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
Copy Markdown
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.


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
Copy Markdown
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 <alyssar@chromium.org>
@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
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
nandu-vinodan pushed a commit to nandu-vinodan/envoy that referenced this pull request Oct 17, 2019
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
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