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

(fix) Header propagation rule passthrough #6690

Merged
merged 6 commits into from
Feb 5, 2025
Merged

Conversation

BrynCooke
Copy link
Contributor

@BrynCooke BrynCooke commented Jan 29, 2025

Header propagation contains logic to prevent headers from being propagated more than once. This was broken in #6281 which always considered a header propagated regardless if a rule actually matched.

This PR alters the logic so that only when a header is populated then the header is marked as fixed.

The following will now work again:

headers:
  all:
    request:
      - propagate:
          named: a
          rename: b
      - propagate:
          named: b

Note that defaulting a head WILL populate a header, so make sure to include your defaults last in your propagation rules.

headers:
  all:
    request:
      - propagate:
          named: a
          rename: b
          default: defaulted # This will prevent any further rule evaluation for header `b`
      - propagate:
          named: b

Instead make sure that your headers are defaulted last:

headers:
  all:
    request:
      - propagate:
          named: a
          rename: b
      - propagate:
          named: b
          default: defaulted # OK

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@BrynCooke BrynCooke requested review from a team as code owners January 29, 2025 17:04
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Jan 29, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: af85560a491445f7fd6c9c07

This comment has been minimized.

@BrynCooke BrynCooke force-pushed the bryn/header_propagation_or branch from 346acd8 to cf2d82f Compare January 29, 2025 17:09
@BrynCooke BrynCooke requested a review from a team as a code owner January 29, 2025 17:09
@BrynCooke BrynCooke changed the title (fix) Header propagation OR (fix) Header propagation passthrough Jan 29, 2025
Header propagation contains logic to prevent headers from being propagated more than once.
 This was being applied regardless of if a rule matched, thus preventing a first matching rule wins situation.

 This PR alters the logic so that only when a header is populated then the header is marked as fixed.

 Note that defaulting a head WILL populate a header, so make sure to include your defaults last in your propagation rules.
@BrynCooke BrynCooke force-pushed the bryn/header_propagation_or branch from cf2d82f to 4117539 Compare January 29, 2025 17:15
@BrynCooke BrynCooke added the backport-1.x Backport this PR to 1.x label Jan 29, 2025
@BrynCooke BrynCooke changed the title (fix) Header propagation passthrough (fix) Header propagation rule passthrough Jan 29, 2025
Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

subtle... should we also clarify in the docs that you should put items with default last?

@BrynCooke
Copy link
Contributor Author

subtle... should we also clarify in the docs that you should put items with default last?
Good point I'll add it.

@BrynCooke
Copy link
Contributor Author

Docs updated: c7c0969

This required improving the test harness to allow env to be passed into the closure.
@BrynCooke
Copy link
Contributor Author

Tests needed refactoring: 7b129df. Code is cleaner now.

@BrynCooke
Copy link
Contributor Author

@mergify queue

Copy link
Contributor

mergify bot commented Jan 30, 2025

queue

🛑 The pull request has been removed from the queue default

The merge conditions cannot be satisfied due to failing checks.

You can take a look at Queue: Embarked in merge queue check runs for more details.

In case of a failure due to a flaky test, you should first retrigger the CI.
Then, re-embark the pull request into the merge queue by posting the comment
@mergifyio refresh on the pull request.

Copy link
Contributor

mergify bot commented Jan 30, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@BrynCooke BrynCooke requested a review from shorgi January 31, 2025 10:24
@BrynCooke
Copy link
Contributor Author

@shorgi I've made some docs changes so it'd be great if you could take a pass.

@router-perf
Copy link

router-perf bot commented Jan 31, 2025

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

@abernix abernix merged commit ea7f255 into dev Feb 5, 2025
16 checks passed
@abernix abernix deleted the bryn/header_propagation_or branch February 5, 2025 09:46
BrynCooke added a commit that referenced this pull request Feb 5, 2025
Co-authored-by: bryn <bryn@apollographql.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit ea7f255)

# Conflicts:
#	apollo-router/src/plugins/test.rs
goto-bus-stop pushed a commit that referenced this pull request Feb 6, 2025
Co-authored-by: bryn <bryn@apollographql.com>
mergify bot pushed a commit that referenced this pull request Feb 6, 2025
Co-authored-by: bryn <bryn@apollographql.com>
(cherry picked from commit 82c1c1d)
abernix pushed a commit that referenced this pull request Feb 6, 2025
Co-authored-by: bryn <bryn@apollographql.com>
(cherry picked from commit 82c1c1d)
abernix pushed a commit that referenced this pull request Feb 6, 2025
@abernix abernix mentioned this pull request Feb 12, 2025
@lrlna lrlna mentioned this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-1.x Backport this PR to 1.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants