Skip to content

test(e2e): wait for docker env cleanup#9631

Merged
jdx merged 1 commit intojdx:mainfrom
risu729:fix/e2e-docker-temp-cleanup
May 6, 2026
Merged

test(e2e): wait for docker env cleanup#9631
jdx merged 1 commit intojdx:mainfrom
risu729:fix/e2e-docker-temp-cleanup

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented May 5, 2026

Summary

  • wait for successful e2e test environment cleanup when the test is running inside Docker
  • keep asynchronous cleanup outside Docker so local/non-Docker runs keep the existing fast path
  • remove the need for a second cleanup container that chmods the Docker bind mounts

Context

#9570 changed Docker e2e runs to bind-mount host-backed directories for /tmp and /root instead of using tmpfs. Inside the container, mktemp -d creates root-owned 0700 per-test directories under the bind-mounted /tmp.

For successful tests, e2e/run_test previously started rm -rf "$TEST_ISOLATED_DIR" in the background. When the Docker container exits before that background cleanup reliably finishes, root-owned 0700 test directories can be left behind on the host mount. The outer host-side cleanup then emits permission noise such as rm: cannot remove.

Waiting for rm -rf only when MISE_E2E_INSIDE_DOCKER=1 fixes the source of that host-side cleanup noise without running a second container or broadly chmodding both mounts.

Failed tests keep the existing behavior: the isolated test environment is left in place and reported for inspection, and the returned test status remains unchanged.

Tests

  • git diff --check
  • bash -n e2e/run_test
  • mise x shellcheck -- shellcheck -x e2e/run_test
  • mise x shfmt -- shfmt -d e2e/run_test
  • MISE_E2E_DOCKER=1 E2E_WAIT_FOR_GH_RATE_LIMIT=0 mise run test:e2e e2e/cli/test_version
    • verified captured output had no rm: cannot remove lines

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a cleanup_docker_mounts function within the run_in_docker routine to resolve permission issues when deleting Docker-mounted directories. The reviewer suggests implementing a trap to ensure that cleanup is performed even if the script is interrupted by signals like SIGINT, preventing leftover root-owned directories.

Comment thread e2e/run_test Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

This PR fixes a race condition in Docker-based e2e tests where root-owned files created inside the container could not be removed by the host runner after the container exited, causing cleanup errors to mask a passing test status under set -euo pipefail.

  • Changes remove_isolated_env to perform a synchronous rm -rf (dropping the trailing &) when running inside Docker, so all test-created files are removed by the container's root process before Docker exits — leaving the host-side bind-mount directories empty and reliably removable.
  • The non-Docker path retains the background cleanup (&) for performance, preserving existing behavior on local and non-namespaced runners.

Confidence Score: 5/5

Safe to merge — the change is a one-function, two-branch fix to a shell cleanup helper with no risk to test logic or production code.

The change is minimal and targeted: a single conditional added to remove_isolated_env that switches between synchronous and background cleanup based on a well-scoped environment variable. The fix correctly addresses the root cause — files created inside Docker as root need to be cleaned up from within the container before it exits, otherwise the host runner cannot remove them under set -e. All other code paths are unaffected.

No files require special attention.

Reviews (2): Last reviewed commit: "test(e2e): wait for docker env cleanup" | Re-trigger Greptile

@risu729 risu729 force-pushed the fix/e2e-docker-temp-cleanup branch from 9bf372b to 40221f8 Compare May 6, 2026 13:01
@risu729 risu729 changed the title test(e2e): clean docker temp mounts as host test(e2e): wait for docker env cleanup May 6, 2026
@risu729
Copy link
Copy Markdown
Contributor Author

risu729 commented May 6, 2026

CI note: windows-e2e failed in zig.executes zig 2024.11.0-mach because both attempts timed out fetching https://pkg.hexops.org/zig/zig-windows-x86_64-0.14.0-dev.2577+271452d22.zip on the Windows runner. This is unrelated to the Docker e2e cleanup change in e2e/run_test; the Linux Docker e2e shards all passed, and the local Docker smoke output had no rm: cannot remove lines.

The aggregate test-ci check is red only because windows-e2e is red. I attempted to rerun the failed job, but GitHub rejected it because this account does not have repository admin rights.

This comment was generated by an AI coding assistant.

@risu729 risu729 marked this pull request as ready for review May 6, 2026 13:29
@jdx jdx merged commit c2791ed into jdx:main May 6, 2026
33 of 35 checks passed
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