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

Allow installing plugins with vMAJOR or vMAJOR.MINOR or vMAJOR.MINOR.PATCH versions #486

Merged
merged 7 commits into from
Sep 21, 2023

Conversation

anujc25
Copy link
Contributor

@anujc25 anujc25 commented Sep 19, 2023

What this PR does / why we need it

  • Allow installing plugins with vMAJOR or vMAJOR.MINOR or vMAJOR.MINOR.PATCH versions

Which issue(s) this PR fixes

Fixes #485

Describe testing done for PR

  • Added Unit Tests and E2E Tests
~ $ tz plugin search --show-details --name insight                                                                                                                         
name: insight
description: Post & query image, package, source, and vulnerability data
target: kubernetes
latest: v1.6.3
versions:
    - v1.3.9
    - v1.4.6
    - v1.5.1
    - v1.6.0
    - v1.6.3
    - 
~ $ tz plugin install insight -v v1                                                                                                                                        (base)
[i] Installing plugin 'insight:v1.6.3' with target 'kubernetes'
[ok] successfully installed 'insight' plugin

~ $ tz plugin install insight -v v1.3                                                                                                                                      (base)
[i] Installing plugin 'insight:v1.3.9' with target 'kubernetes'
[ok] successfully installed 'insight' plugin

~ $ tz plugin install insight -v v1.6                                                                                                                                      (base)
[i] Installing plugin 'insight:v1.6.3' with target 'kubernetes'
[i] Plugin binary for 'insight:v1.6.3' found in cache
[ok] successfully installed 'insight' plugin

~ $ tz plugin install insight -v v1.6.3                                                                                                                                    (base)
[i] Installing plugin 'insight:v1.6.3' with target 'kubernetes'
[i] Plugin binary for 'insight:v1.6.3' found in cache
[ok] successfully installed 'insight' plugin

~ $ tz plugin install insight -v v1.5                                                                                                                                      (base)
[i] Installing plugin 'insight:v1.5.1' with target 'kubernetes'
[ok] successfully installed 'insight' plugin

~ $ tz plugin install insight -v v2                                                                                                                                        (base)
[x] : unable to find plugin 'insight' with version 'v2' for target 'kubernetes'

~ $ tz plugin list                                                                                                                                                      (base)
Standalone Plugins
  NAME       DESCRIPTION                                                  TARGET      VERSION     STATUS
  telemetry  configure cluster-wide settings for vmware tanzu telemetry   global      v1.1.0      installed
  insight    post & query image, package, source, and vulnerability data  kubernetes  v1.5.1      installed

Release note

Allow installing plugins with `vMAJOR` or `vMAJOR.MINOR` or `vMAJOR.MINOR.PATCH` versions with `tanzu plugin install` and `tanzu plugin sync` commands

Additional information

Special notes for your reviewer

@anujc25 anujc25 requested a review from a team as a code owner September 19, 2023 16:19
@marckhouzam
Copy link
Contributor

Thanks @anujc25 for this. While I review I wanted to mention an alternative implementation. I'm not suggesting using it, I'm just bringing it to your attention.

Currently when we look for a plugin in the DB:

  1. the RecommendedVersion field returned is set to the highest semantic version found by the query
  2. the query will either look for all versions (not filter on version) or will look for a specific version using WHERE Version=<vX.Y.Z>

For this feature, we could use SQL's matching functionality and have the version filter become WHERE Version like '<version>%'. Then the query would return all versions that match the specified version, even if it is vX.Y or vX. And the latest version matching would be in RecommendedVersion.

For example, requesting to install a version of v1.2 would return the highest version that matches v1.2, which means the latest patch of v1.2.

Pros:

  • should be almost transparent to the code as the sql query does this already

Cons:

  • we would be dependent on using the RecommendedVersion field so we would need to ignore that value if the DB ever provided one.

@marckhouzam
Copy link
Contributor

@anujc25 my apologies but after merging #484 this PR needs a rebase

