-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 User Passes a Url #2086
Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url #2086
Conversation
…rl When User Passes a Url Signed-off-by: Rishikesh1159 <[email protected]>
Can one of the admins verify this patch? |
@dblock Sorry for Inconvenience, I had to close my previous PR because of issue with my repo (previous PR #1737 ). I have addressed the changes you suggested in this PR. Please let me know your opinion. Also had a chat with @saratvemulapalli , he suggested on top of these changes we can also check by passing a url from a opensearch internal plugin and see if it overrides default url. We want to make it like an integration test for this change. What is your opinion on this ? |
start gradle check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessarily hacky. You can examine the repositories added without any such complication. See Rishikesh1159@6257d8e
Signed-off-by: Rishikesh1159 <[email protected]>
Thank you @dblock . I realize that I was unnecessarily complicating things. I have made changes you suggested in new PR. |
Also @dblock what is your opinion on adding integration test for this change ? Something like passing custom url from opensearch internal plugin to test this change. |
I like more tests but won’t hold anything for an IT. |
Project project = createProject(null, false); | ||
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class); | ||
plugin.setupDistributions(project); | ||
assertEquals(5, project.getRepositories().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we still get 5 here? (And check for 4 below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of when we not pass customDistribution URL to setupDownloadService() it goes to else block and calls addIvyRepo() with releases and release-candidates as last two parameters for PATTERN LAYOUT. In case when we pass customDistributionUrl PATTERN LAYOUT will be empty.
code: in setupDownloadService() else block
addIvyRepo(
project,
DOWNLOAD_REPO_NAME,
"https://artifacts.opensearch.org",
FAKE_IVY_GROUP,
"/releases" + RELEASE_PATTERN_LAYOUT,
"/release-candidates" + RELEASE_PATTERN_LAYOUT
);
In addIvyRepo() method we have Arrays.stream() which iterates through PATTERN LAYOUT parameter for two times and create two separate repos one for releases and one for release-candidates but both having same url. So, this is why we have 5 repos added instead of 4 for case of not passing custom Distribution url.
code: in addIvyRepo()
private static void addIvyRepo(Project project, String name, String url, String group, String... patternLayout) {
final List repos = Arrays.stream(patternLayout).map(pattern -> project.getRepositories().ivy(repo -> {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question is more what do we want to do about this? If the URL is the going to be the same all the time, the second one should be removed, shouldn't it? If not, adjust the test for now to check all values.
I hit approve, but consider fixing this before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes URL will be same both times. But I think either if we want to remove the second repo from repositories set or add a test check(opensearch-downloads2) again for same URL, we need to perform extra operation. Please correct me if I am wrong, adjusting the test to check all values would be like an extra safe step and better than removing repo. So, I will add test (checking opensearch-downloads2) to check all values as you mentioned in your previous suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually one more thing. You need to document how to use this, probably in DEVELOPER_GUIDE.
Sure. I was thinking to document this usage on all plugins repo DEVELOPER_GUIDE as we will be passing custom url from plugins side. May be we have to document this on both opensearch repo and plugins as-well. I will also get @saratvemulapalli opinion on where would be best place to document usage of this change. |
For this PR DEVELOPER_GUIDE is sufficient. |
…g usage of this in Developer Guide Signed-off-by: Rishikesh1159 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, update the TOC in developer guide.
Let's tidy up the text.
DEVELOPER_GUIDE.md
Outdated
We can override the default distribution download url which always downloads latest version of OpenSearch, with custom distribution download url. This will help to pull artifacts from any location. | ||
This custom distribution download url can be passed from external plugins as an argument. | ||
|
||
Sample command: ./gradlew integTest -DcustomDistributionUrl= "custom distribution download url" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking a bit. This is a doc, so instead of "we can override ..." write "To override ..." and instead of "This will help" with "This enables to ..." or "This allows to pull artifacts from a custom location."
url -> URL
Remove "Sample command: ", quote
the example on its own line, and replace "custom distribution download url" with an actual URL that one might want to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will make these changes.
Sure @dblock . Also had a chat with @saratvemulapalli, decided to document this change both in opensearch repo DEVELOPER_GUIDE and plugins repo DEVELOPER_GUIDE. |
Signed-off-by: Rishikesh1159 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the extra space after =
makes it not copy-pastable, that needs to be fixed.
DEVELOPER_GUIDE.md
Outdated
To override the default Distribution Download URL which always downloads latest version of OpenSearch, with custom Distribution Download URL. This allows to pull artifacts from a custom location. | ||
This custom Distribution Download URL can be passed from external plugins as an argument. | ||
|
||
`./gradlew integTest -DcustomDistributionUrl= "https://ci.opensearch.org/ci/dbc/bundle-build/1.2.0/1127/linux/x64/dist/opensearch-1.2.0-linux-x64.tar.gz"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after =
.
DEVELOPER_GUIDE.md
Outdated
#### Distribution Download Plugin | ||
|
||
To override the default Distribution Download URL which always downloads latest version of OpenSearch, with custom Distribution Download URL. This allows to pull artifacts from a custom location. | ||
This custom Distribution Download URL can be passed from external plugins as an argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bit clearer:
The Distribution Download plugin downloads the latest version of OpenSearch by default, and supports overriding this behavior by setting customDistributionUrl
.
./gradlew integTest -DcustomDistributionUrl="https://ci.opensearch.org/ci/dbc/bundle-build/1.2.0/1127/linux/x64/dist/opensearch-1.2.0-linux-x64.tar.gz"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks @dblock for your suggestion. I think it looks cleaner this way.
Signed-off-by: Rishikesh1159 <[email protected]>
start gradle check |
start gradle check |
…rl When User Passes a Url (#2086) * Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url Signed-off-by: Rishikesh1159 <[email protected]> * Adding test to check if correct IVY repos were added Signed-off-by: Rishikesh1159 <[email protected]> * Adding another test case when custom url is not passed and documenting usage of this in Developer Guide Signed-off-by: Rishikesh1159 <[email protected]> * Adding TOC and making changes in DEVELOPER_GUIDE Signed-off-by: Rishikesh1159 <[email protected]> * Making changes in DEVELOPER_GUIDE about Distribution Download plugin Signed-off-by: Rishikesh1159 <[email protected]> (cherry picked from commit 4a6f54b)
Signed-off-by: Rishikesh1159 [email protected]
Description
This PR overrides default distribution url with custom distribution url passes by user. Previous discussions regarding this PR can be found in PR #1737
Issues Resolved
#1240
Check List
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.