Skip to content

[Build Tools] Custom Gradle plugin to leverage java agent #17900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2025

Conversation

prudhvigodithi
Copy link
Member

@prudhvigodithi prudhvigodithi commented Apr 11, 2025

Description

To Support phasing off SecurityManager usage in favor of Java Agent a custom Gradle plugin from core should help leverage the java agent.

Coming from opensearch-project/custom-codecs#235 (comment) created a custom java agent plugin that can be applied as required. The plugins can use as apply plugin: 'opensearch.java-agent'. With this we can remove the duplicate code across plugins.

I have tested by adding apply plugin: 'opensearch.java-agent' to job-scheduler and now able to run the tests depend on java agent.

Related Issues

Part of #16634 and #16753

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.

@prudhvigodithi
Copy link
Member Author

Adding @reta @cwperks @kumargu @andrross @getsaurabh02 to please take a look and provide some feedback.

@prudhvigodithi prudhvigodithi force-pushed the agent branch 2 times, most recently from 6c50ebc to c5a2ed7 Compare April 11, 2025 01:04
Copy link
Contributor

❌ Gradle check result for c5a2ed7: 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?

Signed-off-by: Prudhvi Godithi <[email protected]>
Copy link
Contributor

✅ Gradle check result for 77ba174: SUCCESS

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 45.83333% with 13 lines in your changes missing coverage. Please review.

Project coverage is 72.49%. Comparing base (1628152) to head (0c652ee).
Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
...in/java/org/opensearch/gradle/agent/JavaAgent.java 45.83% 12 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17900      +/-   ##
============================================
+ Coverage     72.43%   72.49%   +0.05%     
- Complexity    66789    66835      +46     
============================================
  Files          5449     5452       +3     
  Lines        309085   309170      +85     
  Branches      44979    44989      +10     
============================================
+ Hits         223899   224121     +222     
+ Misses        66906    66702     -204     
- Partials      18280    18347      +67     

☔ 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.

@prudhvigodithi prudhvigodithi added the v3.0.0 Issues and PRs related to version 3.0.0 label Apr 11, 2025
@prudhvigodithi
Copy link
Member Author

prudhvigodithi commented Apr 11, 2025

Following changes can be reverted once we have the changes part of the gradle plugin.

Thanks
@peterzhuamazon

@kumargu
Copy link
Contributor

kumargu commented Apr 11, 2025

can they coexist and we revert the above tomorrow? Once we know the change in core works for all plugins?

@peterzhuamazon
Copy link
Member

There are more, but for now we can just merge all plugin individual changes and at least bring RC1 up.

Thanks.

@prudhvigodithi
Copy link
Member Author

can they coexist and we revert the above tomorrow? Once we know the change in core works for all plugins?

From the PR's a task prepareAgent was added which core already has one https://github.com/search?q=repo%3Aopensearch-project%2FOpenSearch%20prepareAgent&type=code.

So in this custom plugin I have used prepareJavaAgent, so I assume for plugins they can co-exist. But I would go with reverting the code and just use apply plugin: 'opensearch.java-agent' as required.

@prudhvigodithi prudhvigodithi changed the title [Draft] Custom Gradle plugin to leverage the java agent Custom Gradle plugin to leverage the java agent Apr 11, 2025
@prudhvigodithi prudhvigodithi changed the title Custom Gradle plugin to leverage the java agent Custom Gradle plugin to leverage java agent Apr 11, 2025
@prudhvigodithi prudhvigodithi marked this pull request as ready for review April 11, 2025 20:15
Signed-off-by: Prudhvi Godithi <[email protected]>
@prudhvigodithi
Copy link
Member Author

Just testing one more thing looks like https://github.com/opensearch-project/OpenSearch/blob/main/libs/agent-sm/agent/build.gradle#L14 we already have net.bytebuddy:byte-buddy dependency here we dont need to explicitly add again. Will post my test results shortly

@prudhvigodithi
Copy link
Member Author

Just testing one more thing looks like https://github.com/opensearch-project/OpenSearch/blob/main/libs/agent-sm/agent/build.gradle#L14 we already have net.bytebuddy:byte-buddy dependency here we dont need to explicitly add again. Will post my test results shortly

I can see the tests pass on my local and on a sample test PR opensearch-project/job-scheduler#761.

Copy link
Contributor

❕ Gradle check result for 0c652ee: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@andrross andrross merged commit 5a0d5c5 into opensearch-project:main Apr 11, 2025
31 of 32 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Performance Roadmap Apr 11, 2025
@prudhvigodithi prudhvigodithi changed the title Custom Gradle plugin to leverage java agent [Build Tools] Custom Gradle plugin to leverage java agent Apr 14, 2025
rgsriram pushed a commit to rgsriram/OpenSearch that referenced this pull request Apr 15, 2025
Harsh-87 pushed a commit to Harsh-87/OpenSearch that referenced this pull request May 7, 2025
Harsh-87 pushed a commit to Harsh-87/OpenSearch that referenced this pull request May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog v3.0.0 Issues and PRs related to version 3.0.0
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants