Repository navigation
healthcheck: defer health check until cluster finishes warming - #43277
Conversation
|
/retest |
f94b7ae to
6e4ee50
Compare
Health checks were starting immediately when the health checker was created, before the cluster completed initialization. This caused issues when cluster depended on SDS secrets: health check sessions would fail because the transport socket configuration wasn't ready yet. Signed-off-by: Tero Saarni <[email protected]>
6e4ee50 to
c5ae48b
Compare
|
/assign @adisuissa |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks, the fix makes sense to me, and overall LGTM.
Please add a runtime-guard as this is a behavior-visible change, and a release note.
| addHosts(hosts_added); | ||
| // Skip adding hosts while cluster is still warming (e.g., waiting for SDS secrets). | ||
| // start() will add all existing hosts after warming completes. | ||
| if (cluster_.info()->configUpdateStats().warming_state_.value() == 0) { |
There was a problem hiding this comment.
It seems a bit strange that stats are used to determine whether the cluster is active or warmed. Is there a different path that can be used here (that avoids using the stats)?
There was a problem hiding this comment.
There was not, but I have now added the new flag HealthCheckerImplBase::started_ to track if HealthCheckerImplBase::start() has been called. Since start() is now delayed until the cluster is active, this flag effectively serves the same purpose.
| void HealthCheckerImplBase::addHosts(const HostVector& hosts) { | ||
| for (const HostSharedPtr& host : hosts) { | ||
| if (host->disableActiveHealthCheck()) { | ||
| if (host->disableActiveHealthCheck() || active_sessions_.contains(host)) { |
There was a problem hiding this comment.
I'm guessing this is an improvement that is not related to the current fix, correct?
There was a problem hiding this comment.
I needed to make this change to prevent a new issue caused by delaying HealthCheckerImplBase::start():
When running IpVersionsClientType/LedsIntegrationTest.BasicLeds I got a crash due to the ASSERT in the health checker session destructor here.
With delayed start(), the sequence was:
- Host is added during cluster warming.
- Health checker is finally started and
HealthCheckerImplBase::start()adds all current hosts by callingaddHosts(). HealthCheckerImplBase::onClusterMemberUpdate()is called with the same host, which callsaddHosts()again.- A new session is created, it replaces the old session object, and the destructor of to-be-replaced old session fails due to the
ASSERT(client_ == nullptr).
Previously, before this PR, the sequence was:
HealthCheckerImplBase::start()is called immediately, but there are no hosts yet, soaddHosts()is not called.- Host is added.
HealthCheckerImplBase::onClusterMemberUpdate()is called and the session is created successfully.
Now I'm wondering if there is any state that requires recreating the session at every cluster member update, rather than skipping creation when a session already exists. I must admit, I don't understand how the client_ is released.
There was a problem hiding this comment.
I guess HealthCheckerImplBase::addHosts() was probably never called twice for the same host before this change. Maybe instead of re-creating same host, the host always went through the HealthCheckerImplBase::onClusterMemberUpdate(..., removed_hosts) and therefore the session, including client_ was released here.
There was a problem hiding this comment.
I don't have enough context here, but the fix seems OK to me as there shouldn't really be a need to make a session to the same host (assuming the previous session is already valid).
To ensure that this doesn't cause an accidental issue, it is suggested to also have this under the runtime guard.
There was a problem hiding this comment.
Thanks @adisuissa, I have placed this behind the existing runtime guard in new commit 7cb86af.
…rom stats Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
@adisuissa I've now added a runtime guard to restore the old behavior and a test case for that. |
Signed-off-by: Tero Saarni <[email protected]>
Signed-off-by: Tero Saarni <[email protected]>
|
@adisuissa, friendly reminder, I'd appreciate your review when you have time! I've caught up with main and resolved new conflicts. |
adisuissa
left a comment
There was a problem hiding this comment.
Overall LGTM.
/assign-from @envoyproxy/senior-maintainers
| void HealthCheckerImplBase::addHosts(const HostVector& hosts) { | ||
| for (const HostSharedPtr& host : hosts) { | ||
| if (host->disableActiveHealthCheck()) { | ||
| if (host->disableActiveHealthCheck() || active_sessions_.contains(host)) { |
There was a problem hiding this comment.
I don't have enough context here, but the fix seems OK to me as there shouldn't really be a need to make a session to the same host (assuming the previous session is already valid).
To ensure that this doesn't cause an accidental issue, it is suggested to also have this under the runtime guard.
|
@envoyproxy/senior-maintainers assignee is @zuercher |
Signed-off-by: Tero Saarni <[email protected]>
|
@tsaarni Needs a main merge. /wait |
Signed-off-by: Tero Saarni <[email protected]>
|
@agrawroh I've merged. It would be great to get this forward! |
|
/retest |
Signed-off-by: Tero Saarni <[email protected]>
|
/retest |
|
@yanavlasov @wbpcode @phlax, I’d appreciate an additional maintainer review on this PR when you have a moment 🙏 |
|
Thank you @wbpcode. |
…proxy#43277) Fixes envoyproxy#43116 **Commit Message:** healthcheck: defer health check until cluster finishes warming **Additional Description:** Active health checks started before the cluster finished initializing, causing failures when the cluster required SDS secrets for upstream connections. Health checks failed because the transport socket configuration was not ready, leading to intermittent failures at startup and when recreating the cluster to update the SDS reference, such as during certificate rotation.. See envoyproxy#43116 for full problem description. This change defers the start of health checks until the cluster has finished warming, ensuring that all necessary configurations (including SDS secrets) are fetched before checks begin. **Risk Level:** Low **Testing:** Added test to verify that health checks are deferred until the cluster warming state is cleared. **Docs Changes:** N/A **Release Notes:** health_check: Fixed a race condition where active health checks could start before required upstream TLS SDS secrets were fetched, causing intermittent health check failures. **Platform Specific Features:** N/A --------- Signed-off-by: Tero Saarni <[email protected]>
…proxy#43277) Fixes envoyproxy#43116 **Commit Message:** healthcheck: defer health check until cluster finishes warming **Additional Description:** Active health checks started before the cluster finished initializing, causing failures when the cluster required SDS secrets for upstream connections. Health checks failed because the transport socket configuration was not ready, leading to intermittent failures at startup and when recreating the cluster to update the SDS reference, such as during certificate rotation.. See envoyproxy#43116 for full problem description. This change defers the start of health checks until the cluster has finished warming, ensuring that all necessary configurations (including SDS secrets) are fetched before checks begin. **Risk Level:** Low **Testing:** Added test to verify that health checks are deferred until the cluster warming state is cleared. **Docs Changes:** N/A **Release Notes:** health_check: Fixed a race condition where active health checks could start before required upstream TLS SDS secrets were fetched, causing intermittent health check failures. **Platform Specific Features:** N/A --------- Signed-off-by: Tero Saarni <[email protected]> Signed-off-by: Xuyang Tao <[email protected]>
…proxy#43277) Fixes envoyproxy#43116 **Commit Message:** healthcheck: defer health check until cluster finishes warming **Additional Description:** Active health checks started before the cluster finished initializing, causing failures when the cluster required SDS secrets for upstream connections. Health checks failed because the transport socket configuration was not ready, leading to intermittent failures at startup and when recreating the cluster to update the SDS reference, such as during certificate rotation.. See envoyproxy#43116 for full problem description. This change defers the start of health checks until the cluster has finished warming, ensuring that all necessary configurations (including SDS secrets) are fetched before checks begin. **Risk Level:** Low **Testing:** Added test to verify that health checks are deferred until the cluster warming state is cleared. **Docs Changes:** N/A **Release Notes:** health_check: Fixed a race condition where active health checks could start before required upstream TLS SDS secrets were fetched, causing intermittent health check failures. **Platform Specific Features:** N/A --------- Signed-off-by: Tero Saarni <[email protected]> Signed-off-by: Jonathan Wu <[email protected]>
…proxy#43277) Fixes envoyproxy#43116 **Commit Message:** healthcheck: defer health check until cluster finishes warming **Additional Description:** Active health checks started before the cluster finished initializing, causing failures when the cluster required SDS secrets for upstream connections. Health checks failed because the transport socket configuration was not ready, leading to intermittent failures at startup and when recreating the cluster to update the SDS reference, such as during certificate rotation.. See envoyproxy#43116 for full problem description. This change defers the start of health checks until the cluster has finished warming, ensuring that all necessary configurations (including SDS secrets) are fetched before checks begin. **Risk Level:** Low **Testing:** Added test to verify that health checks are deferred until the cluster warming state is cleared. **Docs Changes:** N/A **Release Notes:** health_check: Fixed a race condition where active health checks could start before required upstream TLS SDS secrets were fetched, causing intermittent health check failures. **Platform Specific Features:** N/A --------- Signed-off-by: Tero Saarni <[email protected]> Signed-off-by: Nick Shipilov <[email protected]>
…proxy#43277) Fixes envoyproxy#43116 **Commit Message:** healthcheck: defer health check until cluster finishes warming **Additional Description:** Active health checks started before the cluster finished initializing, causing failures when the cluster required SDS secrets for upstream connections. Health checks failed because the transport socket configuration was not ready, leading to intermittent failures at startup and when recreating the cluster to update the SDS reference, such as during certificate rotation.. See envoyproxy#43116 for full problem description. This change defers the start of health checks until the cluster has finished warming, ensuring that all necessary configurations (including SDS secrets) are fetched before checks begin. **Risk Level:** Low **Testing:** Added test to verify that health checks are deferred until the cluster warming state is cleared. **Docs Changes:** N/A **Release Notes:** health_check: Fixed a race condition where active health checks could start before required upstream TLS SDS secrets were fetched, causing intermittent health check failures. **Platform Specific Features:** N/A --------- Signed-off-by: Tero Saarni <[email protected]>
…de paths (#48561) Commit Message: runtime: remove health_check_after_cluster_warming flag and legacy code paths Additional Description: The guard was added in #43277 (2026-03). This removes it and the legacy code path, so active health checking always starts once the cluster finishes warming rather than when the health checker is attached. The guard-disabled integration test ClusterWarmingWhileHealthCheckBlocksOnSdsDisabled is removed. Risk Level: Low Testing: N/A. Docs Changes: N/A Release Notes: added. Runtime guard: Removed envoy.reloadable_features.health_check_after_cluster_warming --------- Signed-off-by: wbpcode <[email protected]>
Fixes #43116
Commit Message: healthcheck: defer health check until cluster finishes warming
Additional Description:
Active health checks started before the cluster finished initializing, causing failures when the cluster required SDS secrets for upstream connections. Health checks failed because the transport socket configuration was not ready, leading to intermittent failures at startup and when recreating the cluster to update the SDS reference, such as during certificate rotation..
See #43116 for full problem description.
This change defers the start of health checks until the cluster has finished warming, ensuring that all necessary configurations (including SDS secrets) are fetched before checks begin.
Risk Level: Low
Testing:
Added test to verify that health checks are deferred until the cluster warming state is cleared.
Docs Changes: N/A
Release Notes:
health_check: Fixed a race condition where active health checks could start before required upstream TLS SDS secrets were fetched, causing intermittent health check failures.
Platform Specific Features: N/A