Skip to content

[RUN-4297] ansible inventory fix#432

Merged
ronaveva merged 3 commits intomainfrom
RUN-4297-inventory
Apr 30, 2026
Merged

[RUN-4297] ansible inventory fix#432
ronaveva merged 3 commits intomainfrom
RUN-4297-inventory

Conversation

@ronaveva
Copy link
Copy Markdown
Contributor

This pull request refactors the handling of temporary working directories in AnsibleRunnerContextBuilder to ensure that each builder instance receives its own exclusive directory, even when multiple builders share the same execution ID (e.g., in parallel workflow steps). This eliminates race conditions where sibling builders could accidentally delete or interfere with each other's files. Extensive new tests are added to verify directory isolation, safe cleanup, and debug mode behavior.

Working directory isolation and cleanup:

  • Each AnsibleRunnerContextBuilder now creates its own unique, builder-specific temp directory under the base tmp dir, with the name format ansible-exec-<executionId>-builder-<rand>/. This prevents conflicts and accidental deletion between parallel builders sharing the same execution ID. [1] [2] [3]
  • Cleanup logic and comments are updated to clarify that recursive deletion is always safe because no files are shared between sibling builders. Debug mode preserves these directories for troubleshooting.

Testing for concurrency and isolation:

  • New tests in AnsibleRunnerContextBuilderSpec.groovy verify that:
    • Builders with the same execution ID get distinct directories.
    • Cleanup in one builder does not affect a sibling's directory or files.
    • Parallel builders do not lose their files due to race conditions.
    • Debug mode preserves builder directories as expected.

Test utilities and setup:

  • Utility methods are added to the test class for creating builders with controlled execution IDs and seeding inventory files, ensuring tests are isolated and reproducible.
  • Test imports and annotations are updated to support temporary directories and concurrency testing.

@ronaveva ronaveva added this to the 6.0.0 milestone Apr 30, 2026
Copilot AI review requested due to automatic review settings April 30, 2026 17:21
@fdevans fdevans requested a review from a team April 30, 2026 17:22
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 updates AnsibleRunnerContextBuilder to avoid temp working-directory collisions when multiple builders share the same Rundeck execution ID (e.g., parallel workflow steps), and adds tests to validate directory isolation and cleanup behavior.

Changes:

  • Make getExecutionSpecificTmpDir() create a unique per-builder temp directory named ansible-exec-<executionId>-builder-<rand>/ under the configured base tmp dir.
  • Update cleanupTempFiles() messaging/docs to reflect builder-exclusive directory ownership and debug-mode preservation.
  • Add Spock tests covering same-execId isolation, sibling cleanup safety, parallel behavior, and debug-mode retention.

Reviewed changes

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

File Description
src/main/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilder.java Switches from shared execution dir to unique builder-specific temp dir creation and updates cleanup semantics/logging.
src/test/groovy/com/rundeck/plugins/ansible/ansible/AnsibleRunnerContextBuilderSpec.groovy Adds tests for directory uniqueness, sibling-safe cleanup, parallel safety, and debug-mode behavior.

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

@ronaveva ronaveva merged commit 4cdb81d into main Apr 30, 2026
6 of 7 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.

3 participants