Skip to content

fix(runners): Skip runner file ownership change when user_name is unset - #5574

Merged
guicaulada merged 1 commit into
github-aws-runners:mainfrom
005f:fix/skip-chown-without-user-name
Nov 3, 2026
Merged

guicaulada merged 1 commit into
github-aws-runners:mainfrom
005f:fix/skip-chown-without-user-name

Conversation

@005f

@005f 005f commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

If a custom userdata_template doesn't set user_name, the end of install-runner.sh runs chown -R ":" over /opt/actions-runner and /opt/hostedtoolcache. That changes no owners, but it still visits every file in the tool cache. On a fresh instance the root volume loads lazily from its snapshot, so the walk is slow. On our Ubuntu runners it adds about one to one and a half minutes to each boot. This change skips both chown calls when user_name is empty. When user_name is set, they run as before.

The module's own user-data.sh templates always set user_name, so default setups behave the same.

There is a side effect change: A chown with an empty owner still clears setuid and setgid bits on the files it visits. With this change, those bits stay as they are when user_name is unset. start-runner.sh still changes the owner of /opt/actions-runner to run_as.

Test Plan

  • In an ubuntu:24.04 container, I ran the old and new snippets over a tool cache of 1,000 files and counted chown calls with strace.
    • With user_name unset, the old snippet made 1,009 calls. Owners stayed root:root, and a setuid file lost its setuid bit.
    • With user_name unset, the new snippet made 0 calls. Owners stayed root:root, and the setuid bit stayed.
    • With user_name=ubuntu, both snippets made 1,009 calls and left both trees ubuntu:ubuntu.
  • shellcheck reported no new findings.
  • Runner syslog showed that the "Set file ownership of action runner" step took ~1 minute off run times.

Related Issues

#2302 added user_name to the Ubuntu example so that the tool cache chown works.

@005f
005f marked this pull request as ready for review November 3, 2026 18:23
@005f
005f requested a review from a team as a code owner November 3, 2026 18:23
@guicaulada
guicaulada merged commit 2cf37e5 into github-aws-runners:main Nov 3, 2026
11 of 12 checks passed
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