Copy link
Contributor

@marckhouzam marckhouzam 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 the update using SQL!

pkg/pluginmanager/manager.go Show resolved Hide resolved
pkg/plugininventory/sqlite_inventory.go Outdated Show resolved Hide resolved
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

  1. For error messages that say unable to find plugin '%v' with version '%v' we will now show "short" versions like v1. How about changing the error message to use the word matching to say unable to find plugin '%v' matching version '%v'`?

  2. Is it ok for the special plugins that have actual binaries with versions v0.25/v0.28/v0.29 to now install the latest patch instead of the specific binary with that version? I hope so, because the behaviour of the PR is what I'm hoping we can keep.

  3. I think we need to look at how this feature can be used for context-scoped plugins.
    I created a CR for the cluster plugin with a version of v0.30.
    When the plugin is not installed I see version v0.30, which is probably ok

Plugins from Context:  tkg1
  NAME                DESCRIPTION                           TARGET      VERSION  STATUS
  cluster             Kubernetes cluster operations         kubernetes  v0.30    not installed

when I do a plugin sync I then see v0.30.1 which is ok, but is shows there is an update available, which is wrong, and the plugin sync will re-install the same version

Plugins from Context:  tkg1
  NAME                DESCRIPTION                           TARGET      VERSION  STATUS
  cluster             Kubernetes cluster operations         kubernetes  v0.30.1  update available

pkg/plugininventory/sqlite_inventory.go Outdated Show resolved Hide resolved
pkg/pluginmanager/manager.go Outdated Show resolved Hide resolved
@anujc25
Copy link
Contributor Author

anujc25 commented Sep 20, 2023

  • For error messages that say unable to find plugin '%v' with version '%v' we will now show "short" versions like v1. How about changing the error message to use the word matching to say unable to find plugin '%v' matching version '%v'`?

Good point. Updated the error message.

  • Is it ok for the special plugins that have actual binaries with versions v0.25/v0.28/v0.29 to now install the latest patch instead of the specific binary with that version? I hope so, because the behaviour of the PR is what I'm hoping we can keep.

Yes. That was the goal with v0.25/v0.28/v0.29 versions but we did not have this feature in past and hence we had to release it separately.

  • I think we need to look at how this feature can be used for context-scoped plugins.
    I created a CR for the cluster plugin with a version of v0.30.
    When the plugin is not installed I see version v0.30, which is probably ok
    when I do a plugin sync I then see v0.30.1 which is ok, but is shows there is an update available, which is wrong, and the plugin sync will re-install the same version

I have updated the DiscoverServerPlugins function a bit to handle this scenario. However, when the plugin is not installed it will also show the latest matching version (in this case v0.30.1). I feel it should be reasonable as it is more explicitly saying which version will be installed with the tanzu plugin sync but would be nice to get your opinion on this.

Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

One small suggestion to improve the tests.
LGTM

Nice job!

pkg/pluginmanager/manager_test.go Show resolved Hide resolved
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

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

Nice that you also added a pre-release version in the tests👍

LGTM

@marckhouzam
Copy link
Contributor

@anujc25 I think this feature is impactful enough that it should be mentioned in the documentation. I'm thinking of at least two areas:

  1. using plugin groups with "shortened" plugin versions
  2. context-scope plugins with "shortened" plugin versions

What do you think?

@anujc25
Copy link
Contributor Author

anujc25 commented Sep 21, 2023

Added some basic documentation. I will be adding more as part of follow-up PR.

@anujc25 anujc25 merged commit feb9f44 into vmware-tanzu:main Sep 21, 2023
4 checks passed
@marckhouzam marckhouzam added this to the v1.1.0 milestone Oct 20, 2023
@anujc25 anujc25 added the docs-impact issues with documentation impact label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required docs-impact issues with documentation impact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support installing latest minor and patch version of the plugin when vMAJOR or vMAJOR.MINOR is specified
3 participants