perf: name upstream CA SDS secrets after their source object - #10127
zhaohuabing wants to merge 8 commits into
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10127 +/- ##
==========================================
- Coverage 81.42% 81.42% -0.01%
==========================================
Files 266 266
Lines 41300 41305 +5
==========================================
+ Hits 33630 33634 +4
- Misses 7669 7670 +1
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/retest |
1 similar comment
|
/retest |
961fd99 to
8ff0165
Compare
| // once per subscriber. Many destinations validating against one CA is the shape that | ||
| // dominates the control-plane heap, so it compares the bundle carried per destination | ||
| // against a single shared entry in Xds.CACertificates that destinations name. | ||
| func BenchmarkXdsIRDeepCopy(b *testing.B) { |
There was a problem hiding this comment.
We don't need a separate benchmark test for this.
8ff0165 to
268896a
Compare
| - path: /dev/stdout | ||
| caCertificates: | ||
| - certificate: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQWcrZ0F3SUJBZ0lVQWw2VUtJdUttenRlODFjbGx6NVBmZE4ySWxJd0RRWUpLb1pJaHZjTkFRRUwKQlFBd0l6RVFNQTRHQTFVRUF3d0hiWGxqYVdWdWRERVBNQTBHQTFVRUNnd0dhM1ZpWldSaU1CNFhEVEl6TVRBdwpNakExTkRFMU4xb1hEVEkwTVRBd01UQTFOREUxTjFvd0l6RVFNQTRHQTFVRUF3d0hiWGxqYVdWdWRERVBNQTBHCkExVUVDZ3dHYTNWaVpXUmlNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXdTVGMKMXlqOEhXNjJueW5rRmJYbzRWWEt2MmpDMFBNN2RQVmt5ODdGd2VaY1RLTG9XUVZQUUUycDJrTERLNk9Fc3ptTQp5eXIreHhXdHlpdmVyZW1yV3FuS2tOVFloTGZZUGhnUWtjemliN2V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dbef91c32f552ed648325104e44de707cee1a0cae69eaed |
There was a problem hiding this comment.
This PR deduplicates CA bundles by source-object name instead of content digest and also deduplicates the emitted SDS secrets. Compared with digest-based deduplication, it may save less control-plane memory when different objects from different namespaces contain identical CA data. The tradeoff is simpler lookup and registration logic.
|
/retest |
Extract the truncate-and-hash primitives behind sdsClusterNameFromURL into internal/utils/naming so other xDS name builders can reuse them. Bounded hashes only when the name exceeds the budget. sdsClusterNameFromURL keeps hashing unconditionally, because rewriting "/" to "_" already collapses distinct socket addresses, so its readable part cannot carry the identity. Its output is unchanged. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
An upstream CA SDS secret was named after the policy reading it, so N BackendTLSPolicies referencing one ConfigMap produced N secrets holding identical bytes. Name it after the source object instead — "<kind>/<namespace>/<name>", joined by "," for multiple refs in declared order — so one Kubernetes object yields one SDS secret. The name now identifies the content, so the digest envoyproxy#10072 added is redundant: Xds.CACertificates is keyed by name and TLSCACertificate.Digest is gone. The registry also subsumes ResolvedCAMap, and does it better, since it skips re-reading refs across different policies sharing a source rather than only repeats of one policy. Renaming alone collapses nothing: the emit site in addXdsCluster bypassed the name dedupe in addXdsSecret and is guarded only by cluster name, so it re-added the secret once per cluster. It now goes through addXdsSecret. TLSCACertificate.Certificate stays. Downstream validation and the in-process TLS paths — ToTLSConfig for the OIDC discovery client, proxy metrics, and the two applyBackendTLSSetting callers with no gateway IR in scope — read those inline bytes directly. The kind prefix is load-bearing: a Secret and a ConfigMap of the same name in one namespace hold different bytes and would otherwise share a name. caRefNameSegment and the byte loop share one supportedCAKind predicate so a name can never identify a bundle it was not built from. Fixes envoyproxy#10100 Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
TruncateToBytes looped forever on a negative budget: once the string is empty DecodeLastRuneInString returns size 0, so the slice never shrinks and the length test never fails. Bounded reached that whenever the name was over budget and maxBytes was below the 17-byte suffix, hanging the caller's goroutine rather than panicking. Unreachable at the 512-byte budget this PR uses, but these are exported helpers, so clamp the budget and keep the hash when there is no room for a readable head — the hash is what makes the name unique. Also correct the release notes: envoyproxy#10072's still described referencing bundles by a content digest, which this PR removes, and the breaking note omitted that a cluster-scoped ClusterTrustBundle has no namespace segment. Record why sharing cannot lose an SDS config, and why the upstream CA secret must stay content-only now that addXdsSecret dedupes on name without comparing what it already holds. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Clarify CA reference lookup and bundle registration, and skip already registered names without comparing certificate bytes. Remove the helper test file and shorten source-based CA secret names to 128 bytes. Trim explanatory comments and the release note, and remove the superseded release note for envoyproxy#10072. Remove the CA benchmarks introduced by envoyproxy#10072 and their updates in this branch. Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
Signed-off-by: Huabing (Robin) Zhao <huabing@tetrate.io>
b214e9f to
133e3a3
Compare
|
/retest |
Fixes #10100
An upstream CA SDS secret was named after the policy reading it, so several
BackendTLSPoliciesreferencing oneConfigMapeach emitted a secret holding identical bytes. This PR names the secret after the source object instead, so one Kubernetes object yields one SDS secret and the xDS snapshot stops carrying the duplicates.caCertificateRefsentry gives<kind>/<namespace>/<name>, for exampleconfigmap/ns1/ca-cmap.Because the name now identifies the content, the digest added in #10072 is redundant.
Xds.CACertificatesis keyed by name andTLSCACertificate.Digestis gone.This is a breaking change for
EnvoyPatchPoliciesand extension servers matching the old names, and several policies can now share one secret, so a patch against it reaches all of them.