Skip to content

fix(image): run the GARM agent in a PAM login session - #245

Merged
cbartz merged 3 commits into
mainfrom
fix/runner-xdg-runtime-dir
Oct 9, 2026
Merged

cbartz merged 3 commits into
mainfrom
fix/runner-xdg-runtime-dir

Conversation

@cbartz

@cbartz cbartz commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Applicable spec: N/A

Overview

Adds a systemd drop-in that runs garm-agent.service in a PAM login session (PAMName=su-l), next to the existing loginctl enable-linger that keeps /run/user/<uid> alive.

Rationale

In agent mode GARM starts the runner from garm-agent.service, a system service with User=runner and no login session, so jobs inherit no XDG_RUNTIME_DIR. Tools that keep per-user state there then fall back to the root-owned /run/containers, e.g. skopeo login fails with mkdir /run/containers: permission denied. The previous runner manager started the runner via su -, which provided a session; PAMName=su-l restores that session (XDG_RUNTIME_DIR, DBUS_SESSION_BUS_ADDRESS, pam_env, pam_limits) rather than a single variable. su-l rather than login avoids the TTY-oriented modules (pam_motd on every agent restart, the removed pam_lastlog). The drop-in can exist before the unit; systemd applies it once GARM's userdata installs garm-agent.service. This targets GARM's agent mode, which the GARM charm enables; runners GARM starts in non-agent mode (via svc.sh, as actions.runner.<…>.service) are not covered. Verified on Ubuntu 24.04 / systemd 255 with a unit shaped like garm-agent: jobs see XDG_RUNTIME_DIR=/run/user/1000, and restarts open a fresh session and close the old one.

Supersedes canonical/github-runner-operators#415, which set XDG_RUNTIME_DIR from the GARM charm instead: the session setup (linger) belongs together in the image.

Juju Events Changes

None.

Module Changes

cloud-init.sh.j2 (configure_system_users): write the drop-in. Unit test expectation and an integration check on the built image updated accordingly.

Library Changes

None.

Checklist

Charmhub documentation: no charm behaviour or configuration change. Label: to be set by the author (urgent).

cbartz added 2 commits October 8, 2026 14:20
GARM's agent mode starts the runner from garm-agent.service, a system service
without a login session, so jobs inherit no XDG_RUNTIME_DIR. Tools that keep
per-user state there (skopeo, podman, buildah) then fall back to the root-owned
/run/containers and fail. Add a systemd drop-in pointing it at /run/user/<uid>,
which lingering already keeps alive.

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

The drop-in correctly complements user lingering, and the focused tests cover its generated and installed configuration.

0 open findings

What changed in this PR

Adds an image-level systemd drop-in so GARM runner jobs receive a valid XDG_RUNTIME_DIR.

Changes:

  • Configures XDG_RUNTIME_DIR using the runner’s shared UID.
  • Adds unit and image integration coverage.
  • Updates the changelog and package version.
File Description
docs/​changelog.md Documents the GARM runtime-directory fix.
app/​tests/​unit/​test_openstack_builder.py Updates generated cloud-init expectations.
app/​tests/​integration/​commands.py Verifies the drop-in on built images.
app/​src/​github_runner_image_builder/​templates/​cloud-init.sh.j2 Creates the systemd environment drop-in.
app/​pyproject.toml Bumps the application version to 0.14.3.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@cbartz
cbartz marked this pull request as ready for review October 8, 2026 14:29
Comment thread app/tests/unit/test_openstack_builder.py Outdated
Setting XDG_RUNTIME_DIR alone restores one piece of what the previous runner
manager's su - provided. A PAMName=su-l drop-in restores the session itself
(XDG_RUNTIME_DIR, the user D-Bus bus, pam_env, pam_limits), without the
TTY-oriented modules of the login stack.
@cbartz cbartz changed the title fix(image): set XDG_RUNTIME_DIR for the GARM agent fix(image): run the GARM agent in a PAM login session Oct 8, 2026
@cbartz
cbartz requested a balanced review from Copilot October 8, 2026 14:40

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

The focused configuration change is consistent with GARM’s unit lifecycle and is covered by unit and integration checks.

0 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@yanksyoon yanksyoon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should add this to the image building repository as well? Lgtm

@cbartz

cbartz commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Do you think we should add this to the image building repository as well? Lgtm

yes we should as well

@cbartz
cbartz merged commit bc2d11a into main Oct 9, 2026
75 of 111 checks passed
@cbartz
cbartz deleted the fix/runner-xdg-runtime-dir branch October 9, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants