Repository navigation
odcds: convert ODCDS over ADS to pre-cluster-single-subscription - #41174
Conversation
Signed-off-by: Adi Suissa-Peleg <[email protected]>
|
This is a continuation of #40988 and uses the component introduced there to fix a bug where OD-CDS isn't working when |
| Upstream::OdCdsApiHandlePtr); | ||
| } | ||
| } | ||
| if (odcds == nullptr) { |
There was a problem hiding this comment.
should this be an else block instead? E.g.:
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.odcds_over_ads_fix")) {
...
} else {
odcds = THROW_OR_RETURN_VALUE(cm.allocateOdCdsApi(&Upstream::OdCdsApiImpl::create,
odcds_config->source(), absl::nullopt,
validation_visitor),
Upstream::OdCdsApiHandlePtr);
}
Or is it written as intentional fallback in case when flag is enabled and on_demand_cds fails to initialize for some reason?
There was a problem hiding this comment.
It should be the else of the 2 conditions above, so I could rewrite it as follows:
if ((Runtime::runtimeFeatureEnabled("envoy.reloadable_features.odcds_over_ads_fix")) && (odcds_config->source().config_source_specifier_case() ==
envoy::config::core::v3::ConfigSource::ConfigSourceSpecifierCase::kAds)) {
odcds = THROW_OR_RETURN_VALUE(cm.allocateOdCdsApi(&Upstream::XdstpOdCdsApiImpl::create,
odcds_config->source(), absl::nullopt,
validation_visitor),
Upstream::OdCdsApiHandlePtr);
} else {
...
I'm not against it, and just thought that the first case is more readable, but I'm happy to change this if you think otherwise (I'm really good with both options).
There was a problem hiding this comment.
sounds good, i missed that it was else for 2 conditions above
|
|
||
| class AdsIntegrationTest : public AdsDeltaSotwIntegrationSubStateParamTest, | ||
| public HttpIntegrationTest { | ||
| class AdsIntegrationTestBase : public Grpc::BaseGrpcClientIntegrationParamTest, |
There was a problem hiding this comment.
do we expect multiple parallel subclasses of AdsIntegrationTestBase class in future? If not, could just keep is simple with one base class
There was a problem hiding this comment.
Good question.
There are already multiple sub-classes of AdsIntegrationTest, but they all use the same TestWithParam parameters (although some might not need to). I think the others will need to be refactored (less parameters) to decrease the tests runtime.
KBaichoo
left a comment
There was a problem hiding this comment.
Thank you for working on this. LGTM besides small comments.
| was not being properly extracted in the final Prometheus stat name. | ||
| - area: odcds | ||
| change: | | ||
| Fixed a bug where using OD-CDS without cds_config would not workin some |
There was a problem hiding this comment.
Oops, thanks, fixed.
|
|
||
| // A singleton through which all subscriptions will be processed. | ||
| XdstpOdcdsSubscriptionsManagerSharedPtr subscriptions_manager_; | ||
| bool old_ads_; |
| // TODO(adisuissa): convert the config_source to optional. | ||
| bool old_ads = false; | ||
| if (config_source.config_source_specifier_case() == | ||
| envoy::config::core::v3::ConfigSource::ConfigSourceSpecifierCase::kAds) { |
There was a problem hiding this comment.
why is old_ads not just equal to the test that sets it to true?
e.g.
const bool old_ads = config_source.config_source_specifier_case() ==
envoy::config::core::v3::ConfigSource::ConfigSourceSpecifierCase::kAds;
There was a problem hiding this comment.
Good idea, fixed.
|
/wait |
Signed-off-by: Adi Suissa-Peleg <[email protected]>
Signed-off-by: Adi Suissa-Peleg <[email protected]>
Commit Message: tcp_proxy: fix OD-CDS over ADS Additional Description: This PR is similar to #41174 (and uses the same component to achieve the same goal). The fix allows proper use of tcp_proxy on-demand cluster discovery when used over ADS. Risk Level: low - only impacts OD-CDS over tcp_proxy Testing: Added integration tests. Docs Changes: N/A Release Notes: Added Platform Specific Features: N/A Runtime guard: Added `envoy.reloadable_features.tcp_proxy_odcds_over_ads_fix` to disable the behavior. --------- Signed-off-by: Adi Suissa-Peleg <[email protected]>
Commit Message: tcp_proxy: fix OD-CDS over ADS Additional Description: This PR is similar to envoyproxy#41174 (and uses the same component to achieve the same goal). The fix allows proper use of tcp_proxy on-demand cluster discovery when used over ADS. Risk Level: low - only impacts OD-CDS over tcp_proxy Testing: Added integration tests. Docs Changes: N/A Release Notes: Added Platform Specific Features: N/A Runtime guard: Added `envoy.reloadable_features.tcp_proxy_odcds_over_ads_fix` to disable the behavior. --------- Signed-off-by: Adi Suissa-Peleg <[email protected]> Signed-off-by: bjmask <[email protected]>
Commit Message: tcp_proxy: fix OD-CDS over ADS Additional Description: This PR is similar to envoyproxy#41174 (and uses the same component to achieve the same goal). The fix allows proper use of tcp_proxy on-demand cluster discovery when used over ADS. Risk Level: low - only impacts OD-CDS over tcp_proxy Testing: Added integration tests. Docs Changes: N/A Release Notes: Added Platform Specific Features: N/A Runtime guard: Added `envoy.reloadable_features.tcp_proxy_odcds_over_ads_fix` to disable the behavior. --------- Signed-off-by: Adi Suissa-Peleg <[email protected]>
Commit Message: tcp_proxy: fix OD-CDS over ADS Additional Description: This PR is similar to envoyproxy#41174 (and uses the same component to achieve the same goal). The fix allows proper use of tcp_proxy on-demand cluster discovery when used over ADS. Risk Level: low - only impacts OD-CDS over tcp_proxy Testing: Added integration tests. Docs Changes: N/A Release Notes: Added Platform Specific Features: N/A Runtime guard: Added `envoy.reloadable_features.tcp_proxy_odcds_over_ads_fix` to disable the behavior. --------- Signed-off-by: Adi Suissa-Peleg <[email protected]>
Commit Message: tcp_proxy: fix OD-CDS over ADS Additional Description: This PR is similar to envoyproxy#41174 (and uses the same component to achieve the same goal). The fix allows proper use of tcp_proxy on-demand cluster discovery when used over ADS. Risk Level: low - only impacts OD-CDS over tcp_proxy Testing: Added integration tests. Docs Changes: N/A Release Notes: Added Platform Specific Features: N/A Runtime guard: Added `envoy.reloadable_features.tcp_proxy_odcds_over_ads_fix` to disable the behavior. --------- Signed-off-by: Adi Suissa-Peleg <[email protected]>
XdstpOdCdsApiImpl::XdstpOdcdsSubscriptionsManager kept a per-resource entry in subscriptions_ for the lifetime of the singleton, even after the cluster manager declared the on-demand discovery terminated with Timeout or Missing. As a result, the very first request that timed out (or was answered with removed_resources) permanently poisoned every subsequent request for the same cluster: addSubscription's "already subscribed to, skipping" early-return fired on every retry, no DiscoveryRequest was ever issued, and each retry consumed the ODCDS timeout before returning 503 NC cluster_not_found. This regression was introduced in 1.38.0 by envoyproxy#41174 and is observable on configurations using `odcds.source: { ads: {} }` against a delta- ADS control plane. The legacy OdCdsApiImpl path (which holds a single long-lived subscription rather than one per resource) is unaffected. This change introduces a new OdCdsApi::onDiscoveryTerminated hook (default no-op) and calls it from ClusterManagerImpl::notifyClusterDiscoveryStatus on terminal Timeout and Missing statuses. XdstpOdCdsApiImpl overrides the hook to erase the matching entry from subscriptions_ via a new manager-side removeSubscription helper, which causes PerSubscriptionData (and its underlying xDS subscription) to be torn down. A subsequent on-demand request for the same cluster therefore creates a fresh subscription and re-issues a DiscoveryRequest, restoring the 1.37 behavior. The eviction is dispatched through ClusterManagerImpl::dispatcher_ so the subscription is not destroyed synchronously from inside its own onConfigUpdate -> notifyMissingCluster -> notifyClusterDiscoveryStatus call stack (which would be a use-after-free). Behavior is gated by a new runtime guard, envoy.reloadable_features.odcds_evict_subscription_on_terminal_status, defaulting to true, so production can revert without disabling the broader odcds_over_ads_fix change. Tests: - new TEST_F entries in xdstp_od_cds_api_impl_test.cc covering subscribe -> Timeout/Missing terminal -> resubscribe (and Available retains the subscription as designed). - new TEST_P(OdCdsAdsIntegrationTest, OnDemandClusterDiscoveryTimesOutThenRetrySucceeds) that exercises the regression end-to-end over a delta ADS control plane: first request times out with 503, eviction emits an unsubscribe on the wire, and a second request triggers a fresh subscribe that succeeds with 200. - existing OnDemandClusterDiscoveryAsksForNonexistentCluster tests (HTTP and xDS-TP variants) updated to reflect the new post-Missing unsubscribe on the wire when the new path is enabled. Risk: low. The default OdCdsApi::onDiscoveryTerminated is a no-op, so legacy OdCdsApiImpl is unchanged. The new code path is only exercised by XdstpOdCdsApiImpl (i.e. odcds_over_ads_fix=true, which has been the default since 1.36) and is reversible via runtime guard. Signed-off-by: William Dauchy <[email protected]> Made-with: Cursor
XdstpOdCdsApiImpl::XdstpOdcdsSubscriptionsManager kept a per-resource entry in subscriptions_ for the lifetime of the singleton, even after the cluster manager declared the on-demand discovery terminated with Timeout or Missing. As a result, the very first request that timed out (or was answered with removed_resources) permanently poisoned every subsequent request for the same cluster: addSubscription's "already subscribed to, skipping" early-return fired on every retry, no DiscoveryRequest was ever issued, and each retry consumed the ODCDS timeout before returning 503 NC cluster_not_found. This regression was introduced in 1.38.0 by envoyproxy#41174 and is observable on configurations using `odcds.source: { ads: {} }` against a delta- ADS control plane. The legacy OdCdsApiImpl path (which holds a single long-lived subscription rather than one per resource) is unaffected. This change introduces a new OdCdsApi::onDiscoveryTerminated hook (default no-op) and calls it from ClusterManagerImpl::notifyClusterDiscoveryStatus on terminal Timeout and Missing statuses. XdstpOdCdsApiImpl overrides the hook to erase the matching entry from subscriptions_ via a new manager-side removeSubscription helper, which causes PerSubscriptionData (and its underlying xDS subscription) to be torn down. A subsequent on-demand request for the same cluster therefore creates a fresh subscription and re-issues a DiscoveryRequest, restoring the 1.37 behavior. The eviction is dispatched through ClusterManagerImpl::dispatcher_ so the subscription is not destroyed synchronously from inside its own onConfigUpdate -> notifyMissingCluster -> notifyClusterDiscoveryStatus call stack (which would be a use-after-free). Behavior is gated by a new runtime guard, envoy.reloadable_features.odcds_evict_subscription_on_terminal_status, defaulting to true, so production can revert without disabling the broader odcds_over_ads_fix change. Tests: - new TEST_F entries in xdstp_od_cds_api_impl_test.cc covering subscribe -> Timeout/Missing terminal -> resubscribe (and Available retains the subscription as designed). - new TEST_P(OdCdsAdsIntegrationTest, OnDemandClusterDiscoveryTimesOutThenRetrySucceeds) that exercises the regression end-to-end over a delta ADS control plane: first request times out with 503, eviction emits an unsubscribe on the wire, and a second request triggers a fresh subscribe that succeeds with 200. - existing OnDemandClusterDiscoveryAsksForNonexistentCluster tests (HTTP and xDS-TP variants) updated to reflect the new post-Missing unsubscribe on the wire when the new path is enabled. Risk: low. The default OdCdsApi::onDiscoveryTerminated is a no-op, so legacy OdCdsApiImpl is unchanged. The new code path is only exercised by XdstpOdCdsApiImpl (i.e. odcds_over_ads_fix=true, which has been the default since 1.36) and is reversible via runtime guard. Signed-off-by: William Dauchy <[email protected]>
XdstpOdCdsApiImpl kept per-resource entries in its singleton subscriptions_ map for the lifetime of the API, even after the cluster manager declared the on-demand discovery terminated with Timeout or Missing. Once stuck, addSubscription's "already subscribed to, skipping" early-return fired on every retry, no DiscoveryRequest was ever issued, and each retry just consumed the ODCDS timeout before returning 503 NC cluster_not_found. This is a 1.37 -> 1.38 regression introduced by envoyproxy#41174 on configurations using `odcds.source: { ads: {} }`. The legacy OdCdsApiImpl path (single long-lived subscription) is unaffected. Add a no-op OdCdsApi::onDiscoveryTerminated hook called from ClusterManagerImpl::notifyClusterDiscoveryStatus on terminal Timeout and Missing. XdstpOdCdsApiImpl overrides it to erase the matching subscriptions_ entry, so the next request creates a fresh subscription and re-issues a DiscoveryRequest. Available is intentionally retained, preserving the envoyproxy#41174 design. Eviction is post-dispatched to avoid tearing down the subscription synchronously from inside its own onConfigUpdate -> notifyMissingCluster -> notifyClusterDiscoveryStatus stack. Gated by a new runtime guard envoy.reloadable_features.odcds_evict_subscription_on_terminal_status, default true, so production can revert without disabling the broader odcds_over_ads_fix change. Tests: - new unit tests in xdstp_od_cds_api_impl_test.cc covering subscribe -> Timeout/Missing terminal -> resubscribe, and Available retaining the subscription. - new OnDemandClusterDiscoveryTimesOutThenRetrySucceeds integration test: first request times out with 503, eviction emits an unsubscribe, second request triggers a fresh subscribe that succeeds with 200. Fails on unmodified main, passes here. - OnDemandClusterDiscoveryAsksForNonexistentCluster (HTTP and xDS-TP variants) updated for the new post-Missing unsubscribe on the wire. Risk: low. Default hook is a no-op, legacy OdCdsApiImpl unchanged. Only XdstpOdCdsApiImpl (odcds_over_ads_fix=true, default since 1.36) hits the new path; reversible via runtime guard. Signed-off-by: William Dauchy <[email protected]> Made-with: Cursor
Commit Message: odcds: convert ODCDS over ADS to pre-cluster-single-subscription
Additional Description:
Prior to this PR there were issues when using OD-CDS without cds_config.
This PR converts OD-CDS over ADS to use the new XdstpOdCdsApiImpl (that is also used for xDS-federation based OD-CDS subscriptions).
Risk Level: low - only impacts OD-CDS usage
Testing: Added many integration tests. Unit tests were already added for the original OD-CDS implementations.
Docs Changes: N/A
Release Notes: Added.
Platform Specific Features: N/A
Runtime guard: This change is guarded by
envoy.reloadable_features.odcds_over_ads_fixto ensure that there's an escape hatch if some unintentional change occurs.