Skip to content

Fix OpenSearchNode working directory to avoid executing in immutable Gradle cache directory#20229

Closed
dbwiddis wants to merge 2 commits intoopensearch-project:mainfrom
dbwiddis:fix-working-dir
Closed

Fix OpenSearchNode working directory to avoid executing in immutable Gradle cache directory#20229
dbwiddis wants to merge 2 commits intoopensearch-project:mainfrom
dbwiddis:fix-working-dir

Conversation

@dbwiddis
Copy link
Copy Markdown
Member

@dbwiddis dbwiddis commented Dec 14, 2025

Description

Modified OpenSearchNode binary execution directory from getDistroDir() to workingDir.toFile() so that all OpenSearch bin scripts run from the node's working directory instead of the Gradle cache directory.

Changed the Unix executable to use absolute paths since we changed the working directory.

Related Issues

Check List

  • Functionality includes testing.
  • [ ] API changes companion pull request created, if applicable.
  • [ ] Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed test cluster startup so tools run from the node working directory and use explicit script paths, preventing failures when executed in immutable or cached build directories.

✏️ Tip: You can customize this high-level summary in your review settings.

@dbwiddis dbwiddis requested a review from a team as a code owner December 14, 2025 01:02
@dbwiddis dbwiddis added the Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. label Dec 14, 2025
@github-actions github-actions bot added the bug Something isn't working label Dec 14, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 14, 2025

Walkthrough

Changed OpenSearchNode so tools are resolved from the distribution's bin directory and processes are started with the node's working directory instead of the extracted distro/Gradle cache directory, preventing writes into the immutable Gradle transform cache.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added entry documenting the fix that avoids executing in the immutable Gradle cache directory.
Script execution logic
buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java
Resolve tool paths from getDistroDir()/bin; set process working directory to the node's workingDir; on Windows use cmd with the resolved absolute .bat path passed as an argument (no reliance on current dir).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect getDistroDir().resolve("bin") usage and Windows .bat resolution for correctness.
  • Verify the process builder's working directory is the node workingDir and that no files are written into the distro/Gradle cache.
  • Run integ tests on Linux/macOS to confirm Gradle immutable workspace is not modified.

Poem

🐰 I hopped where scripts once roamed the cache,

Now I tuck them safe within my patch.
No more marks upon that guarded ground,
Logs at home, not scattered around.
A small tidy hop — peace all around. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing OpenSearchNode's working directory to prevent execution in the immutable Gradle cache.
Description check ✅ Passed The description includes all essential template sections: clear description of changes, related issues, and completed checklist items with DCO confirmation.
Linked Issues check ✅ Passed The code changes address the root cause of issue #20226: preventing OpenSearchNode from executing in the immutable Gradle cache by changing working directory and using absolute paths.
Out of Scope Changes check ✅ Passed All changes in CHANGELOG.md and OpenSearchNode.java are directly scoped to fixing the working directory issue and preventing cache corruption, with no unrelated modifications.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35c5865 and 149bcdb.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: gradle-check
  • GitHub Check: detect-breaking-change
  • GitHub Check: precommit (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, ubuntu-latest)
  • GitHub Check: precommit (25, ubuntu-latest)
  • GitHub Check: precommit (25, windows-latest)
  • GitHub Check: assemble (21, macos-15)
  • GitHub Check: precommit (25, macos-15-intel)
  • GitHub Check: assemble (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, windows-2025, true)
  • GitHub Check: precommit (21, macos-15)
  • GitHub Check: precommit (25, macos-15)
  • GitHub Check: assemble (25, windows-latest)
  • GitHub Check: assemble (21, ubuntu-latest)
  • GitHub Check: precommit (21, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, windows-latest)
  • GitHub Check: Analyze (java)
  • GitHub Check: assemble (25, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (21, windows-latest)
  • GitHub Check: Mend Security Check

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

…ble Gradle cache directory

Signed-off-by: Daniel Widdis <widdis@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for 35c5865: SUCCESS

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 14, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.18%. Comparing base (66ed5cb) to head (35c5865).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...opensearch/gradle/testclusters/OpenSearchNode.java 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #20229      +/-   ##
============================================
+ Coverage     72.82%   73.18%   +0.35%     
- Complexity    71315    71771     +456     
============================================
  Files          5795     5795              
  Lines        328297   328306       +9     
  Branches      47282    47283       +1     
============================================
+ Hits         239089   240276    +1187     
+ Misses        69893    68787    -1106     
+ Partials      19315    19243      -72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

try (InputStream byteArrayInputStream = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8))) {
LoggedExec.exec(project, spec -> {
spec.setEnvironment(getOpenSearchEnvironment());
spec.workingDir(getDistroDir());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When is getDistroDir resolved to the gradle cache? Is that in instances when running integTest against a testcluster that is using the ARCHIVE distribution?

I'm wondering if we should start to remove the restrictions on copying only the transport modules in the INTEG_TEST distribution and then start a campaign across the plugins to use INTEG_TEST which always pulls the latest commit from core without pulling a min distribution though I'm not sure how that would impact test speed.

Let me try to dig up the comment about the distinction of ARCHIVE vs INTEG_TEST.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

When is getDistroDir resolved to the gradle cache? Is that in instances when running integTest against a testcluster that is using the ARCHIVE distribution?

It's reproducible on main using ccr repo, so perhaps you can see if this change fixes it?

In any case, I'm not sure we want to execute in the distro dir and not the working dir...

Signed-off-by: Daniel Widdis <widdis@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 149bcdb: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@dbwiddis dbwiddis added the v3.5.0 Issues and PRs related to version 3.5.0 label Dec 26, 2025
@opensearch-trigger-bot
Copy link
Copy Markdown
Contributor

This PR is stalled because it has been open for 30 days with no activity.

@opensearch-trigger-bot opensearch-trigger-bot bot added the stalled Issues that have stalled label Feb 8, 2026
@dbwiddis
Copy link
Copy Markdown
Member Author

Closing as this has been addressed by a different approach.

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

Labels

bug Something isn't working Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. stalled Issues that have stalled v3.5.0 Issues and PRs related to version 3.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] TestClusters plugin corrupts Gradle 9.x transform cache when canUseSharedDistribution() is true

2 participants