-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Support Listener
and ClusterLoadAssignment
in property-override
#17497
Support Listener
and ClusterLoadAssignment
in property-override
#17497
Conversation
Add support for patching `Listener` resources via the builtin `property-override` extension. Refactor existing listener patch code in `BasicEnvoyExtender` to simplify addition of resource support.
{ | ||
name: "propertyoverride-outbound-doesnt-apply-to-inbound", | ||
create: func(t testinf.T) *proxycfg.ConfigSnapshot { | ||
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", false, propertyOverrideServiceDefaultsListenerOutboundDoesntApplyToInbound, nil) | ||
}, | ||
}, | ||
{ | ||
name: "propertyoverride-inbound-doesnt-apply-to-outbound", | ||
create: func(t testinf.T) *proxycfg.ConfigSnapshot { | ||
return proxycfg.TestConfigSnapshotDiscoveryChain(t, "default", false, propertyOverrideServiceDefaultsListenerInboundDoesntApplyToOutbound, nil) | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The golden files for these are already in main
😅
"policy": { | ||
"overprovisioningFactor": 123 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outbound patch 1/2
"policy": { | ||
"overprovisioningFactor": 123 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outbound patch 2/2
"policy": { | ||
"overprovisioningFactor": 123 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inbound patch
// PatchClusterLoadAssignment patches a cluster load assignment to include the custom Envoy configuration | ||
// required to integrate with the built in extension template. | ||
PatchClusterLoadAssignment(*RuntimeConfig, *envoy_endpoint_v3.ClusterLoadAssignment) (*envoy_endpoint_v3.ClusterLoadAssignment, bool, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a use case for list-order operations on this resource, so only singular patch op is supported
patchedClusters[nameOrSNI] = patchedCluster | ||
clusterLoadAssignments[nameOrSNI] = patchedClusterLoadAssignment | ||
} else { | ||
patchedClusters[nameOrSNI] = cluster | ||
clusterLoadAssignments[nameOrSNI] = clusterLoadAssignment | ||
} | ||
} | ||
return patchedClusters, resultErr | ||
return clusterLoadAssignments, resultErr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is odd-looking due to similar-shaped code being introduced below code that was edited; the red here is the modified end of patchClusters
above, and the green is the tail end of the new patchClusterLoadAssignments
.
if err != nil { | ||
return listeners, fmt.Errorf("error patching listeners: %w", err) | ||
} | ||
for nameOrSNI, listener := range listeners { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to a single loop over listeners here and changed the filter chain fns below to handle individual listener values; this made introducing common listener patch code simpler. This didn't reduce any runtime iteration in practice, but I think it could aid similar changes in the future.
I also renamed those fns and updated their error messages to make it a bit more obvious what they're doing, since all of them deal exclusively w/ filter chains.
Add support for patching `ClusterLoadAssignment` resources via the builtin `property-override` extension.
1e9c56e
to
a921bd1
Compare
// This allows extensions to operate on a collection of listeners. | ||
// For extensions that implement both PatchListener and PatchListeners, | ||
// PatchListeners is always called first with the entire collection of listeners. | ||
// Then PatchListeners is called for each individual listener. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Then PatchListeners is called for each individual listener. | |
// Then PatchListener is called for each individual listener. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make this change in a follow up PR
Add support for patching
Listener
andClusterLoadAssignment
resources via the builtinproperty-override
extension.Changes for each resource split across two commits for easier review.
I skipped a separate changelog entry since this is an enhancement to a feature already introduced in the next release.
Note that several golden files used by new tests were previously committed with the bulk of
property-override
extension work; they're now in use with this change.Description
BasicEnvoyExtender
to simplify addition of resource supportPR Checklist