Skip to content

Azure: identity expiry, a failed refresh, toolMissing from the cli source, and resume directories - #112

Open
odgrim wants to merge 4 commits into
track-a/azure-tenant-domainsfrom
track-a/azure-detect-gaps
Open

odgrim wants to merge 4 commits into
track-a/azure-tenant-domainsfrom
track-a/azure-detect-gaps

Conversation

@odgrim

@odgrim odgrim commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Change

Four Azure gaps before the cutover release.

  • A federated sign-in's identity says when it expires. identity.expiresAt is the access token's expiry, as env's expiresAt already is, for a service principal signed in with a federated token. Before, Runbooks had no expiry until the first env. Every other sign-in az renews itself, so it has none.
  • detect goes on when az account list --refresh fails. A copy of the person's az login is listed with --refresh, to see subscriptions created since they signed in. When that fails, detect logs why and lists the subscriptions az already holds, where before the whole detect failed. Runbooks main did the same.
  • The cli source with no az answers toolMissing: a test only. It already did.
  • A resume no longer leaves a directory behind. A resume copied the block's az directory into a new one and left the old one, with its tokens, until signOut: one more per restart. The block's own sign-in directory is now used where it is. Any other directory, such as the person's own login or another block's, is still copied.

Decisions

  • A failed refresh is logged, not shown to the person, as main did (electron/main/ipc/azure-signin.ts:383-397). A warning would need a second warning slot beside the home-tenant one. A refresh that times out adds a second az call, up to 60 s.
  • toolMissing needs no code change. The cli source's unusable_is_none passes toolMissing through, so detect answers it.
  • The block's directory is taken back in place, not deleted after the copy. Runbooks keeps a saved login's values until the block is Ready again. After a delete, a resume that ended in choosing a target, or a restart before the next save, would name a missing directory.
  • install keeps a directory the new session uses. Runbooks closes the old provider before a resume, so this needs a second detect in one process. The protocol allows that.

Gaps

  • A resume that fails leaves the block's directory until signOut, as before. Runbooks may still hold that login.
  • holds_login decides by path (the state directory's az- child with a profile file), so a symlink named az-<n> there counts as held and az runs through it. Removal removes only the link. Writing one needs write access to the 0700 state directory.

Evidence

  • Each test failed before its fix:
    • env_renews_a_federated_token_file_or_request_within_the_refresh_window, which now checks the detected identity's expiresAt: left: None right: Some(2024-10-04 0:05:01.0 +00:00:00).
    • detect_goes_on_with_the_saved_subscriptions_when_a_refresh_fails: detect failed: ... "kind":"network" ... "az account list --all --refresh failed: Max retries exceeded.".
  • Adding ToolMissing to the cli source's unusable kinds fails only the new case (182 passed, 1 failed), in with_no_az_on_path_detecting_a_credential_is_tool_missing.
  • a_new_process_takes_back_the_blocks_own_login now counts sign-in directories after a resume. Before the fix: left: 2 right: 1.
  • Hand mutants, each failing exactly one test:
    • always copy, and install deleting the directory it installs: a_new_process_takes_back_the_blocks_own_login (183 passed, 1 failed);
    • deleting the block's directory when a resume fails: a_resume_that_fails_leaves_the_login_for_the_next (184 passed, 1 failed).
  • mise run check at 261736a: 507 tests run: 507 passed, 0 skipped, lint clean, semver no publishable crates.
  • Audit dependencies is red, as on main, until the pin-project-lite 0.2.19 lock update.
  • Rebased for the stack, a1eebc2 to 2fc7a1d: the PR's diff has the same git patch-id --stable (09bbd55a5e37) and the same changed lines, tree unchanged.

@odgrim odgrim changed the title Azure: identity expiry, a failed refresh, and toolMissing from the cli source Azure: identity expiry, a failed refresh, toolMissing from the cli source, and resume directories Dec 5, 2026
@odgrim
odgrim force-pushed the track-a/azure-detect-gaps branch from e0812ed to 0b27f6c Compare December 6, 2026 07:03
@odgrim
odgrim force-pushed the track-a/azure-detect-gaps branch from 0b27f6c to 261736a Compare December 6, 2026 07:48
identity.expiresAt is the access token's expiry, as env's expiresAt
is, for a service principal signed in with a federated token. Every
other sign-in az renews itself, so it has none.
A copy of the person's az login is listed with --refresh, to see
subscriptions created since they signed in. When that fails, detect
logs why and lists the subscriptions az already holds, as Runbooks main
did, where it failed the whole detect before.
A person's own az login found with no az to run is toolMissing, as a
values source's already was. No test reached the cli source without az.
A resume copied the block's az directory into a new one and left the
old one, with its tokens, until signOut: one more per restart. The
block's own sign-in directory is now used where it is. Its path stays
the one Runbooks saved, so a resume that ends short of Ready, or a
restart before Runbooks saves again, still finds the login. Any other
directory is still copied.
@odgrim
odgrim force-pushed the track-a/azure-detect-gaps branch from a1eebc2 to 2fc7a1d Compare December 6, 2026 16:03
@odgrim
odgrim added this pull request to stack #118 December 6, 2026 16:04
@odgrim
odgrim marked this pull request as ready for review December 6, 2026 16:14

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