Skip to content

ci: remove the probe directories the Agent service locks down - #2243

Open
Benoît Cortier (CBenoit) wants to merge 2 commits into
masterfrom
cbenoit-ci-flakes-probe-cleanup
Open

Benoît Cortier (CBenoit) wants to merge 2 commits into
masterfrom
cbenoit-ci-flakes-probe-cleanup

Conversation

@CBenoit

@CBenoit Benoît Cortier (CBenoit) commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

The standard-user probe failed at cleanup with "Access to the path ...\config\identity is denied" when the Agent service had created its identity directory before the probe stopped it: the service gives that directory to LocalSystem alone, so the elevated runner account could not delete it, and whether it existed depended on how far the service got.

Cleanup now removes what the runner account cannot as LocalSystem through PsExec, which the job already installs for its other cleanups, and reports both errors when that fails too.

Copilot AI adaptive review requested due to automatic review settings December 1, 2026 20:34

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 were identified for the restricted probe-directory cleanup changes.

No open issues 🎉

What changed in this PR

This PR makes the Agent’s standard-user CI probe cleanup handle directories restricted to LocalSystem, avoiding failures that depend on how far the service starts.

Changes:

  • Takes ownership and grants Administrators full control before deleting the probe directory tree.
  • Retries cleanup up to four times to reach restricted nested directories.
  • Clears the native-command exit code after successful deletion.
File Description
ci/​agent-service-standard-user-probe.ps1 Adds ownership recovery, permission grants, and bounded retries to probe-directory cleanup.

Review effort: Balanced (adaptive)

The standard-user probe failed at cleanup with "Access to the path
...\config\identity is denied" when the Agent service had created its
identity directory before the probe stopped it: the service gives that
directory to LocalSystem alone, so the elevated runner account could not
delete it, and whether it existed depended on how far the service got.

Cleanup now removes what the runner account cannot through a one-off
scheduled task running as LocalSystem.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@CBenoit
Benoît Cortier (CBenoit) force-pushed the cbenoit-ci-flakes-probe-cleanup branch from 35e96d9 to adf9732 Compare December 1, 2026 20:57
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 20:57

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.

🟡 Changes recommended

The cleanup loop waits a full minute after rd fails and discards its result, obscuring the underlying failure behind a generic timeout.

1 open issue

Review effort: Max (adaptive)

@CBenoit

Benoît Cortier (CBenoit) commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

Evidence: "Probe standard-user access to the LocalSystem Agent service" failed with Directory cleanup failed: Access to the path '...\config\identity' is denied in 46721188251 and 46733043245 (#2240), after the probe itself passed. The identity directory does not always exist by then: in a run that waited 90 s for it before stopping the service, it never appeared and plain removal succeeded.

Verified on a GitHub-hosted runner with a temporary commit (since deleted) that, before cleanup, created a two-level tree under the probe's config directory and gave every entry to LocalSystem alone (icacls /setowner *S-1-5-18, /inheritance:r /grant:r *S-1-5-18:(OI)(CI)F), as the service does (job 142987506386):

  • listing as the runner account: Access to the path '...\config\identity-locked' is denied
  • plain Remove-Item: the same error, the failure seen in CI
  • removal as LocalSystem: the directory is gone, and the step passed; repeated with the final PsExec version in job 143048599978 (PsExec exit code 0, directory gone), after a first version using a one-off scheduled task

Taking ownership with takeown /R /D Y and granting Administrators with icacls /T in passes was tried first and still left identity.json access-denied after four passes (job 142978374822).

Lines changed: production code 0; tests 0; other files (CI script) +17/−1.

UNTESTED property (marked at the code): no run is sure to leave a LocalSystem-only directory, so passing runs may never reach the LocalSystem removal; when changing it, run the probe with such a tree under the config directory and check that cleanup removes it.

Note

LLM-assisted content (no human feedback).

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.

🟡 Changes recommended

A passing probe can leave the SYSTEM cleanup fallback untested, while fallback failures lose scheduled-task results and original removal errors needed for diagnosis.

4 open issues

Review effort: Max (adaptive)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 22:31

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.

🔵 Needs a closer look

The privileged cleanup path requires Windows ACL/PsExec validation against a deliberately LocalSystem-only directory, which ordinary probes do not reliably exercise and this review environment cannot verify.

No open issues 🎉

4 resolved since last review

Review effort: Balanced (adaptive)

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

Development

Successfully merging this pull request may close these issues.

2 participants