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

Implement support for the Proxy-Upstream-Request-Attempts header #2430

Merged

Conversation

carterkozak
Copy link
Contributor

@carterkozak carterkozak commented Nov 21, 2024

This aims to provide coordination between clients and reverse proxy servers which implement retries, allowing us to avoid multiplying out the total retry count.

When dialogue is configured with more retries than a proxy, we still may retry more than we want, but not DIALOGUE_ATTEMPTS * PROXY_ATTEMPTS. The worst case scenario should be when the proxy retry attempts don't quite reach the configured dialogue retry limit, and another full round of proxy retries must be accumulated. This should be a reaosnable trade-off because it allows the calling client to be configured with a larger value as needed for stability, without multiplying all retries across the board unnecessarily.

Note that when a Dialogue client receives a tcp error/closure, it can make no assumptions about proxy retry attempts, so this only applies to requests which successfully receive a response.

==COMMIT_MSG==
Implement support for the Proxy-Upstream-Request-Attempts header
==COMMIT_MSG==

Note this feature is meant to be used in tandem with #2434 for flexibility

@changelog-app
Copy link

changelog-app bot commented Nov 21, 2024

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Implement support for the Proxy-Upstream-Request-Attempts header

Check the box to generate changelog(s)

  • Generate changelog entry

This aims to provide coordination between clients and reverse
proxy servers which implement retries, allowing us to avoid
multiplying out the total retry count.

When dialogue is configured with more retries than a proxy, we still
may retry more than we want, but not DIALOGUE_ATTEMPTS * PROXY_ATTEMPTS.
The worst case scenario should be when the proxy retry attempts don't quite
reach the configured dialogue retry limit, and another full round of proxy
retries must be accumulated. This should be a reaosnable trade-off because
it allows the calling client to be configured with a larger value as
needed for stability, without multiplying all retries across the board
unnecessarily.

Note that when a Dialogue client receives a tcp error/closure, it
can make no assumptions about proxy retry attempts, so this only
applies to requests which successfully receive a response.
@carterkozak carterkozak force-pushed the ckozak/implement_proxy_retry_attempts_awareness branch from bcf10ba to 1853f05 Compare November 25, 2024 14:51
carterkozak added a commit that referenced this pull request Nov 25, 2024
This feature functions in combination with `Proxy-Upstream-Request-Attempts` (#2430) to allow negotiation for
retries to occur based on proxy configuration, without requiring clients to be updated or reconfigured.
@carterkozak carterkozak changed the title Implement support for the Proxy-Retry-Attempts header Implement support for the Proxy-Upstream-Request-Attempts header Nov 25, 2024
@carterkozak carterkozak marked this pull request as ready for review November 25, 2024 15:31

@Test
void proxyUpstreamRequestAttempts_valid() {
try (Response response = new TestResponse().withHeader(Responses.PROXY_UPSTREAM_REQUEST_ATTEMPTS, "1")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughts on also adding some misc spaces to check that it's trim'd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

mpritham
mpritham previously approved these changes Nov 25, 2024
Copy link
Contributor

@mpritham mpritham left a comment

Choose a reason for hiding this comment

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

LGTM! Removed merge-when-ready in case you wanted to make the nit test change.

@policy-bot policy-bot bot dismissed mpritham’s stale review November 25, 2024 17:33

Invalidated by push of 9b9cf0a

Comment on lines +316 to +321
if (proxyUpstreamRequestAttempts > 1) {
log.info(
"Received a Proxy-Upstream-Request-Attempts response header "
+ "indicating retries have already occurred",
SafeArg.of("proxyUpstreamRequestAttempts", proxyUpstreamRequestAttempts));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an info-level log statement here as well

@carterkozak
Copy link
Contributor Author

Thanks, this needs another +1 since I've pushed again!

@bulldozer-bot bulldozer-bot bot merged commit 0c4c11e into develop Nov 25, 2024
6 checks passed
@bulldozer-bot bulldozer-bot bot deleted the ckozak/implement_proxy_retry_attempts_awareness branch November 25, 2024 18:18
@autorelease3
Copy link

autorelease3 bot commented Nov 25, 2024

Released 4.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants