Skip to content

Unverified: does a node draining to zero meshed pods tear down the shared out_http route-config provider? #844

Closed

Description

@bpalermo

When a node drains to zero meshed pods, the egress listener goes away, and with it the last reference to the shared out_http route-config provider. The next pod ADD should therefore re-subscribe cold — back in the warming regime that #817 is about.

This looks benign, because by construction there is no traffic in that window: a node with no meshed pods has nothing to route. But it was not confirmed on the pinned build that the teardown actually happens, and if it does, this is the one path that puts a live node back into the cold-subscription state without an Envoy restart.

Why it is worth confirming rather than assuming

Envoy's RouteConfigProviderManagerImpl keys providers by (route_config_name, config_source hash) and shares them across listeners, holding them by shared_ptr from the listeners that reference them. That sharing is exactly what makes #817's negative RDS−LDS intervals benign — a listener re-push re-uses a provider whose table is already in hand.

Drain-to-zero is the case where that argument stops applying, because the last shared_ptr goes away. Two possibilities:

Either answer is worth having written down, because "what happens to route-config state when a node empties" is currently unknown and the reasoning elsewhere depends on provider lifetime.

How to check

Source-level first, in the pinned Envoy (1.40.0-dev.20260904.13144fb.envoy): whether RouteConfigProviderManagerImpl holds a weak or strong reference to providers once no listener references them.

Live, on a node that can be safely emptied: drain all meshed pods, confirm the egress listener is gone, add one pod back, and watch whether envoy_http_outbound_http_rds_out_http_update_time resets or continues, and whether config_reload increments. A reset means a cold re-subscription.

Split out of #817 rather than bundled, per one-issue-per-finding. Not urgent: no traffic is at risk in the window by construction, and #839 should already make the cold path safe.

