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

GH-9737: Allow setting min_server_version in plugin manifest #9743

Merged
merged 4 commits into from
Nov 5, 2018
Merged

GH-9737: Allow setting min_server_version in plugin manifest #9743

merged 4 commits into from
Nov 5, 2018

Conversation

hanzei
Copy link
Contributor

@hanzei hanzei commented Oct 25, 2018

Summary

This PR add min_server_version to plugin manifests. This allows to set a minimum Mattermost server version which is required for the plugin to start.
Two notes on backwards compatibility: If a plugin doesn't set min_server_version the sever doesn't perform a version check and just starts the plugin. This way plugins aren't force the set the option.
If a plugin sets min_server_version and the plugins gets executed on a Mattermost server prior to v5.6 the server will just ignore the setting. This means plugins can't enforce a server version on servers prior to v5.6!

UX

If an admin tries to enable a plugin, which requires an higher server version then provided, they will see the error message "This plugin failed to start. Check your system logs for errors.". This is the same message that e.g. appears when the call of OnActivate() fails or a plugin in badly configured. Of course we could create a new error message for this or disable the "enable" button for the plugin, but this will require changes in the webapp which I'm not capable of.
The here proposed changes to the server side have to be done anyway, better UX in the webapp would be nice to have.

Ticket Link

Fixes #9737

Open questions

This PR adds a new library to Gopkg.toml. Is this fine? Is there anything more to do?

The are currently no tests for environment.go, so I didn't add one. Doing this requires a lot of work.

Error messages in (env *Environment) Activate() are appended with the plugin id. For constancy I constructed my error messages the same way. But it makes little sense to be because in the Mattermost log will also show the plugin id. I propose to remove the id from all error messages, but 2/5 and must likely to out of scope of this PR.

@jasonblais
Copy link
Contributor

Would there be a sample plugin we can test the UX with?

@jasonblais jasonblais added 1: PM Review Requires review by a product manager Setup Old Test Server Triggers the creation of a test server labels Oct 26, 2018
@jasonblais jasonblais self-assigned this Oct 26, 2018
@hanzei
Copy link
Contributor Author

hanzei commented Oct 26, 2018

Sure, here you go.com.mattermost.sample-plugin-0.0.1.tar.gz

I set min_server_version to 5.6.0.

Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

@hanzei You're awesome, that's so fast. Just a minor comment/inquiry.

plugin/environment.go Outdated Show resolved Hide resolved
@hanzei
Copy link
Contributor Author

hanzei commented Oct 26, 2018

Work on this PR is paused until some discussion about this feature is finished. You can follow it here

@jasonblais jasonblais added the Work In Progress Not yet ready for review label Oct 26, 2018
@jasonblais
Copy link
Contributor

I saw that the discussion on pre-release regarding this PR is completed. Let me know once updates are completed and I'll review the 'work in progress' label (and if no updates are needed, let me know :) )

@hanzei
Copy link
Contributor Author

hanzei commented Nov 2, 2018

@jasonblais The outcome of the discussion is that a min_server_version setting is needed. Please proceed with the review.

@jasonblais jasonblais removed Setup Old Test Server Triggers the creation of a test server Work In Progress Not yet ready for review labels Nov 2, 2018
@mattermost mattermost deleted a comment from mattermod Nov 2, 2018
@mattermost mattermost deleted a comment from mattermod Nov 2, 2018
@mattermost mattermost deleted a comment from mattermod Nov 2, 2018
@mattermost mattermost deleted a comment from mattermod Nov 2, 2018
@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Nov 2, 2018
@mattermod
Copy link
Contributor

Setup Test Server label detected. Spinmint test server created if build succeeds (checks pass and no conflicts with base branch).

@mattermod
Copy link
Contributor

Spinmint test server created at: https://i-00f27f2a0a685c0e7.test.spinmint.com

Test Admin Account: Username: sysadmin | Password: sysadmin

