Skip to content

fix(fleet-queue): secrets-broker publishes refresh progress; fetches land as they complete - #13125

Open
dezren39 wants to merge 1 commit into
mainfrom
xaltha/13081-heal-refresh
Open

dezren39 wants to merge 1 commit into
mainfrom
xaltha/13081-heal-refresh

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Refs #13081 — the broker-side half of the fix; the heal-side rule change is named below and does not live in this repo.

Root cause, as confirmed in code

The only heal rule that restarts fleet serve secrets-broker on a health verdict is the sandbox prelude's (broker process ≥120s old + /health not reporting serving:true → kill). It never looks at refreshing. A first refresh takes longer than that fixed patience — one bws secret get per secret (~221), 8 in flight — so the kill lands mid-refresh, the next start begins the refresh from zero, and the broker can starve indefinitely (observed 2026-11-23 07:54–07:56Z; left alone, the same refresh completed and health went green).

The repo-owned half of the defect: the broker gave a heal no way to apply the rule this issue prescribes ("do not restart while refreshing:true with refresh progress underway"). Installs were batch-atomic — fetched values sat in a worker-local map until every fetch joined — so for the entire first refresh /health reported secrets: 0, with no progress signal at all. A slow-but-healthy refresh and a wedged one were indistinguishable.

What this PR changes (fleet-queue, secrets_broker.rs only)

  • Refresh progress is tracked and published. State gains a refresh_progress record {started_unix, fetched, total}, opened when the authoritative list lands, advanced once per completed fetch (either outcome — a completed fetch is forward motion), and closed when the refresh ends. /health publishes it as an object in flight, null when idle.
  • Fetches land as they complete. Each successful fetch is installed into the live cache immediately, stamped with its own fetch time — the per-secret install the module doc already promises (fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767). The batch-end install_refresh is unchanged and still owns eviction against the authoritative list and the all-fetches-failed → keep-whole-cache rule; the early landing changes only when a value becomes visible, never what installs. /health's secrets count now climbs during a first refresh, and early secrets are servable while siblings still fetch. serving still waits for a completed refresh.
  • The heal contract is written down in the module doc: do not restart a broker whose health shows refreshing with advancing refresh_progress.fetched (or a climbing secrets count); size a first-refresh patience window to the vault (refresh_progress.total × per-call latency ÷ 8); restart is for absent, not-refreshing-and-not-serving, or no-progress-past-the-window.

What remains outside this repo

The prelude's kill rule itself (~/tools/init-ensure.sh, sandbox-local, not versioned here) needs the matching change: consult refreshing/refresh_progress before killing a not-serving broker, with the vault-sized patience above. Flagged on the issue; this PR gives that rule the signal it needs.

Evidence

  • cargo test -p fleet-queue --lib --features secrets-broker — 143 passed, 0 failed (sandbox, local rustup 1.99.0 toolchain cargo; the module is feature-gated, so the feature flag is required to see its tests at all).
  • The secrets_broker module suite: 26 passed, 0 failed, including 3 new tests, each naming its oracle:
    • health_publishes_refresh_progress_only_while_refreshing — progress object with exact fetched/total in flight; null when idle.
    • fetched_secrets_are_visible_before_the_first_refresh_completes — a landed fetch is in the cache and counted on /health mid-first-refresh; serving stays false; an unreached name still gets the not-loaded 503.
    • refresh_progress_counts_completions_and_stops_at_the_end — the count advances per completion and the record closes with the refresh (a frozen count is the wedged signal).
  • rustfmt --check clean. No new build warnings (the 2 warnings in the test build are pre-existing: merge_intent.rs unused-mut, home.rs dead code). Clippy not run locally — CI is the first clippy pass.

Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b1a0a192-1cc0-49d9-ac20-22dbd294f47f
Commits

Reviewing files that changed from the base of the PR and between 5a098de and 45fa676.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-queue/src/secrets_broker.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T08:40:52.119209Z 45fa676 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

1 participant