Skip to content

test: Wait for cert_active before interrupting the on_demand handshake - #48967

Merged
RyanTheOptimist merged 1 commit into
envoyproxy:mainfrom
phlax:test-on-demand-cert-active-wait
Nov 5, 2026
Merged

RyanTheOptimist merged 1 commit into
envoyproxy:mainfrom
phlax:test-on-demand-cert-active-wait

Conversation

@phlax

@phlax phlax commented Nov 3, 2026

Copy link
Copy Markdown
Member

ClientInterruptedHandshake asserted cert_active == 1 straight after waitCertsRequested(1). The secret manager increments cert_requested and then cert_active on the main thread, so the test thread can see the counter at 1, close the client and read the gauge before the second increment lands. It did under tsan (run 41663745469): nothing decrements the gauge in that test, so the 0 it read was the increment not having happened yet.

Wait for the gauge to reach 1 before closing the client, so the check after the close is checking what it means to: that interrupting the handshake does not drop the outstanding SDS subscription.

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested
and then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing
decrements the gauge in that test, so the 0 it read was the increment
not having happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
@phlax
phlax force-pushed the test-on-demand-cert-active-wait branch from 2a45b21 to 72f759c Compare November 3, 2026 16:48
@phlax
phlax requested a balanced review from Copilot November 3, 2026 16:48

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

No active review issues remain for the TLS handshake test timing change.

No open issues 🎉

What changed in this PR

Removes a timing race in the on-demand TLS ClientInterruptedHandshake integration test, so it checks that interrupting a handshake preserves the outstanding SDS subscription.

Changes:

  • Waits for cert_active to reach 1 before closing the client.
  • Explains why waiting for cert_requested alone is insufficient.
File Description
test/​extensions/​transport_sockets/​tls/​cert_selectors/​on_demand/​integration_test.cc Adds a gauge wait before interrupting the handshake to prevent a premature assertion.

Review effort: Balanced

@RyanTheOptimist
RyanTheOptimist merged commit 71f29fe into envoyproxy:main Nov 5, 2026
27 checks passed
phlax added a commit to phlax/envoy that referenced this pull request Nov 12, 2026
envoyproxy#48967)

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
jwendell pushed a commit that referenced this pull request Nov 12, 2026
#48967)

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 16, 2026
envoyproxy#48967)

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

(cherry picked from commit 71f29fe)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit that referenced this pull request Nov 17, 2026
#48967)

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

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

ClientInterruptedHandshake asserted cert_active == 1 straight after
waitCertsRequested(1). The secret manager increments cert_requested and
then cert_active on the main thread, so the test thread can see the
counter at 1, close the client and read the gauge before the second
increment lands. It did under tsan (run 41663745469): nothing decrements
the gauge in that test, so the 0 it read was the increment not having
happened yet.

Wait for the gauge to reach 1 before closing the client, so the check
after the close is checking what it means to: that interrupting the
handshake does not drop the outstanding SDS subscription.

Signed-off-by: Ryan Northey <[email protected]>
Backport note: with this branch's `waitForGaugeEq` (`main`'s `waitForGauge` takes a
matcher).

(cherry picked from commit 71f29fe)
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