Skip to content

Fix randomly failing build.sh test - #587

Merged
edolstra merged 2 commits into
mainfrom
require-sandbox
Aug 5, 2026
Merged

Fix randomly failing build.sh test#587
edolstra merged 2 commits into
mainfrom
require-sandbox

Conversation

@edolstra

@edolstra edolstra commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Fix random failures in build.sh in GHA, e.g. https://github.com/DeterminateSystems/nix-src/actions/runs/30926645783/job/92052907077.

Context

Summary by CodeRabbit

  • Tests
    • Improved functional test reliability in environments where sandboxing or unprivileged user namespaces are unavailable.
    • Tests now skip gracefully when required system capabilities are not supported.
    • Updated build and flake-check scenarios to avoid unintended sandbox fallbacks.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request August 5, 2026 10:40 Inactive
These fail randomly in GHA with messages like

  builder-fast-fail.sh: line 3: /cancelled-builds-fifo/fifo: No such file or directory

that suggest that the sandbox was not actually set up properly. This
could happen if the clone() call in mountAndPidNamespacesSupported()
fails under load. So let's ensure an explicit error message in that
case.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes centralize unprivileged user namespace detection and update cancelled-builds functional tests to run only with supported namespaces and without sandbox fallback.

Changes

Cancelled-builds functional tests

Layer / File(s) Summary
Centralize namespace capability detection
tests/functional/common/functions.sh
Adds unprivilegedUserNamespacesSupported() and uses it from requiresUnprivilegedUserNamespaces().
Require sandboxing for cancellation checks
tests/functional/build.sh
Adds the namespace capability guard and passes --no-sandbox-fallback to the nix flake check and nix build commands.

Estimated code review effort: 1 (Trivial) | ~4 minutes

Suggested reviewers: xokdvium

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the randomly failing build.sh test addressed by the changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch require-sandbox

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/functional/build.sh (1)

221-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Label the namespace-limit diagnostics.

cat writes two bare values to stderr. If one /proc file is unavailable, the output does not identify which value belongs to max_user_namespaces or max_pid_namespaces. Print each limit name with its value.

Proposed diagnostic format
-    cat /proc/sys/user/max_user_namespaces /proc/sys/user/max_pid_namespaces >&2 || true
+    for limit in max_user_namespaces max_pid_namespaces; do
+        printf '%s=' "$limit" >&2
+        cat "/proc/sys/user/$limit" >&2 || printf '<unavailable>' >&2
+        printf '\n' >&2
+    done
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/functional/build.sh` at line 221, Update the namespace-limit diagnostic
near the existing /proc reads to print each limit’s name together with its
value, while retaining the best-effort behavior when either file is unavailable.
Ensure max_user_namespaces and max_pid_namespaces remain distinguishable in
stderr output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/functional/build.sh`:
- Line 221: Update the namespace-limit diagnostic near the existing /proc reads
to print each limit’s name together with its value, while retaining the
best-effort behavior when either file is unavailable. Ensure max_user_namespaces
and max_pid_namespaces remain distinguishable in stderr output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 88c4f79f-bb12-46d2-8594-443ed732a312

📥 Commits

Reviewing files that changed from the base of the PR and between e8f0c5f and e196a67.

📒 Files selected for processing (1)
  • tests/functional/build.sh

@github-actions
github-actions Bot temporarily deployed to pull request August 5, 2026 11:31 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request August 5, 2026 12:06 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/libutil/linux/linux-namespaces.cc`:
- Around line 76-81: Update the namespace probe error handling around
startProcess(), pid.wait(), and the child status checks to distinguish status 1
mount-namespace failures from status 2 /proc remount PID-namespace failures.
Ensure SysError messages are not always labeled as mount namespace failures;
report the specific failed operation when known, or use a neutral “namespace
probe failed” message.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19977531-95e0-4e7a-9a61-e412179e533d

📥 Commits

Reviewing files that changed from the base of the PR and between e196a67 and 75616d6.

📒 Files selected for processing (2)
  • src/libutil/linux/linux-namespaces.cc
  • tests/functional/build.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/functional/build.sh

Comment thread src/libutil/linux/linux-namespaces.cc Outdated
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions
github-actions Bot temporarily deployed to pull request August 5, 2026 12:27 Inactive
@edolstra edolstra changed the title Diagnose randomly failing build.sh test Fix randomly failing build.sh test Aug 5, 2026
@edolstra
edolstra enabled auto-merge August 5, 2026 13:39
@edolstra
edolstra added this pull request to the merge queue Aug 5, 2026
Merged via the queue into main with commit a529555 Aug 5, 2026
33 checks passed
@edolstra
edolstra deleted the require-sandbox branch August 5, 2026 14:16
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