Test User Account: Username: user-1 | Password: user-1

Instance ID: i-00f27f2a0a685c0e7

Copy link
Contributor

@jasonblais jasonblais left a comment

Choose a reason for hiding this comment

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

Thanks @hanzei. Functionally it works for me with your sample plugin. Just added one question on the error message itself.

As you say, the UX could be improved, but I don't think it blocks this PR - the error message asks the admin to view the error in server logs, which states plugin requires Mattermost 5.6.0: com.mattermost.sample-plugin. I suspect this is the same for other such messages.

One question: Do you know how easy or hard it would be to present the error message we output to server logs in the System Console > Plugins > Management page directly? It would save a step for the admin. If easy, I can create a ticket for it.

PS: I also created a ticket for a bug when uploading a plugin - reproduces on master so not caused by this PR. https://mattermost.atlassian.net/browse/MM-12892

plugin/environment.go Show resolved Hide resolved
Copy link
Contributor

@jasonblais jasonblais left a comment

Choose a reason for hiding this comment

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

Approving with above non-blocking comment.

@jasonblais jasonblais added 2: Dev Review Requires review by a developer and removed 1: PM Review Requires review by a product manager labels Nov 4, 2018
@jasonblais jasonblais removed their assignment Nov 4, 2018
Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks @hanzei 🎉

model/manifest_test.go Show resolved Hide resolved
model/manifest.go Show resolved Hide resolved
Copy link
Member

@jwilander jwilander left a comment

Choose a reason for hiding this comment

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

Awesome, LGTM

@jwilander jwilander added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a developer Setup Old Test Server Triggers the creation of a test server labels Nov 5, 2018
@mattermod
Copy link
Contributor

Spinmint test server destroyed

@jwilander jwilander merged commit 789b2f7 into mattermost:master Nov 5, 2018
@hanzei hanzei deleted the GH-9737 branch November 5, 2018 14:33
@hanzei
Copy link
Contributor Author

hanzei commented Nov 5, 2018

One question: Do you know how easy or hard it would be to present the error message we output to server logs in the System Console > Plugins > Management page directly? It would save a step for the admin. If easy, I can create a ticket for it.

@jasonblais I think this is not so easy to do. But others can estimate this better.

@lindalumitchell lindalumitchell added this to the v5.6.0 milestone Nov 7, 2018
@amyblais amyblais added Docs/Needed Requires documentation Changelog/Done Required changelog entry has been written labels Nov 16, 2018
@jasonblais jasonblais self-assigned this Nov 26, 2018
@lindy65 lindy65 added Tests/Not Needed New release tests not required and removed 4: Reviews Complete All reviewers have approved the pull request labels Dec 5, 2018
@jasonblais jasonblais added Docs/Not Needed Does not require documentation and removed Docs/Needed Requires documentation labels Dec 11, 2018
lieut-data added a commit to lieut-data/mattermost-plugin-remind that referenced this pull request Aug 1, 2019
This takes advantage of built-in version constraint checking within [Mattermost v5.6+](mattermost/mattermost#9743). I realize this won't actually enforce the version check prior to v5.6+, but thought I'd submit in case it that was acceptable.
lieut-data added a commit to lieut-data/mattermost-plugin-remind that referenced this pull request Aug 1, 2019
This takes advantage of built-in version constraint checking within [Mattermost v5.6+](mattermost/mattermost#9743). I realize this won't actually enforce the version check prior to v5.6+, but thought I'd submit in case it that was acceptable.
scottleedavis pushed a commit to scottleedavis/mattermost-plugin-remind that referenced this pull request Aug 1, 2019
This takes advantage of built-in version constraint checking within [Mattermost v5.6+](mattermost/mattermost#9743). I realize this won't actually enforce the version check prior to v5.6+, but thought I'd submit in case it that was acceptable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation Hacktoberfest Tests/Not Needed New release tests not required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants