Skip to content
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

Override Default Distribution Download Url with Custom Distribution Url when it is passed from Plugin #2420

Merged
merged 8 commits into from
Mar 15, 2022

Conversation

Rishikesh1159
Copy link
Member

@Rishikesh1159 Rishikesh1159 commented Mar 9, 2022

Description

This PR overrides default distribution url with custom distribution url passes by user from plugin.

Issues Resolved

#1240

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 8205a2a
Log 3203

Reports 3203

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

How does this fix the issue that caused the revert?

@Rishikesh1159
Copy link
Member Author

I was able to root cause failure in Alerting plugin. In order to fix this issue #1240, in my previous PR I moved call to setupDownloadServiceRepo() in DistributionDownloadPlugin.java from apply() method to setupDistributions() method, which is called in afterEvaluate(). Here is previous PR: #2086 which is reverted.

-> This change made to setup repo at the end of configuration phase [One of gradle life cycle process] after entire root and sub projects are configured.

-> Internally in subprojects of Alerting plugin in configuration phase call to the repo is being made before it was actually setup. But the setup will happen after configuration phase ends. So, this was the reason Alerting plugin was failing.

-> Temporarily we moved back call to setupDownloadServiceRepo() in DistributionDownloadPlugin.java to apply() method as it was before. Here the repo is setup before evaluation happens. But, it does not fix this issue.

Fix:

-> The fix I found was to use Project properties to set the custom url from plugin instead of system properties. Before, I was trying to use system properties to set custom url from plugin.

-> These system properties are not available for us to use them in configuration phase, we had to wait until configuration phase ends and afterEvaluate() happens to use these system properties.

->But Project properties are different and are available in configuration phase.

-> So, the fix would be using Project properties to set custom url from plugin side.

-> So no moving of seupDownloadServiceRepo() call out of apply() in DistributionDownloadPlugin.java is necessary and just adding conditions and logic of cutom Url is enough to fix this issue.

Test case for handling Alerting plugin failure:

-> I haven't thought of a way writing test case for this failure. As, it is happening because of moving method call in gradle life cycle phase, I find it a bit complex to write a test case for this scenario. opensearch-project/alerting#312

@Rishikesh1159
Copy link
Member Author

Here is the exact line where Alerting plugin fail with my previous reverted PR #2086. There are other plugins using similar piece of code but for those this piece of code is wrapped inside an after evaluate block, which is making it not fail. So, test case mentioned in my above comment will be related to this. This was the error on Alerting plugin side: opensearch-project/alerting#312

@Rishikesh1159
Copy link
Member Author

Rishikesh1159 commented Mar 9, 2022

This PR fixes the issue, but I am planning to keep it open until we write a test case for above mentioned failure. If someone in future tries to do same mistake as I did then a test case should catch that. So, I am planning on keeping this open until I do that. @dblock please let me know your opinion on this, should we keep this PR open until we write a test case or should that be a new issue?

@dblock
Copy link
Member

dblock commented Mar 9, 2022

This PR fixes the issue, but I am planning to keep it open until we write a test case for above mentioned failure. If someone in future tries to do same mistake as I did then a test case should catch that. So, I am planning on keeping this open until I do that. @dblock please let me know your opinion on this, should we keep this PR open until we write a test case or should that be a new issue?

Because this is an issue in the tooling and not the engine, I would timebox writing the test for this, and move on if it takes too long.

Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

Thanks for this @Rishikesh1159 !

I think we do lack the infrastructure to test these kinds of cases.
Lets start with opening an issue and as we discussed see how other opensource gradle plugins are being tested. We should bring in a similar framework to test these cases.

@Rishikesh1159
Copy link
Member Author

This PR fixes the issue, but I am planning to keep it open until we write a test case for above mentioned failure. If someone in future tries to do same mistake as I did then a test case should catch that. So, I am planning on keeping this open until I do that. @dblock please let me know your opinion on this, should we keep this PR open until we write a test case or should that be a new issue?

Because this is an issue in the tooling and not the engine, I would timebox writing the test for this, and move on if it takes too long.

Sure. Thank you!

@Rishikesh1159
Copy link
Member Author

Thanks for this @Rishikesh1159 !

I think we do lack the infrastructure to test these kinds of cases. Lets start with opening an issue and as we discussed see how other opensource gradle plugins are being tested. We should bring in a similar framework to test these cases.

Sure I will look for other opensource gradle plugins, and see if their framework fits for our use case. Thank you!

@dblock
Copy link
Member

dblock commented Mar 15, 2022

Can we merge this?

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

Successfully merging this pull request may close these issues.

4 participants