Skip to content

Update fault injection to use a single x-bp-fault header.#690

Merged
HiramSilvey merged 7 commits intoreddit:masterfrom
HiramSilvey:multi-services
Mar 12, 2025
Merged

Update fault injection to use a single x-bp-fault header.#690
HiramSilvey merged 7 commits intoreddit:masterfrom
HiramSilvey:multi-services

Conversation

@HiramSilvey
Copy link
Copy Markdown
Contributor

@HiramSilvey HiramSilvey commented Feb 26, 2025

💸 TL;DR

This PR consolidates all of the fault injection headers into one. This is necessary to allow multiple fault injection configurations on a single request.

📜 Details

DM me for the doc.

Note that this PR removes support for the original x-bp-fault- headers. My understanding is that this is OK since this is a new unused feature. If backwards compatibility is required, however, let me know and I can update this to ensure the previous headers are still read as backups.

🧪 Testing Steps / Validation

This was tested solely through comprehensive unit testing.

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@HiramSilvey HiramSilvey changed the title Move to a new single x-bp-fault header. Update fault injection to use a single x-bp-fault header. Feb 27, 2025
Clean up nested if statements.

Update field defaults.

Remove unused field.

Update LookupValues.

Fix comment.

Update thrift and http middlewares.

Add clarifying comment.
@HiramSilvey HiramSilvey marked this pull request as ready for review March 6, 2025 21:22
@HiramSilvey HiramSilvey requested a review from a team as a code owner March 6, 2025 21:22
@HiramSilvey HiramSilvey requested review from fishy, mathyourlife-reddit and pacejackson and removed request for a team March 6, 2025 21:22
Copy link
Copy Markdown
Contributor

@pacejackson pacejackson left a comment

Choose a reason for hiding this comment

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

headerbp only forwards a single value so I'm not sure that this will work?

@HiramSilvey
Copy link
Copy Markdown
Contributor Author

headerbp only forwards a single value so I'm not sure that this will work?

That's fine if the HTTP headers are combined as per RFC 9110. Follow-up question: If headerbp sees multiple values for 1 header which aren't combined into a single line yet, can it support joining them before it forwards?

@HiramSilvey HiramSilvey requested a review from pacejackson March 6, 2025 21:33
@pacejackson
Copy link
Copy Markdown
Contributor

That's fine if the HTTP headers are combined as per RFC 9110.

headerbp isn't just concerned with HTTP, it also has to care about thrift and gRPC, thrift in particular just has a single value per header.

If headerbp sees multiple values for 1 header which aren't combined into a single line yet, can it support joining them before it forwards?

It currently doesn't even support this, it only accepts a single value for each header.

There are solutions for this, but one major concern with headerbp in general is request size and supporting potentially an unbounded list is another vector through which this could be used to blow up request sizes or cause issues with headers being chopped off because the size is too big.

@HiramSilvey
Copy link
Copy Markdown
Contributor Author

That's fine if the HTTP headers are combined as per RFC 9110.

headerbp isn't just concerned with HTTP, it also has to care about thrift and gRPC, thrift in particular just has a single value per header.

If headerbp sees multiple values for 1 header which aren't combined into a single line yet, can it support joining them before it forwards?

It currently doesn't even support this, it only accepts a single value for each header.

There are solutions for this, but one major concern with headerbp in general is request size and supporting potentially an unbounded list is another vector through which this could be used to blow up request sizes or cause issues with headers being chopped off because the size is too big.

Followed up offline. headerbp only forwarding a single header is perfectly acceptable as the code that populates x-bp-fault can ensure it's only a single value. Size issues are a valid concern and a limit may need to be defined and enforced either in headerbp or in the code that populates x-bp-fault.

@pacejackson
Copy link
Copy Markdown
Contributor

Note that this PR removes support for the original x-bp-fault- headers. My understanding is that this is OK since this is a new unused feature. If backwards compatibility is required, however, let me know and I can update this to ensure the previous headers are still read as backups.

I think that should be fine, I don't think anyone actively used these headers yet?

Comment thread internal/faults/headers.go Outdated
Comment thread internal/faults/headers_test.go Outdated
Comment thread internal/faults/headers_test.go Outdated
Comment thread internal/faults/headers_test.go Outdated
Comment thread internal/faults/faults.go
@HiramSilvey
Copy link
Copy Markdown
Contributor Author

Note that this PR removes support for the original x-bp-fault- headers. My understanding is that this is OK since this is a new unused feature. If backwards compatibility is required, however, let me know and I can update this to ensure the previous headers are still read as backups.

I think that should be fine, I don't think anyone actively used these headers yet?

Internally that is correct.

Comment thread internal/faults/headers.go Outdated
Comment thread thriftbp/faults.go Outdated
Comment thread internal/faults/headers.go Outdated
Comment thread internal/faults/errors.go Outdated
Comment thread internal/faults/errors.go Outdated
Comment thread internal/faults/headers.go Outdated
Comment thread internal/faults/headers.go Outdated
@HiramSilvey HiramSilvey requested a review from pacejackson March 12, 2025 20:35
@HiramSilvey HiramSilvey merged commit 2e4c653 into reddit:master Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants