Skip to content

[release/17.0] Use TimeProvider for SealedSecret sync-wait budget to fix SealedSecretApplyStepTests flake - #22017

Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-19-pr21304from
mitchdenny-backport-17-0-20-pr21530
Closed

Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-19-pr21304from
mitchdenny-backport-17-0-20-pr21530

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Backport of #21530 to release/17.0 (cherry-picked from c37dfbe with no modifications). Layer 20 of 55 in the release/17.0 backport stack; stacked on #22016.

Backport recommendation: No — Test-flake fix.

Backport of #21530

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

…tApplyStepTests flake (#21530)

## Description

Fixes #19662

`SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut`
is flaky on CI.

### Root cause

`WaitForSealedSecretSyncedAsync` and
`InvokeProbeWithRemainingBudgetAsync` measured their budget against the
wall clock (`DateTimeOffset.UtcNow` and `CancelAfter`). #19555 raised
the test budget from 10ms to 250ms, but the test still failed on main on
10-12: under CI load, a slow first iteration (cold JIT, thread-pool
starvation) can use up the whole budget before the second poll, so the
loop times out after observing the absent Secret only once.

### Fix

Inject a `TimeProvider` into the budget calculation, the probe timeout
(`CancellationTokenSource(remaining, timeProvider)`) and the poll delay.
Production passes `TimeProvider.System`, so runtime behavior is
unchanged. The test now uses `FakeTimeProvider`: it waits until the
second probe signals that it started, then calls `Advance` to exhaust
the budget. The budget therefore only elapses after the loop has
demonstrably kept waiting, regardless of runner speed.
`Microsoft.Extensions.TimeProvider.Testing` is already centrally
versioned in `Directory.Packages.props`; the test project only
references it.

### Evidence

- **Fail-before / pass-after:** with a 300ms stall injected into the
first iteration, the old code failed 3/3 with the CI signature and the
fixed code passed 5/5.
- **Under load:** the `SealedSecretApplyStepTests` class passed 30/30
under CPU load.
- **Full project:** `Aspire.Hosting.Radius.Tests` passed 669 tests, 0
failed.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit c37dfbe)
@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-20-pr21530 branch from 55595f3 to 2e42689 Compare November 10, 2026 04:22
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22017

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22017"

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-20-pr21530 branch from 2e42689 to 55595f3 Compare November 10, 2026 04:24
@mitchdenny
Mitch Denny (mitchdenny) marked this pull request as ready for review November 10, 2026 04:55
@mitchdenny

Copy link
Copy Markdown
Member Author

Approved for inclusion in release/17.0. Do not merge yet.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-20-pr21530 branch 2 times, most recently from 55595f3 to 6dfb42f Compare November 10, 2026 07:24
@mitchdenny
Mitch Denny (mitchdenny) changed the base branch from mitchdenny-backport-17-0-19-pr21304 to mitchdenny-backport-17-0-18-pr21545 November 10, 2026 08:18
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-20-pr21530 branch from 6dfb42f to 55595f3 Compare November 10, 2026 09:05
@mitchdenny
Mitch Denny (mitchdenny) changed the base branch from mitchdenny-backport-17-0-18-pr21545 to mitchdenny-backport-17-0-19-pr21304 November 10, 2026 09:45
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.

2 participants