Backport of [NET-4703] Prevent partial application of Envoy extensions into release/1.16.x #18332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #18068 to be assessed for backporting due to the inclusion of the label backport/1.16.
The below text is copied from the body of the original PR.
Ensure that non-required extensions do not change xDS resources before exiting on failure by cloning proto messages prior to applying each extension.
Also avoid unnecessary cloning by moving
CanApply
checks up a layer and making them before application is attempted.Description
Today, it's theoretically possible that a non-required extension could fail partway through making updates. If that extension is not configured as
Required
, we will not short-circuit xDS updates; the error will be logged and swallowed, allowing any other extensions to continue applying before updating xDS resources.By proactively cloning resources that are subject to extensions, s.t. we do not pass any data by reference that is intended to be modified atomically, we can prevent the unintentional partial application of extensions regardless of their
Required
status.Testing & Reproduction steps
CanApply
check to ensure we skip application when extensions should not be appliedClone
method ofIndexedResources
PR Checklist
Overview of commits