Skip to content

odcds: answer repeated requests for known-missing clusters immediately - #48024

Merged
wbpcode merged 5 commits into
envoyproxy:mainfrom
wbpcode:dev-odcds-missing-cache-per-source
Oct 14, 2026
Merged

wbpcode merged 5 commits into
envoyproxy:mainfrom
wbpcode:dev-odcds-missing-cache-per-source

Conversation

@wbpcode

@wbpcode wbpcode commented Oct 5, 2026

Copy link
Copy Markdown
Member

Commit Message:

When an on-demand cluster discovery asks for a cluster its config source has already answered as missing, answer the request immediately from that remembered answer instead of starting another discovery and waiting for the response or the discovery timeout. The answer is remembered per config source, only for explicitly requested clusters, and only when the server affirmatively answered that the cluster doesn't exist; a discovery that merely failed or timed out is not remembered and is retried. The remembered answer is withdrawn as soon as an update delivers the cluster, and is not consulted while the cluster is warming.

Risk Level: mid (cluster manager on-demand discovery path; runtime guarded)
Testing: unit.
Docs Changes: N/A
Release Notes: added.
Runtime guard: envoy.reloadable_features.odcds_missing_cluster_cache

@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: #48024 was opened by wbpcode.

see: more, trace.

@mathetake

mathetake commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

@wbpcode this might be very serious breaking change at netflix -- we need some time to assess

@wbpcode

wbpcode commented Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

@wbpcode this might be very serious breaking change at netflix -- we need some time to access

Then let's set the runtime flag as default false and flip it to true after some versions? WDYT?

BTW, this should only affect the behavior of missing clusters to avoid unnecessary hanging? I am not sure whether I missed something in this fix, could you explain a little more about why this will bring serious break changes/side effects? I

@mathetake

mathetake commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Then let's set the runtime flag as default false and flip it to true after some versions? WDYT?

If things are broken, then runtime flag doesn't help and the flag will exist forever, does it?

@wbpcode

wbpcode commented Oct 7, 2026 •

Copy link
Copy Markdown
Member Author

Then let's set the runtime flag as default false and flip it to true after some versions? WDYT?

If things are broken, then runtime flag doesn't help and the flag will exist forever, does it?

iam not sure what you meant by things are broken? Is that means the PR self is not good enough or the previous behavior will be broken by this PR?

I treat this PR as a bug fix and the runtime flag should finally be flipped and then be removed. But a default false gives more time for users to accept the behavior changes gradually.

In the previous implementation, if one cluster is missing, all further requests to this cluster result in a waiting until the discovery timeout.
And with PR, the missing flag will be cached and the request will be acted immediately. But note, the cache is not forever, once the control plain delivered the subscribed cluster, the cache will be erased.

Because i personally think the changes should be in correct direction, I actually wonder what is the specific scenarios that cannot accept the behavior changes? So then we could understand the gap more clearly and try to figure out an agreed solution.

@mathetake

mathetake commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

i said "if" because we are not sure either and that's why i said "we need some time to assess" above

@mathetake

Copy link
Copy Markdown
Member

In the previous implementation, if one cluster is missing, all further requests to this cluster result in a waiting until the discovery timeout.
And with PR, the missing flag will be cached and the request will be acted immediately. But note, the cache is not forever, once the control plain delivered the subscribed cluster, the cache will be erased.

thanks, this clarifies the things a bit. We use the main branch aggressively so we can test after this lands, and will report back if we found an issue in prod

@wdauchy wdauchy left a comment

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.

Thanks, the approach looks right to me. Two things before approving: the immediate answer is broadcast to all workers on every request (inline), and an integration test for the ADS delta and xdstp paths would help, for example extending OnDemandClusterDiscoveryAsksForNonexistentCluster with a second request (503 with no new CDS request) and a server push followed by a 200.

Also, a name answered missing is no longer requested again, so a control plane that only answers on request keeps it missing. Bounding the remembered answer or defaulting the guard to false may be safer, and minor_behavior_changes may fit better than bug_fixes.

Comment thread envoy/upstream/cluster_manager.h Resolved
Comment thread test/common/upstream/odcd_test.cc Resolved
Comment thread test/common/upstream/odcd_test.cc Resolved
Comment thread test/common/upstream/odcd_test.cc Resolved
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
* leaving anything pending there: no later notification will reach this worker, so no
* callback for the name may be left behind waiting for one.
*/
void invokeAllCallbacks(ClusterDiscoveryStatus cluster_status) const {

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.

This is the one place where a second callback queued on this worker between its post and the answer gets picked up since nothing goes into pending_cluster_creations_ and no timer is there on this path.

We don't seem to have any new tests around this. In odcd_test.cc the posts run inline, so the second request never queues behind an in-flight one and all four pass with invokeCallback here.

Could we add a case that captures the post to factory_.tls_.dispatcher_, queues a second request for cluster_foo before running it, and asserts both callbacks fire? With a single invoke the second one hangs with no timer, and the worker's list stays non-empty so later requests for that name on that worker never post again.

agrawroh
agrawroh previously approved these changes Oct 13, 2026

@agrawroh agrawroh left a comment

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.

Looks good overall. If possible, let's have a test around two-callbacks-on-one-worker scenario.

Signed-off-by: wbpcode <[email protected]>
@wbpcode

wbpcode commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

/retest

@wbpcode
wbpcode merged commit 1db8804 into envoyproxy:main Oct 14, 2026
27 checks passed
@wbpcode
wbpcode deleted the dev-odcds-missing-cache-per-source branch October 14, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants