Revert "chore(cleanup): lxc-helpers does not need a global lock (#1047)" #1103

Merged
earl-warren merged 1 commit from earl-warren/runner:wip-lock into main 2025-10-20 21:05:06 +00:00
Contributor

This reverts commit 996ac343ee.

The lock is still needed to guard against the following scenario.

function build_template_act() {
local name="$(template_act)"
if lxc_exists_and_apt_not_old $name ; then
return 0
fi
lxc_build_template $(lxc_template_release) $name
lxc_container_start $name
install_nodejs $name
lxc_container_stop $name
}

  • two or more jobs start
  • one of them creates the act template (lxc_build_template $(lxc_template_release) $name) - lxc-helpers now has transactions and they won't race against each other
  • once it is built all jobs will then try to install node in the container that was just built and race against each other

with a global lock only the first one will build and populate the act template. The other will then do nothing because it already exists.

The bug can trivially be reproduced with:

on:
  pull_request:

jobs:
  test1:
    runs-on: lxc
    steps:
      - run: echo OK1
  test2:
    runs-on: lxc
    steps:
      - run: echo OK2
  test3:
    runs-on: lxc
    steps:
      - run: echo OK3
  • other
    • PR: Revert "chore(cleanup): lxc-helpers does not need a global lock (#1047)"
This reverts commit 996ac343ee155a4b47d89a6bf1854feb1c04fdb2. The lock is still needed to guard against the following scenario. https://code.forgejo.org/forgejo/runner/src/commit/d92a892ecebb7d5d362f252c487635c1fb9a4c6e/act/runner/run_context.go#L225-L236 - two or more jobs start - one of them creates the act template (`lxc_build_template $(lxc_template_release) $name`) - lxc-helpers now has transactions and they won't race against each other - once it is built all jobs will then try to install node in the container that was just built and race against each other with a global lock only the first one will build and populate the act template. The other will then do nothing because it already exists. The bug can trivially be reproduced with: ```yaml on: pull_request: jobs: test1: runs-on: lxc steps: - run: echo OK1 test2: runs-on: lxc steps: - run: echo OK2 test3: runs-on: lxc steps: - run: echo OK3 ``` <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/1103): <!--number 1103 --><!--line 0 --><!--description UmV2ZXJ0ICJjaG9yZShjbGVhbnVwKTogbHhjLWhlbHBlcnMgZG9lcyBub3QgbmVlZCBhIGdsb2JhbCBsb2NrICgjMTA0Nyki-->Revert "chore(cleanup): lxc-helpers does not need a global lock (#1047)"<!--description--> <!--end release-notes-assistant-->
earl-warren force-pushed wip-lock from 6a24559a4a
All checks were successful
cascade / forgejo (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
checks / validate pre-commit-hooks file (pull_request) Successful in 1m8s
checks / validate mocks (pull_request) Successful in 1m51s
checks / build and test (pull_request) Successful in 5m6s
checks / runner exec tests (pull_request) Successful in 48s
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / runner integration tests (pull_request) Successful in 7m4s
checks / integration tests (pull_request) Successful in 13m57s
to badc918e60
All checks were successful
checks / build and test (pull_request) Successful in 1m37s
issue-labels / release-notes (pull_request_target) Successful in 18s
checks / validate mocks (pull_request) Successful in 2m16s
checks / validate pre-commit-hooks file (pull_request) Successful in 1m33s
checks / runner exec tests (pull_request) Successful in 53s
checks / runner integration tests (pull_request) Successful in 9m34s
checks / integration tests (pull_request) Successful in 19m21s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 5s
cascade / forgejo (pull_request_target) Successful in 2m38s
2025-10-20 15:19:10 +00:00
Compare
viceice approved these changes 2025-10-20 16:25:10 +00:00
earl-warren deleted branch wip-lock 2025-10-20 21:05:06 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
forgejo/runner!1103
No description provided.