Skip to content

feat(runner): lock workdir to prevent concurrent testruns#3441

Merged
mkoura merged 1 commit intomasterfrom
acquire_workdir_lock
Apr 30, 2026
Merged

feat(runner): lock workdir to prevent concurrent testruns#3441
mkoura merged 1 commit intomasterfrom
acquire_workdir_lock

Conversation

@mkoura
Copy link
Copy Markdown
Collaborator

@mkoura mkoura commented Apr 30, 2026

Add acquire_workdir_lock that grabs a non-blocking flock on .lock at the start of regression.sh and node_upgrade.sh. The lock file lives next to the workdir so wiping the workdir does not drop the lock, and the fd is held by the calling shell so the kernel releases the lock automatically on exit. Pull util-linux into the base devShell so flock is available.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a workdir-based locking mechanism to prevent concurrent runner invocations (e.g., regression and upgrade runs) from clobbering the same run_workdir, and ensures the required flock utility is available in the Nix dev shell.

Changes:

  • Add acquire_workdir_lock <workdir> in scripts/common.sh using a non-blocking flock on <workdir>.lock.
  • Call acquire_workdir_lock "$WORKDIR" early in runner/regression.sh and runner/node_upgrade.sh.
  • Add util-linux to devShells.base so flock is available.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/common.sh Adds acquire_workdir_lock helper to enforce exclusive use of a workdir.
runner/regression.sh Acquires workdir lock before proceeding with run setup/cleanup.
runner/node_upgrade.sh Acquires workdir lock before proceeding with run setup/cleanup.
flake.nix Adds util-linux to base dev shell inputs to provide flock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/common.sh Outdated
Comment thread scripts/common.sh Outdated
Comment thread scripts/common.sh Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a workdir-level lock to runner scripts to prevent concurrent test runs from clobbering the shared run_workdir, and ensures flock is available in the Nix base dev environment.

Changes:

  • Introduce acquire_workdir_lock <workdir> in scripts/common.sh using a non-blocking flock on <workdir>.lock.
  • Invoke the lock helper early in runner/regression.sh and runner/node_upgrade.sh before workdir cleanup/creation.
  • Add util-linux to devShells.base so flock is present under nix develop .#base.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
scripts/common.sh Adds acquire_workdir_lock helper for non-blocking exclusive locking via flock.
runner/regression.sh Acquires the workdir lock before stopping/cleaning the workdir.
runner/node_upgrade.sh Acquires the workdir lock before stopping/cleaning the workdir and running upgrade steps.
flake.nix Adds util-linux to base shell inputs to provide flock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/common.sh
Comment thread scripts/common.sh
Add acquire_workdir_lock that grabs a non-blocking flock on
<workdir>.lock at the start of regression.sh and node_upgrade.sh.
The lock file lives next to the workdir so wiping the workdir does
not drop the lock, and the fd is held by the calling shell so the
kernel releases the lock automatically on exit. Pull util-linux into
the base devShell so flock is available.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a workdir-level locking mechanism in the runner scripts to prevent concurrent test runs from clobbering the same $WORKDIR, and ensures the required flock dependency is available in the Nix dev environment.

Changes:

  • Add acquire_workdir_lock helper in scripts/common.sh to take an exclusive, non-blocking lock on <workdir>.lock.
  • Call the lock helper early in runner/regression.sh and runner/node_upgrade.sh to refuse concurrent runs on the same workdir.
  • Add util-linux to the base devShell (for flock) and add an explicit WORKDIR requirement in runner/node_upgrade_pytest.sh.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/common.sh Adds acquire_workdir_lock helper built on flock.
runner/regression.sh Acquires the workdir lock before doing any workdir cleanup/use.
runner/node_upgrade.sh Acquires the workdir lock before cleanup and running upgrade steps.
runner/node_upgrade_pytest.sh Adds an explicit assertion that WORKDIR is set.
flake.nix Adds util-linux to the base devShell inputs to provide flock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/common.sh
@mkoura mkoura merged commit c7c48a7 into master Apr 30, 2026
6 checks passed
@mkoura mkoura deleted the acquire_workdir_lock branch April 30, 2026 15:49
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