Skip to content

templates: report idle before starting the runner service (gitea linux) - #976

Open
fernvenue wants to merge 1 commit into
cloudbase:mainfrom
fernvenue:template-report-idle-before-start
Open

fernvenue wants to merge 1 commit into
cloudbase:mainfrom
fernvenue:template-report-idle-before-start

Conversation

@fernvenue

Copy link
Copy Markdown

Refs #971.

In non-agent mode the install template starts the runner service (systemctl enable --now) and only afterwards reads the agent ID and reports idle. An ephemeral runner can pick up an already-queued job in between: the forge reports the job in_progress, garm marks the runner active, and the final idle status callback is then rejected with 401 by the instance middleware, because the runner is no longer installing/pending. garm never records the agent ID.

This moves the agent ID lookup, the system-info report and the idle status report before systemctl enable --now, as suggested on #971. Agent mode is unchanged.

Tested on a self-hosted Gitea (latest) with an external ECS provider, non-agent mode, by applying the same reordering to a copy of this template: the final status callback returns 200 instead of 401, the runner goes pending -> installing -> active with its agent ID recorded, and the job completes. Agent mode was not tested.

Trade-off: idle is now reported before the service is started. If systemctl enable --now fails afterwards, garm cannot be told, because the runner status transitions do not allow idle -> failed.

Only the Gitea Linux template is changed. The GitHub Linux template appears to share the ordering (svc.sh start comes before reading .runner and the idle report), but I have not changed or tested it.

Not addressed here: job never got assigned to a runner, ignoring is still logged from handleCompletedJob when the completed event carries an empty runner name. That is separate from the 401.

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