Skip to content

Conversation

Divyaasm
Copy link
Collaborator

Description

Add native plugin validation framework for all distributions

Issues Resolved

#2859

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.

plugin_list = [i["name"] for i in response if i["name"] not in installed_plugins_list]
plugin_list.remove("examples")
plugin_list.remove("build.gradle")
plugin_list.remove("identity-shiro") # Assuming security plugin enabled in the artifacts
Copy link
Member

@prudhvigodithi prudhvigodithi May 20, 2025

Choose a reason for hiding this comment

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

@Divyaasm can you add some more details like since identity-shiro is also an identity plugin and 2 similar identity plugins cannot be installed.

Signed-off-by: Divya Madala <[email protected]>
Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (6eba98d) to head (3d432f1).
Report is 22 commits behind head on main.

❌ Your project status has failed because the head coverage (0.00%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #5529   +/-   ##
============================
============================

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

Copy link
Member

@gaiksaya gaiksaya left a comment

Choose a reason for hiding this comment

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

I would still recommend to add gradle task in core repo to list native plugins as projects and grab those instead of parsing the GitHub. Wondering if core maintainers (@andrross @reta ) have any better mechanism or preference for this.

Thanks!

native_plugins_list = self.get_native_plugin_list(self.tmp_dir.name)
for container in ["opensearch-node1", "opensearch-node2"]:
for native_plugin in native_plugins_list:
command = f'docker exec -it {container} sh .' + os.sep + 'bin' + os.sep + f'opensearch-plugin install --batch {native_plugin}'
Copy link
Member

Choose a reason for hiding this comment

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

Why not add RUN/CMD opensearch-plugin install --batch {native_plugin} in the docker compose file.
This is not how user might be doint it right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This can be done in both ways! I have opted this as it seemed straight-forward, we have container details to run the command and we restart docker compose file after installing plugins. So we should be good AFAIK.

For the approach you have suggested, Existing compose file needs to be modified, we will need to update the docker-compose file dynamically and bring docker up!

Copy link
Member

Choose a reason for hiding this comment

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

That's how the users will do it. Add the required plugins in the docker-compose files for their set up. I believe its the right way to go than executing a command against container.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should not change dockerfile or dockercomposefiles especially the latter one is now the official docker compose files on our website since the WP migration.

I am ok with having cmd in py to do this test as it is just a test, not related to functionalities of dockerfile and dockercomposefiles.

Thanks.

try:
self.filename = os.path.basename(self.args.file_path.get(project))
execute('mkdir ' + os.path.join(self.tmp_dir.path, project) + ' | tar -xzf ' + os.path.join(str(self.tmp_dir.path), self.filename) + ' -C ' + os.path.join(self.tmp_dir.path, project) + ' --strip-components=1', ".", True, False) # noqa: E501
if self.args.validate_native_plugin:
Copy link
Member

Choose a reason for hiding this comment

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

We want to test everytime no matter the arg right? Wondering why we have if condition here.

Copy link
Member

Choose a reason for hiding this comment

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

Agree. I think we should always test native plugin installation as part of validation workflow.

Or maybe we could have an argument to pass in specific native plugin we want to test on instead of the whole lists. By default, it would test the entire list. I think it could be helpful. WDYT? @gaiksaya @prudhvigodithi @rishabh6788

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I assumed that, this will be an argument passed from jenkins. We can set it to true/false by default based on our requirement.

Copy link
Member

Choose a reason for hiding this comment

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

I believe its better to pass the whole list. I know discovery-ec2 and repository-s3 are some of the commonly used plugins but better to test everything while we are in there. It's just installation so should be fast.

plugin_list = [i["name"] for i in response if i["name"] not in installed_plugins_list]
plugin_list.remove("examples")
plugin_list.remove("build.gradle")
plugin_list.remove("identity-shiro") # Since the security plugin is enabled in the artifacts and identity-shiro is also an identity plugin, we cannot have both the plugins installed together. # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
plugin_list.remove("identity-shiro") # Since the security plugin is enabled in the artifacts and identity-shiro is also an identity plugin, we cannot have both the plugins installed together. # noqa: E501
# Since the security plugin is enabled in the artifacts and identity-shiro is also an identity plugin, we cannot have both the plugins installed together.
plugin_list.remove("identity-shiro") # noqa: E501

Copy link
Member

@zelinh zelinh left a comment

Choose a reason for hiding this comment

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

Can you also update our README file since we will be introducing new functionality?
https://github.com/opensearch-project/opensearch-build/blob/main/src/validation_workflow/README.md

try:
self.filename = os.path.basename(self.args.file_path.get(project))
execute('mkdir ' + os.path.join(self.tmp_dir.path, project) + ' | tar -xzf ' + os.path.join(str(self.tmp_dir.path), self.filename) + ' -C ' + os.path.join(self.tmp_dir.path, project) + ' --strip-components=1', ".", True, False) # noqa: E501
if self.args.validate_native_plugin:
Copy link
Member

Choose a reason for hiding this comment

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

Agree. I think we should always test native plugin installation as part of validation workflow.

Or maybe we could have an argument to pass in specific native plugin we want to test on instead of the whole lists. By default, it would test the entire list. I think it could be helpful. WDYT? @gaiksaya @prudhvigodithi @rishabh6788

path = os.path.exists(os.path.join(work_dir, "plugins", "opensearch-security"))
return path

def install_native_plugin(self, path: str) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Wonder how do we validate the cluster can be exit gracefully after native plugin installation. I think we saw an issue when exiting previously.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At the end of validation, cleanup() method stops the cluster before finishing the job, if there is any issue an exception is raised.

@reta
Copy link
Contributor

reta commented May 24, 2025

I would still recommend to add gradle task in core repo to list native plugins as projects and grab those instead of parsing the GitHub. Wondering if core maintainers (@andrross @reta ) have any better mechanism or preference for this.

Thanks!

Thanks @gaiksaya , I think just listing the repo plugins folder (https://github.com/opensearch-project/OpenSearch/tree/main/plugins) would the simplest way to get all list "builtin" plugins.

native_plugins_list = self.get_native_plugin_list(self.tmp_dir.name)
for container in ["opensearch-node1", "opensearch-node2"]:
for native_plugin in native_plugins_list:
command = f'docker exec -it {container} sh .' + os.sep + 'bin' + os.sep + f'opensearch-plugin install --batch {native_plugin}'
Copy link
Member

Choose a reason for hiding this comment

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

I think we should not change dockerfile or dockercomposefiles especially the latter one is now the official docker compose files on our website since the WP migration.

I am ok with having cmd in py to do this test as it is just a test, not related to functionalities of dockerfile and dockercomposefiles.

Thanks.

def get_native_plugin_list(self, workdir: str) -> list:
bundle_manifest = BundleManifest.from_path(os.path.join(workdir, "manifest.yml"))
commit_id = bundle_manifest.components["OpenSearch"].commit_id
plugin_url = f"https://api.github.com/repos/opensearch-project/OpenSearch/contents/plugins?ref={commit_id}"
Copy link
Member

Choose a reason for hiding this comment

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

Is the native plugin list not in manifest that you have to retrieve from github api?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The github api returns the plugin(native plugins list) folder based on the commit id from the bundle manifest.

Copy link
Member

@peterzhuamazon peterzhuamazon May 29, 2025

Choose a reason for hiding this comment

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

Yeah but build manifest at least include all the plugin names without the need to go online again.
I am not sure about the bundle manifest tho.

Copy link
Collaborator Author

@Divyaasm Divyaasm May 29, 2025

Choose a reason for hiding this comment

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

Yes, but we need native-pugins list https://github.com/opensearch-project/OpenSearch/tree/main/plugins, not the os plugins which are in the manifest.

Copy link
Member

Choose a reason for hiding this comment

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

No, if you check bundle manifest under opensearch core section, there are core-plugins key that contains all the core plugins.

Comment on lines 87 to 88
subprocess.run(f'docker cp opensearch-node1:/usr/share/opensearch/plugins {self.tmp_dir.name}/plugins',
shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why do you need to copy the plugins folder, unlike other dists?

Copy link
Collaborator Author

@Divyaasm Divyaasm May 29, 2025

Choose a reason for hiding this comment

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

Yeah so, the query-insights in 2.x releases is os plugin as well as in native plugin folder. So inorder to restrict installing the plugin twice. I'm removing plugins list in the artifact from the native plugins list retrieved from github api. Which will need plugins folder available locally for the operations. So I've copied it to tmp folder from the container for getting the final list of native plugins which will be later iterated and installed.

Copy link
Member

Choose a reason for hiding this comment

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

Cant you just get the list and save to a var?
I still couldnt wrap my head around why we need to docker cp the plugin folders again.

Thanks.

Signed-off-by: Divya Madala <[email protected]>
Copy link
Member

@peterzhuamazon peterzhuamazon left a comment

Choose a reason for hiding this comment

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

Thanks @Divyaasm !

Please wrap possible improvements in an issue and attached to this PR.

Before merging, Thanks!

@Divyaasm Divyaasm merged commit 1bfa697 into opensearch-project:main Jun 6, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in Engineering Effectiveness Board Jun 6, 2025
@Divyaasm Divyaasm mentioned this pull request Jul 7, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

6 participants