Skip to content

test/hds: Wait for health check counters before checking them - #49257

Merged
phlax merged 1 commit into
envoyproxy:mainfrom
phlax:hds-test-counter-race
Nov 16, 2026
Merged

phlax merged 1 commit into
envoyproxy:mainfrom
phlax:hds-test-counter-race

Conversation

@phlax

@phlax phlax commented Nov 14, 2026

Copy link
Copy Markdown
Member

Commit Message: test/hds: Wait for health check counters before checking them
Additional Description:

HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc failed once in postsubmit tsan with cluster.anna.health_check.failure at 0 instead of 1 (hds_integration_test.cc:306):
https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as FAILED_ACTIVE_HC, so every HDS report sent before the first health check reports them as UNHEALTHY. waitForEndpointHealthResponse(UNHEALTHY) can therefore return on a report sent before the health check failed. checkCounters() then reads the failure counter once, and can read it before the failure has been counted.

checkCounters() now waits for the success and failure counters to reach the expected values before checking them exactly. The tests set the health check interval to MaxTimeout, so the counters cannot move past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the failing test and 1000 tsan runs of the whole hds_integration_test on main passed. Checking the counters against the first UNHEALTHY report, before the health check has run, fails 200/200 on main, which confirms the stale report. This change targets the observed failure but is not validated against a reproduction.

Docs Changes: n/a
Release Notes: n/a

Copilot AI 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.

🟢 Approval recommended

There are no active review issues blocking the test-only change to wait for health-check counters before asserting their exact values.

No open issues 🎉

What changed in this PR

This test-only change addresses a timing race in HDS integration tests where an UNHEALTHY report can arrive before the health-check failure counter is incremented.

Changes:

  • Wait for health-check success and failure counters to reach their expected values.
  • Preserve exact counter assertions after the waits.
File Description
test/​integration/​hds_integration_test.cc Adds counter waits in checkCounters() to avoid premature assertions.

Review effort: Balanced

@phlax
phlax merged commit d4f6452 into envoyproxy:main Nov 16, 2026
25 checks passed
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit that referenced this pull request Nov 17, 2026
`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 18, 2026
…roxy#49257)

`HdsIntegrationTest.SingleEndpointUnhealthyTlsMissingSocketMatch/IPv4_EnvoyGrpc`
failed once in postsubmit tsan with `cluster.anna.health_check.failure`
at 0 instead of 1 (`hds_integration_test.cc:306`):

https://github.com/envoyproxy/envoy/actions/runs/43522277566/job/132219362568

HDS hosts start as `FAILED_ACTIVE_HC`, so every HDS report sent before
the first health check reports them as UNHEALTHY.
`waitForEndpointHealthResponse(UNHEALTHY)` can therefore return on a
report sent before the health check failed. `checkCounters()` then reads
the failure counter once, and can read it before the failure has been
counted.

`checkCounters()` now waits for the success and failure counters to
reach the expected values before checking them exactly. The tests set
the health check interval to `MaxTimeout`, so the counters cannot move
past the expected values while the test waits.

Risk Level: low (test only)
Testing:

The CI failure does not reproduce in staging: 1000 tsan runs of the
failing test and 1000 tsan runs of the whole `hds_integration_test` on
main passed. Checking the counters against the first UNHEALTHY report,
before the health check has run, fails 200/200 on main, which confirms
the stale report. This change targets the observed failure but is not
validated against a reproduction.

Signed-off-by: Ryan Northey <[email protected]>
Backport note (release/v1.38): with this branch's `waitForCounterGe()`, as it
has no `waitForCounter()` matcher overload (envoyproxy#44864).

(cherry picked from commit d4f6452)
Signed-off-by: Ryan Northey <[email protected]>
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.

3 participants