Repository navigation
fix: keep xDS watches whose response has to be withheld #592
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cd14adc
fix: keep xDS watches whose response has to be withheld
chandler-solo c9f6f1d
Merge branch 'main' into chandler/solo-kit-586-but-better
chandler-solo 5c94c49
configurability via SOLOKIT_RETAIN_UNANSWERED_XDS_WATCHES
chandler-solo 54aafe1
Merge remote-tracking branch 'refs/remotes/origin/chandler/solo-kit-5…
chandler-solo f557ad2
observability borrowed from #587
chandler-solo 922b48c
lint
chandler-solo d74a035
EXP_FIX
chandler-solo 9fca4b7
Merge branch 'main' into chandler/solo-kit-586-but-better
chandler-solo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| changelog: | ||
| - type: FIX | ||
| issueLink: https://github.com/solo-io/solo-kit/pull/586 | ||
| resolvesIssue: false | ||
| description: >- | ||
| Keep an xDS watch open when its response has to be withheld. In ADS mode | ||
| the snapshot cache does not answer a request whose resource names do not | ||
| cover the snapshot's resources of that type, which happens while a client | ||
| has not yet subscribed to a resource the snapshot already carries. Both | ||
| call sites treated the withheld response as a completed request, so the | ||
| watch was discarded on a snapshot update and never registered for a new | ||
| request. Because a client only issues a new request after receiving a | ||
| response, nothing re-armed delivery, and it stayed on its previous | ||
| configuration until it reconnected. When enabled, the watch is retained on both | ||
| paths and answered by the first snapshot it can accept. | ||
| Set SOLOKIT_RETAIN_UNANSWERED_XDS_WATCHES to "off" to restore the previous | ||
| behavior on both paths, or "on" to force retention. "default", unset, and | ||
| empty values follow the release default (currently off), which may change | ||
| in a future release; explicit "on" and "off" remain pinned. Other values | ||
| log a warning and use the release default. The setting is read when each | ||
| snapshot cache is created. | ||
| - type: NEW_FEATURE | ||
| issueLink: https://github.com/solo-io/solo-kit/pull/587 | ||
| resolvesIssue: false | ||
| description: >- | ||
| Add the xds/suppressed_responses measure, counting the times the snapshot | ||
| cache intentionally withholds an xDS response, tagged with the resource | ||
| type and a reason. The only reason today is ads_name_mismatch: the | ||
| request's resource names do not cover the snapshot's resources of that | ||
| type. The measure is recorded whether or not watch retention is enabled, | ||
| because nothing else reports that the condition happened -- with retention | ||
| off the watch is silently discarded, and with it on the watch survives but | ||
| still goes unanswered until a compatible snapshot arrives. It is therefore | ||
| the signal for how often this occurs in a running fleet, and the basis for | ||
| deciding the release default of SOLOKIT_RETAIN_UNANSWERED_XDS_WATCHES. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
pkg/api/v1/control-plane/cache/suppressed_responses_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| package cache_test | ||
|
|
||
| import ( | ||
| envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" | ||
| . "github.com/onsi/ginkgo/v2" | ||
| . "github.com/onsi/gomega" | ||
| "github.com/solo-io/solo-kit/pkg/api/v1/control-plane/cache" | ||
| "github.com/solo-io/solo-kit/pkg/api/v1/control-plane/resource" | ||
| "github.com/solo-io/solo-kit/pkg/api/v1/control-plane/types" | ||
| "go.opencensus.io/stats/view" | ||
| ) | ||
|
|
||
| // A withheld response is otherwise invisible. With retention off the watch is | ||
| // silently discarded; with it on the watch survives but still goes unanswered | ||
| // until a compatible snapshot arrives. Neither case logs above debug or moves | ||
| // any other counter, so this measure is the only thing that says how often the | ||
| // condition fires -- which is what makes the retention default decidable from | ||
| // field data rather than from argument. | ||
| var _ = Describe("Suppressed response metric", func() { | ||
|
|
||
| const suppressedNode = "suppressed-response-node" | ||
|
|
||
| // suppressedCount totals the rows of xds/suppressed_responses. The view is | ||
| // process-wide and other specs record into it, so a test reads the delta | ||
| // across the action rather than an absolute. | ||
| suppressedCount := func() int64 { | ||
| rows, err := view.RetrieveData(cache.SuppressedResponsesView.Name) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| var total int64 | ||
| for _, row := range rows { | ||
| if data, ok := row.Data.(*view.CountData); ok { | ||
| total += data.Value | ||
| } | ||
| } | ||
| return total | ||
| } | ||
|
|
||
| // withholdOneResponse asks for "a" while the snapshot also holds "b", which | ||
| // is the ADS name mismatch that makes the cache withhold. | ||
| withholdOneResponse := func(snapshotCache cache.SnapshotCache) func() { | ||
| snapshotCache.SetSnapshot(suppressedNode, &TestSnapshot{ | ||
| Endpoints: cache.NewResources("v1", []cache.Resource{ | ||
| resource.NewEnvoyResource(makeEndpoint("a")), | ||
| resource.NewEnvoyResource(makeEndpoint("b")), | ||
| }), | ||
| }) | ||
| _, cancel := snapshotCache.CreateWatch(cache.Request{ | ||
| TypeUrl: types.EndpointTypeV3, | ||
| ResourceNames: []string{"a"}, | ||
| VersionInfo: "v0", | ||
| Node: &envoy_config_core_v3.Node{Id: suppressedNode}, | ||
| }) | ||
| return cancel | ||
| } | ||
|
|
||
| DescribeTable("counts a withheld response whether or not watches are retained", | ||
| func(retention string) { | ||
| GinkgoT().Setenv(cache.RetainUnansweredXDSWatchesEnv, retention) | ||
| snapshotCache := cache.NewSnapshotCache(cache.CacheSettings{Ads: true, Hash: TestIDHash{}}) | ||
|
|
||
| before := suppressedCount() | ||
| cancel := withholdOneResponse(snapshotCache) | ||
| defer cancel() | ||
|
|
||
| Expect(suppressedCount()).To(BeNumerically(">", before), | ||
| "a withheld response must be counted regardless of the retention setting") | ||
| }, | ||
| Entry("retention on", "on"), | ||
| Entry("retention off", "off"), | ||
| ) | ||
|
|
||
| It("does not count a response that was sent", func() { | ||
| GinkgoT().Setenv(cache.RetainUnansweredXDSWatchesEnv, "on") | ||
| snapshotCache := cache.NewSnapshotCache(cache.CacheSettings{Ads: true, Hash: TestIDHash{}}) | ||
| snapshotCache.SetSnapshot(suppressedNode, &TestSnapshot{ | ||
| Endpoints: cache.NewResources("v1", []cache.Resource{ | ||
| resource.NewEnvoyResource(makeEndpoint("a")), | ||
| }), | ||
| }) | ||
|
|
||
| before := suppressedCount() | ||
| // The request now names every resource in the snapshot, so it is answered. | ||
| _, cancel := snapshotCache.CreateWatch(cache.Request{ | ||
| TypeUrl: types.EndpointTypeV3, | ||
| ResourceNames: []string{"a"}, | ||
| VersionInfo: "v0", | ||
| Node: &envoy_config_core_v3.Node{Id: suppressedNode}, | ||
| }) | ||
| defer cancel() | ||
|
|
||
| Expect(suppressedCount()).To(Equal(before)) | ||
| }) | ||
|
|
||
| It("tags the reason so the cause is distinguishable", func() { | ||
| GinkgoT().Setenv(cache.RetainUnansweredXDSWatchesEnv, "on") | ||
| snapshotCache := cache.NewSnapshotCache(cache.CacheSettings{Ads: true, Hash: TestIDHash{}}) | ||
| cancel := withholdOneResponse(snapshotCache) | ||
| defer cancel() | ||
|
|
||
| rows, err := view.RetrieveData(cache.SuppressedResponsesView.Name) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| var reasons, typeURLs []string | ||
| for _, row := range rows { | ||
| for _, t := range row.Tags { | ||
| switch t.Key.Name() { | ||
| case "reason": | ||
| reasons = append(reasons, t.Value) | ||
| case "type": | ||
| typeURLs = append(typeURLs, t.Value) | ||
| } | ||
| } | ||
| } | ||
| Expect(reasons).To(ContainElement("ads_name_mismatch")) | ||
| Expect(typeURLs).To(ContainElement(types.EndpointTypeV3)) | ||
| }) | ||
| }) |
Oops, something went wrong.
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.
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.
maybe just call this ENV "EXP_FIX", I know it's very generic but if we are doing similar in other area to gate risky fix, we can re-use this. The cons is of course all or nothing. I don't think we need to keep it for long. The fix itself looks good to me.
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.
Done.