Skip to content

Conversation

yonch
Copy link
Contributor

@yonch yonch commented Aug 7, 2025

Installing packages in the pre-runner-script has been unreliable as it seems during boot there are other processes locking the package index. It appears the recommended way is to use the packages property of cloud-init.

This requires passing a cloud init YAML (starts with #cloud-config) as user data. Luckily this format is supported by AWS.

This PR:

  • writes the pre-runner-script.sh and the main user-data script (runner-setup.sh) using cloud-init's write_files
  • adds a cloud-init packages directive to install packages
  • runs the main script using cloud-init's runcmd

This allows supporting multi-line pre-runner-script.sh. As a bonus, this greatly simplified strange escaping issues stemming from echo "${config.input.preRunnerScript}" > pre-runner-script.sh -- we tried to write a file inside the pre-runner-script which required multiple levels of nested escaping before this change, now this burden is greatly reduced.

Additionally, this PR causes the package, when installing the github runner, to install the latest version. Otherwise I've seen the runner updates itself on load, increasing the startup time. I thought this might be causing some issues while debugging the feature and added this according to github instructions. Since this works, I think we might as well merge this too and enjoy the reduced startup time.

@yonch
Copy link
Contributor Author

yonch commented Aug 14, 2025

There are cases where this change does not work. I'm closing for now, might reopen with updated code.

@yonch yonch closed this Aug 14, 2025
@yonch yonch reopened this Aug 29, 2025
@yonch
Copy link
Contributor Author

yonch commented Aug 29, 2025

Hi @Preen, this is ready for review.

I ran this with workflows that auto-install the runner on:
ubuntu-22.04: https://github.com/yonch/collector/actions/runs/17324943448
ubuntu-24.04: https://github.com/yonch/collector/actions/runs/17325258198

and with a pre-runner script + packages:
https://github.com/yonch/linux/actions/runs/17325392651

@yonch
Copy link
Contributor Author

yonch commented Aug 29, 2025

fyi I re-tested after merging the main branch:

  • with ubuntu-24.04 auto-install
  • custom-runner-install + pre-runner script + packages

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