Activity

  1. added
    bug
    on Sep 20, 2026
  2. bpalermo commented on Sep 20, 2026

    @bpalermo
    OwnerAuthor

    Settled from the pinned Envoy source. Answer: TORN DOWN — the provider manager retains nothing — but this closes as a non-event, and now for a traced reason rather than the assumed one. No code needed.

    1. The manager holds providers WEAKLY

    source/common/router/rds_impl.* delegates to the shared base. source/common/rds/route_config_provider_manager.h:73-74:

    absl::node_hash_map<uint64_t, std::pair<std::weak_ptr<RouteConfigProvider>, const Init::Target*>>
        dynamic_route_config_providers_;

    weak_ptr. The design is stated outright in source/common/rds/rds_route_config_subscription.cc:102-106: "The ownership of RdsRouteConfigProviderImpl is shared among all HttpConnectionManagers that hold a shared_ptr to it. The RouteConfigProviderManager holds weak_ptrs."

    The strong chain is HCM route_config_provider_ (extensions/filters/network/http_connection_manager/config.h:350) → the FilterFactoryCb → FilterChainImpl → ListenerImpl. No caching layer outlives it: the EDS resources cache is EDS-only, xdstp_based_config_singleton_subscriptions is a FALSE_RUNTIME_GUARD, and /config_dump only .lock()s the weak_ptrs.

    ~RdsRouteConfigSubscription (rds_route_config_subscription.cc:94-107) erases itself from the map, drops the Config::SubscriptionPtr (closing the delta-ADS watch), and takes the Stats::ScopeSharedPtr scope_ with it. Re-creation builds a fresh SharedTargetImpl with initialized_ == false, so the listener warms subject to initial_fetch_timeout.

    2. The premise holds, and aether's drain window makes the cold path actually reachable

    aether's egress listener is per-pod (outbound_http_<pod>, agent/internal/xds/proxy/listener.go:34), so zero meshed pods really does mean zero references to out_http. Confirmed.

    But teardown is deferred by the drain window: ListenerManagerImpl::drainListener parks the ListenerImpl in draining_listeners_ and only destroys it after --drain-time-s. Inside that window a replacement listener reuses the provider warm — reuseDynamicProvider re-adds the stored, already-fired SharedTargetImpl, which short-circuits to watcher_handle->ready() (source/common/init/target_impl.cc:62-71), so the new listener goes straight to ACTIVE with the populated table.

    Envoy's default drain is 600s, which would make the cold path essentially unobservable. aether sets 10s (charts/aether/values.yaml, proxy.hotRestart.drainTime: 10s → --drain-time). So unlike a stock deployment, this path is reachable here in ordinary churn. Worth knowing.

    3. Why the cold re-subscription is safe — sequencing verified, not inferred

    This is the part the issue asked to confirm rather than assume, and it is the part that turned out to matter.

    1. On teardown Envoy's delta mux really does unsubscribe: DeltaSubscriptionState::updateSubscriptionInterest populates names_removed_ (delta_subscription_state.cc:98), copied into resource_names_unsubscribe at :331.
    2. go-control-plane v0.14.0 then forgets it ever served the resource. Subscription.UpdateResourceSubscriptions (pkg/server/stream/v3/subscription.go:154-156) takes the non-wildcard branch for RDS: delete(s.returnedResources, resource), commented "Cleanup unsubscribed resources. This avoids returning a response if the versions have not changed."
    3. So the next pod ADD's re-subscribe carries no prior version, and createDeltaResponse returns out_http — provided the snapshot carries it.
    4. Post-fix(agent): always publish out_http so the egress listener's RDS resolves (#817) #839 it always does: agent/internal/xds/cache/snapshot.go:162 emits BuildOutboundRouteConfiguration unconditionally, zero vhosts included, independent of pod count.

    The counterfactual is the real finding. Step 2 is exactly what would have re-armed #817. Without #839, a node draining to zero and then taking a pod back would hit the #817 silence — not at cold start, but on a running proxy whose control plane had just been made to forget it had ever served out_http. Non-wildcard + never-carried = neither a resource nor a removal = no response at all, 15s warming, then ACTIVE with a null route table.

    So #844 was a genuine second entry point into #817's failure mode. #839 closes it. The guess in the issue was right; it just wasn't safe for the reason of provider retention.

    4. What this means for #817's benign-interval argument

    The argument survives, with one precondition now explicit. Negative RDS−LDS intervals are benign within a provider's lifetime, and that lifetime is bounded by --drain-time-s, not by the process. Drain-to-zero genuinely ends it. The path is safe because the snapshot always carries out_http, not because the provider survives — so if "always emit" is ever made conditional again, this reopens.

    5. Runtime discriminators, if anyone wants to watch it live

    The subscription's scope_ dies with it, so the whole http.<stat_prefix>.rds.out_http.* family disappears from /stats during the gap and restarts at zero.

    • Cold: stat name absent during the gap, then update_attempt = 1, config_reload = 1; init_fetch_timeout non-zero if the control plane is slow; the listener appears in listener_manager.total_listeners_warming; out_http absent from /config_dump?resource=dynamic_route_configs.
    • Warm (inside the drain window): counters continuous, no warming.
    • Unambiguous proof of teardown in a debug log: shared target RdsRouteConfigSubscription RDS init out_http destroyed (source/common/init/target_impl.cc:73).

    (Per [the zero-stats note] a counter that is absent is one that was never incremented, not one that is unexported — here the scope's disappearance makes "absent" the actual signal.)

    6. Adjacent finding worth recording — the reuse key is not the route name

    route_config_provider_manager.h:50-54: the map key is MessageUtil::hash() of the entire HttpConnectionManager.Rds message, with only initial_fetch_timeout released before hashing. Matching route_config_name is not sufficient for reuse — any byte difference in the generated config_source yields a second independent subscription and a second stats scope for the same route config name.

    aether is fine today: config.XDSConfigSourceADSWithInitialFetch (agent/internal/xds/config/common.go:42-47) is a constant struct literal — ConfigSource_Ads{} plus a durationpb, no maps — so the hash is stable. Flagging it because it is the same determinism class as #135, and a future config_source field added non-deterministically would silently split the provider with no NACK and no error.

    Closing as settled and a non-event. Verified on 13144fb (the pin) where it mattered; the working checkout is 211 commits ahead of it, so line numbers may drift by a line or two. Source read only — nothing built, nothing run against a cluster.

  3. bpalermo commented on Sep 20, 2026

    @bpalermo
    OwnerAuthor

    Settled: provider is torn down (weak_ptr manager, deferred by --drain-time-s = 10s), but the path is safe because #839 always emits out_http. See the analysis above — notably that this was a second entry point into #817, not merely a cold-start variant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions