Skip to content

ext_proc: support HeaderAppendAction in mutation utils#37139

Closed
agrawroh wants to merge 1 commit intoenvoyproxy:mainfrom
agrawroh:ext_proc_ap
Closed

ext_proc: support HeaderAppendAction in mutation utils#37139
agrawroh wants to merge 1 commit intoenvoyproxy:mainfrom
agrawroh:ext_proc_ap

Conversation

@agrawroh
Copy link
Copy Markdown
Member

Description

Previously, ext_proc only supported the deprecated append field in HeaderValueOption for header mutations, ignoring the newer append_action field. This meant users could only choose between replacing a header value or appending to it, without access to more granular controls like ADD_IF_ABSENT or OVERWRITE_IF_EXISTS.

In this PR, we are adding support for all HeaderAppendAction values in ext_proc header mutations. Default behavior would be changed to append when no action is specified. This behavior could be temporarily reverted with runtime guard envoy.reloadable_features.ext_proc_legacy_append. We maintain the backward compatibility with the legacy append field.

The following actions are now supported:

  • APPEND_IF_EXISTS_OR_ADD: Appends to existing headers or adds new ones
  • ADD_IF_ABSENT: Only adds if header doesn't exist
  • OVERWRITE_IF_EXISTS: Only overwrites if header exists
  • OVERWRITE_IF_EXISTS_OR_ADD: Always overwrites or adds

Fixes #36982


Commit Message: ext_proc: support HeaderAppendAction in mutation utils
Additional Description: Add support for HeaderAppendAction in the ext_proc header mutations.
Risk Level: Low
Testing: Added unit tests covering all append_action behaviors and interaction with legacy append
Docs Changes: Added behavior change notice for the default append behavior
Release Note: Added release note about header mutation behavior change

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #37139 was opened by agrawroh.

see: more, trace.

@agrawroh
Copy link
Copy Markdown
Member Author

/assign @tyxia

@yanjunxiang-google
Copy link
Copy Markdown
Contributor

/assign @yanjunxiang-google

@soulxu
Copy link
Copy Markdown
Member

soulxu commented Nov 20, 2024

gentle ping @yanjunxiang-google

/wait-any

@agrawroh
Copy link
Copy Markdown
Member Author

/retest

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
@agrawroh
Copy link
Copy Markdown
Member Author

/retest

@yanjunxiang-google
Copy link
Copy Markdown
Contributor

Haven't had chance to look into this PR yet.

FYI: there is another PR trying this before: #29862.

should_append = PROTOBUF_GET_WRAPPED_OR_DEFAULT(sh, append, false);
check_op = (should_append && header_exists) ? CheckOperation::APPEND : CheckOperation::SET;
} else {
if (sh.has_append()) {
Copy link
Copy Markdown
Contributor

@yanjunxiang-google yanjunxiang-google Dec 13, 2024

Choose a reason for hiding this comment

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

Thanks for working on this issue. If we want to support both append and append_action, can we first define the behavior. I have a few questions:

  1. If both append and append_action is left as default, which config to take?
  2. If both append and append_action are set to non-default value, what's the behavior and which config to take? Should we deem it as invalid config? Or just take the one with higher preference? Which one is preferred?
  3. If one is default and the other is set, this is an easy case. I think we are ignoring the default configuration, and take the one with non-default setting.
  4. The design should be backward compatible.

Let's add comments here to clearly document it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for reviewing this! Let me address your questions in order:

  1. We have implemented a check to prevent users from specifying both append and append_action. Additionally, a behavior change notice is included to inform users that if neither option is explicitly set, the default behavior of append_action will apply, which is to append the header instead of replacing it.
  2. Allowing both options to be set simultaneously is not permitted. If users attempt to do so, the system will throw an InvalidArgumentError.
  3. That’s correct! If one option is set and the other remains default, the non-default setting takes precedence. However, we would issue a deprecation warning, as append is being marked as deprecated.
  4. While we aim to maintain compatibility, the design cannot be fully backward compatible. This is because there’s no way to distinguish in the proto whether append was left unspecified or explicitly set to false. As a result, a minor behavior change is necessary. This is also noted as part of the changelog.

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.

Agreed with below:

  1. If both are set to non-default values, throw an error.
  2. If one is default, the other is none-default, taking the none-default value.

However, I have questions in the case both are default:
i) With the existing behavior, which only honor config "append", it will take append = false, and replace the existing headers.
ii) With your proposal, it will take append_action = APPEND_IF_EXISTS_OR_ADD, which will append.

This is not backward-compatible. Needs some more analysis on it's impact.

Another thought is if both are default, can you just take append = false, which will be backward-compatible. Then you will be able to support append-action at same time maintain backward compatibility. If in the future, there is a real need to honor append-action when both are default, you can raise a breaking-change PR then. WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@yanjunxiang-google How should I distinguish that append_action is explicitly set to APPEND_IF_EXISTS_OR_ADD or is not present? There is no has_append_action() for enums.

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.

That's a good question. Let me loop in @adisuissa to see whether he has some ideas on this.

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.

@agrawroh Here are my previous replies and opinion about breaking change and non-breaking change

breaking change (i.e. no has function for enum): #29862 (comment)
non-breaking change idea: #29862 (comment)

I have not looked at this specific code area for a quite a while, but i just want to share them for your reference

should_append = sh.append().value();
check_op = (should_append && header_exists) ? CheckOperation::APPEND : CheckOperation::SET;
} else {
switch (sh.append_action()) {
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.

Instead of doing this inline this function, please add two helper functions to make it easy to read, like parseAppendConfig(), parseAppendActionConfig().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, I can do that. Before I start making changes, are you okay with the proposal here?

@adisuissa
Copy link
Copy Markdown
Contributor

/wait-any

@zuercher
Copy link
Copy Markdown
Member

zuercher commented Jan 7, 2025

/wait-any

@tyxia tyxia removed their assignment Jan 10, 2025
@tyxia
Copy link
Copy Markdown
Member

tyxia commented Jan 10, 2025

The best practice of proto enum is having UNSPECIFIED field as default 0 to distinguish UNSET. This will resolve the difficulties of introducing HeaderAppendAction in this PR.

But I am not sure if it is too late to follow this practice at this stage. I have shared some thoughts before.

cc @wbpcode @yanavlasov

@jmarantz
Copy link
Copy Markdown
Contributor

Assigning to Tianyu for now though it might not be reviewable yet.

/wait

@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale stalebot believes this issue/PR has not been touched recently label Feb 12, 2025
@github-actions
Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

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

Labels

stale stalebot believes this issue/PR has not been touched recently waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext_proc does not honour HeaderAppendAction

7 participants