mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-31699 Don't downgrade plugins with feature flag for on-prem (#16639)
* Don't downgrade plugins with feature flag for on-prem * Update app/plugin.go Co-authored-by: Christopher Poile <cpoile@gmail.com> * Short circut for plugin doesn't exist. Co-authored-by: Christopher Poile <cpoile@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d356ef349b
commit
866e938a12
@@ -909,11 +909,33 @@ func (a *App) installFeatureFlagPlugins() {
|
||||
|
||||
// Check if we already installed this version as InstallMarketplacePlugin can't handle re-installs well.
|
||||
pluginStatus, err := a.Srv().GetPluginStatus(pluginId)
|
||||
if err == nil && pluginStatus.Version == version {
|
||||
pluginExists := err == nil
|
||||
if pluginExists && pluginStatus.Version == version {
|
||||
continue
|
||||
}
|
||||
|
||||
if version != "" && version != "control" {
|
||||
// If we are on-prem skip installation if this is a downgrade
|
||||
license := a.Srv().License()
|
||||
inCloud := license != nil && *license.Features.Cloud
|
||||
if !inCloud && pluginExists {
|
||||
parsedVersion, err := semver.Parse(version)
|
||||
if err != nil {
|
||||
a.Log().Debug("Bad version from feature flag", mlog.String("plugin_id", pluginId), mlog.Err(err), mlog.String("version", version))
|
||||
return
|
||||
}
|
||||
parsedExistingVersion, err := semver.Parse(pluginStatus.Version)
|
||||
if err != nil {
|
||||
a.Log().Debug("Bad version from plugin manifest", mlog.String("plugin_id", pluginId), mlog.Err(err), mlog.String("version", pluginStatus.Version))
|
||||
return
|
||||
}
|
||||
|
||||
if parsedVersion.LTE(parsedExistingVersion) {
|
||||
a.Log().Debug("Skip installation because given version was a downgrade and on-prem installations should not downgrade.", mlog.String("plugin_id", pluginId), mlog.Err(err), mlog.String("version", pluginStatus.Version))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
_, err := a.InstallMarketplacePlugin(&model.InstallMarketplacePluginRequest{
|
||||
Id: pluginId,
|
||||
Version: version,
|
||||
|
||||
Reference in New Issue
Block a user