Skip to content

test(e2e): write stack Compose files from a container so macOS VMs read them whole - #893

Merged
magrhino merged 4 commits into
mainfrom
fix/e2e-macos-compose-writes
Oct 16, 2026
Merged

magrhino merged 4 commits into
mainfrom
fix/e2e-macos-compose-writes

Conversation

@magrhino

Copy link
Copy Markdown
Owner

Summary

tests/e2e-docker-compose.sh failed on macOS with OrbStack in the stack-recreate scenario: the updater logged "Could not verify whether selected services are running; the update was not applied." The cause is in the test harness, not the updater. The harness rewrote the stack's docker-compose.yml from the host after an updater container had already rewritten it. On a macOS Docker VM, containers then kept seeing the old file size for a few seconds. The next updater read the new file cut off at the old size, Compose rejected it, and WUDup correctly refused to update.

What the run showed:

  • Error report: phase=preflight, reason=runtime-state-unavailable, note=Compose project identity is unavailable. Stack discovery's docker compose -f docker-compose.yml config --format json had failed with services.sidecar.depends_on.app must be a mapping.
  • Right before the updater ran, the compose file was 481 bytes on the host, but a plain alpine container saw 326 bytes and the same inode. 326 bytes is the digest-pinned file the previous scenario's updater wrote, and cutting the new file at 326 bytes ends at depends_on: / app:.
  • A standalone replay with only alpine and the wudup image reproduces it. A container writes the file and stays running a few seconds, the host rewrites the file, and the next container still reads the old size. If the writing container exits immediately, the host rewrite shows up right away. Container-to-host writes were always visible immediately.
  • The macOS /var → /private/var symlink hypothesis was ruled out: the Compose working_dir and config_files labels matched the paths the updater used.

Change:

  • write_stack_compose_file writes the stack Compose files from a container running as the host user, the same way write_volume_file already writes volume files. All writes then happen on the same side of the file share as the updater, and the file owner stays the same as before. Writing to a temp file and renaming it on the host did not fix this, because containers kept resolving the path to the old inode.

Scope

  • This PR has one reviewable objective
  • Follow-up work, stacked PRs, or intentionally deferred changes are called out here: no product change. The updater already fails closed when it reads a cut-off Compose file. The OrbStack coherence behavior is outside WUDup.

Checklist

  • Tests added or updated: N/A - test harness fix only; the failing e2e scenario is the regression check
  • README.md or docs/ updated if install, deployment, config, or user-facing behavior changed: N/A - no user-facing change
  • docs/examples/template.env or docs/examples/webui.env.example updated if environment variables or example config changed: N/A
  • Release Please/changelog impact considered; no manual CHANGELOG.md edit needed outside release prep

Test plan

  • tests/run-all.sh: N/A - only the Docker E2E harness changed

  • Focused test(s):

    • bash -n tests/e2e-docker-compose.sh
    • shellcheck tests/e2e-docker-compose.sh
  • Docker or Compose validation, if container behavior changed:

    • tests/e2e-docker-compose.sh on macOS with OrbStack 2.2.4 (Docker 29.8.2, API 1.56): failed before the change; passed after it, three times with a prebuilt image and once with the script's own build
    • CI docker e2e (Linux): pending on this PR

…ad them whole

On macOS Docker VMs (seen with OrbStack 2.2.4), once a container has written a bind-mounted file, later host-side rewrites of that file can stay invisible to new containers for a few seconds. The stack-recreate scenario rewrote docker-compose.yml from the host right after the digest-pin updater had rewritten it from a container, so the next updater read the new file cut off at the old size, Compose rejected it, and the runtime-state preflight failed closed. Write the stack Compose files from a container as the host user, like write_volume_file does for volumes.
@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The E2E harness now writes generated Compose files from a host-user container, matching the updater’s file-share side and preventing macOS/OrbStack stale-size reads during stack recreation without changing product behavior.

File-Level Changes

Change Details Files
Route all generated stack Compose-file writes through a container on the same side of the Docker file share as the updater.
  • Added a shared writer that bind-mounts the stack directory, streams stdin into the Compose path, and runs with the host UID/GID.
  • Updated each Compose fixture generator to use the shared container-based writer instead of a host-side heredoc.
  • Preserved existing ownership and avoided host-side inode replacement behavior implicated in macOS VM coherence issues.
tests/e2e-docker-compose.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b86371b-3d6e-4ae0-ad57-0e211beb9726
📥 Commits

Reviewing files that changed from the base of the PR and between 734fee8 and 5a4a1e1.

📒 Files selected for processing: 1
  • tests/e2e-docker-compose.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Compose-file generation now creates the file on the host if it is absent, then writes its contents from an image container with the stack directory mounted. The five Compose-writing functions use this helper. Unchanged, the generated Compose contents are.

Changes: Compose file generation

Layer / File(s) Summary
Shared Compose writer
tests/e2e-docker-compose.sh
A new helper creates the Compose file if absent and writes its contents from an image container with the stack directory mounted. All five Compose-writing functions now delegate to this helper. The generated Compose contents remain unchanged.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5a4a1

No actionable merge-blocking issue is established for this test-harness change.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed PASS: Clear and specific, the title accurately identifies the e2e harness change and the macOS file-visibility problem it addresses.
Description check Passed PASS: Complete and relevant, the description explains the failure, root cause, implementation, scope, checklist decisions, focused tests, Docker validation, and pending CI status.
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.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/e2e-docker-compose.sh" line_range="412" />
<code_context>
+# Writing from a container keeps every write on the updater's side of the file
+# share; running as the host user keeps the file owner unchanged.
+write_stack_compose_file(){
+  docker run -i --rm --user "$(id -u):$(id -g)" -v "$STACK_DIR:$STACK_DIR" "$IMAGE" \
+    bash -c 'cat > "$1"' _ "$COMPOSE_FILE"
+}
</code_context>
<issue_to_address>
**Compose file write fails**

When the e2e test runs with a rootless or user-namespace-remapped Docker daemon, `write_stack_compose_file` runs `docker` with the host UID/GID, which the daemon maps to subordinate host IDs. Then `cat > "$1"` cannot create or truncate `docker-compose.yml`, so the e2e script stops before its scenarios run.

Run the writer in a way that gives it write access to the bind-mounted directory under these daemon mappings.

Also at `tests/e2e-docker-compose.sh:413`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: tests/e2e-docker-compose.sh:412


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/e2e-docker-compose.sh Outdated
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ad them whole

On macOS Docker VMs (seen with OrbStack 2.2.4), once a container has written a bind-mounted file, later host-side rewrites of that file can stay invisible to new containers for a few seconds. The stack-recreate scenario rewrote docker-compose.yml from the host right after the digest-pin updater had rewritten it from a container, so the next updater read the new file cut off at the old size, Compose rejected it, and the runtime-state preflight failed closed. Write the stack Compose files from a container as the host user, like write_volume_file does for volumes.
@magrhino
magrhino force-pushed the fix/e2e-macos-compose-writes branch from e57f90c to db6b90a Compare October 16, 2026 22:38
…to fix/e2e-macos-compose-writes

# Conflicts:
#	tests/e2e-docker-compose.sh
@sonarqubecloud

Copy link
Copy Markdown

@magrhino
magrhino merged commit e3817d3 into main Oct 16, 2026
25 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.

1 participant