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

[Decouple] Add new core service to expose functionality to verify plugin compatibility with OpenSearch plugins #4710

Merged

Conversation

manasvinibs
Copy link
Member

@manasvinibs manasvinibs commented Aug 9, 2023

Description

  • Adds new core server service cross_compatibility_service which export feature that plugins can extend to decide what they want to do if their OpenSearch plugin counterpart is not installed or has incompatible version.

Issues Resolved

#4903
https://github.com/orgs/opensearch-project/projects/63/views/27?pane=issue&itemId=34093291

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@manasvinibs manasvinibs changed the title Decouple ver compat service [Decouple] Add new core service to expose functionality to verify plugin compatibility with OpenSearch plugins Aug 9, 2023
@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (f822702) 66.96% compared to head (9c90d18) 66.98%.

Files Patch % Lines
...cross_compatibility/cross_compatibility_service.ts 90.32% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4710      +/-   ##
==========================================
+ Coverage   66.96%   66.98%   +0.01%     
==========================================
  Files        3291     3293       +2     
  Lines       63249    63281      +32     
  Branches    10057    10061       +4     
==========================================
+ Hits        42355    42386      +31     
- Misses      18453    18499      +46     
+ Partials     2441     2396      -45     
Flag Coverage Δ
Linux_1 35.24% <ø> (ø)
Linux_2 55.21% <93.33%> (+0.05%) ⬆️
Linux_3 43.77% <8.88%> (-0.05%) ⬇️
Linux_4 35.33% <8.88%> (-0.03%) ⬇️
Windows_1 35.26% <ø> (ø)
Windows_2 55.18% <93.33%> (+0.05%) ⬆️
Windows_3 43.79% <8.88%> (-0.04%) ⬇️
Windows_4 35.33% <8.88%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

src/core/public/plugins/plugin.test.ts Outdated Show resolved Hide resolved
src/core/server/cross_compatibility/README.md Outdated Show resolved Hide resolved
src/core/server/cross_compatibility/README.md Outdated Show resolved Hide resolved
src/core/server/cross_compatibility/README.md Outdated Show resolved Hide resolved

The cross compatibility service can be used by plugins to:

* Disable themselves if they are not compatible with the installed OpenSearch plugins.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the above example, can you please add a condition saying if mustHavePlug is not compatble and show how I can disable my plugin?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! In current world plugins can use core/capabilities API to configure whether to enable/disable plugin. I've included the example.

opensearchInstalledPlugins.forEach((obj) => {
if (obj.component === depPluginName && obj.version) {
installedPluginVersions.add(obj.version);
if (semver.satisfies(semver.coerce(obj.version)!.version, depPluginVersionRange)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI, I was going to release a PEP 440 alternate to semver but I found @renovatebot/pep440 on NPM which I have not used. If that library works, it would be better solution to semver.coerce and if it doesn't, I would release my alternative and we can use it here. If you have the time, can you check if @renovatebot/pep440 works?

src/core/types/cross_compatibility.ts Outdated Show resolved Hide resolved
} catch (error) {
this.log.warn(
`Cat API call to OpenSearch to get list of plugins installed on the cluster has failed: ${error}`
await this.crossCompatibilityService.checkPluginVersionCompatibility(
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the health check is not doing anything here other than recording the compatibility for itself. What are the plans to notify the OSD plugins if one of their deps becomes incompatible?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's correct. To notify the OSD plugins if one of their deps becomes incompatible during runtime needs a hook to be identified to embed this new service when engine state changes. For now, plugins can call the cross compatibility service API on their own during runtime to get to know the compatibility state.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's create an issue for an enhancement which will have plugins possibly expose a function that we call when compatibility changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

return results;
}

private async isVersionCompatibleOSPluginInstalled(
Copy link
Member

@SuZhou-Joe SuZhou-Joe Oct 12, 2023

Choose a reason for hiding this comment

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

The async signature seems not used in this case, could we remove the async and make the call to this method without await? As I thought there is a async call in every for of loop in the code above when there is an await.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @SuZhou-Joe Thanks for your review. Yeah I don't think I need async here and in another public function. Removed the unused async usages.

@joshuarrrr
Copy link
Member

@mana, this has conflicts to resolve. Are you still actively working, or should it move to draft status?

@manasvinibs
Copy link
Member Author

@mana, this has conflicts to resolve. Are you still actively working, or should it move to draft status?

Yes I can resolve the conflict. This needs secondary reviewer and I've asked @kavilla for that.

kavilla
kavilla previously approved these changes Nov 14, 2023
Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

This will be really helpful

…lugin and verify if it is installed on the cluster

Signed-off-by: Manasvini B Suryanarayana <[email protected]>
…bility with OpenSearch plugins

Signed-off-by: Manasvini B Suryanarayana <[email protected]>
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
@manasvinibs manasvinibs merged commit cf4f929 into opensearch-project:main Nov 15, 2023
67 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-4710-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 cf4f9296c0f3f5dfa96df59f6efada868e7cdffe
# Push it to GitHub
git push --set-upstream origin backport/backport-4710-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-4710-to-2.x.

manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this pull request Nov 17, 2023
…gin compatibility with OpenSearch plugins (opensearch-project#4710)

* Allow plugin manifest config to define semver compatible OpenSearch plugin and verify if it is installed on the cluster

Signed-off-by: Manasvini B Suryanarayana <[email protected]>

* Add new core service to expose functionality to verify plugin compatibility with OpenSearch plugins

Signed-off-by: Manasvini B Suryanarayana <[email protected]>

* Add readme doc for cross compatibility service

Signed-off-by: Manasvini B Suryanarayana <[email protected]>

---------

Signed-off-by: Manasvini B Suryanarayana <[email protected]>
(cherry picked from commit cf4f929)
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this pull request Nov 27, 2023
…gin compatibility with OpenSearch plugins (opensearch-project#4710)

* Allow plugin manifest config to define semver compatible OpenSearch plugin and verify if it is installed on the cluster

Signed-off-by: Manasvini B Suryanarayana <[email protected]>

* Add new core service to expose functionality to verify plugin compatibility with OpenSearch plugins

Signed-off-by: Manasvini B Suryanarayana <[email protected]>

* Add readme doc for cross compatibility service

Signed-off-by: Manasvini B Suryanarayana <[email protected]>

---------

Signed-off-by: Manasvini B Suryanarayana <[email protected]>
(cherry picked from commit cf4f929)
ananzh pushed a commit that referenced this pull request Dec 13, 2023
…gin compatibility with OpenSearch plugins (#4710) (#5503)

* Allow plugin manifest config to define semver compatible OpenSearch plugin and verify if it is installed on the cluster
* Add new core service to expose functionality to verify plugin compatibility with OpenSearch plugins
* Add readme doc for cross compatibility service
---------

Signed-off-by: Manasvini B Suryanarayana <[email protected]>
(cherry picked from commit cf4f929)
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.

5 participants