8000 fix: reset shared ephemeral directories once by dajiaohuang · Pull Request #4727 · ansible/molecule · GitHub
[go: up one dir, main page]

Skip to content

fix: reset shared ephemeral directories once - #4727

Open
dajiaohuang wants to merge 1 commit into
ansible:mainfrom
dajiaohuang:wushuwen-reset-shared-ephemeral-20261024
Open

dajiaohuang wants to merge 1 commit into
ansible:mainfrom
dajiaohuang:wushuwen-reset-shared-ephemeral-20261024

Conversation

@dajiaohuang
@dajiaohuang dajiaohuang commented Oct 24, 2026 •
Copy link
Copy Markdown

Fixes #4717.

When multiple scenarios share an ephemeral directory, reset attempts to remove the same path once per scenario; the second removal fails. Track directories removed during a reset and remove each unique path only once. Use the same helper in serial and worker reset flows.

Validation:

  • Focused regression test test_reset_removes_shared_ephemeral_directory_once: 1 passed in a task-local Python 3.13 environment. A fail-fast fcntl shim was used only to allow collection on Windows; the test does not exercise locking.
  • py_compile passed for the changed Python files.
  • Ruff passed for the production files. The test file passed with INP001 ignored because this sparse checkout lacks package marker files.
  • The full test module was not clean in this sparse Windows checkout: the unmodified project imports POSIX-only fcntl, and this sparse test fixture tree lacks config_instance; with the fail-fast shim, the module reported 7 passed, 2 failures in existing caplog assertions, and 1 fixture error. No integration tests or CI were run.

Summary by CodeRabbit

  • Bug Fixes
    • Resetting scenarios that share an ephemeral directory now removes that directory only once. Separate scenario directories are still removed during reset.

@coderabbitai
coderabbitai Bot commented Oct 24, 2026 •
Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3779448-6207-40ec-8372-c20d1b744554
Commits

Reviewing files that changed from the base of the PR and between e3340ca and 2939ef6.

Files selected for processing: 3
  • src/molecule/command/base.py
  • src/molecule/worker.py
  • tests/unit/command/test_reset.py

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

Walkthrough

Reset cleanup now tracks ephemeral directories removed during a run. The command and worker reset paths use this tracking to avoid removing a shared directory more than once. A unit test covers shared and unique scenario directories.

Changes: Reset cleanup

Layer / File(s) Summary
Track directory removals
src/molecule/command/base.py
A helper skips ephemeral directories that were already removed. The command reset path uses the helper and tracks removals.
Apply tracked cleanup in worker reset
src/molecule/worker.py, tests/unit/command/test_reset.py
The worker reset path uses a shared set and the helper instead of deleting directories directly. A test checks that shared and unique directories are each removed once.

Priority: Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: cidrblock

Merge Risk: Minimal · up to 2939e

Reset with a shared ephemeral directory should now remove it once instead of failing on the second removal. No actionable merge-blocking risk remains; the PR notes that integration tests and CI were not run, which is normal pre-merge verification.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: removing shared ephemeral directories only once during reset.
Linked Issues check Passed Issue #4717 requires serial reset of multiple scenarios with shared state to remove a shared ephemeral directory without a second-removal failure. _run_scenarios now creates one `removed_ephemeral_d…
Out of Scope Changes check Passed The changes are limited to shared ephemeral-directory removal during reset, the reusable helper in src/molecule/command/base.py, its use in the worker reset flow, and a focused regression test. The …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files.
Full details: Linked Issues check

Explanation

Issue #4717 requires serial reset of multiple scenarios with shared state to remove a shared ephemeral directory without a second-removal failure. _run_scenarios now creates one removed_ephemeral_directories set and calls _remove_scenario_ephemeral_directory for each reset scenario. The helper skips paths already in the set, and the regression test verifies one removal for the shared path and one removal for a unique path. Scenario.ephemeral_directory resolves to the shared path when shared state is enabled.

Full details: Out of Scope Changes check

Explanation

The changes are limited to shared ephemeral-directory removal during reset, the reusable helper in src/molecule/command/base.py, its use in the worker reset flow, and a focused regression test. The worker change applies the same reset fix to the parallel flow and supports consistent behavior. No unrelated product behavior is established by the supplied summary or inspected files.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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

8000

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Serial reset --all fails with shared_state: true

1 participant

0