MM-49485: Properly disable plugin in product mode (round 2) (#22195)

There were multiple issues at play here.

1. If the plugin was disabled in ch.syncPlugins,
then the prepackaged plugin would not be processed.
Therefore, if there was an earlier version of the plugin
that remained in S3, that would show up instead.

Therefore, we have to let the full plugin extraction
procedure go ahead, but not enable focalboard.

2. We also need to send the disablePlugin signal
to the other node. But the signal won't be sent
until the cluster leader is elected and inter-node
communication is set up. Therefore, we need to listen
to the ClusterLeaderChanged event and send out
a disable plugin event as well.

When both these issues are taken care of,
then we would correctly see the version of the plugin
from the prepackaged_plugins directory in the disabled
state.

https://mattermost.atlassian.net/browse/MM-49485

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2023-02-01 19:43:44 +05:30
коммит произвёл GitHub
родитель c8d08adf29
Коммит 0bf1a91ad8
3 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@@ -161,6 +161,11 @@ func (ch *Channels) syncPluginsActiveState() {
defer wg.Done()
pluginID := plugin.Manifest.Id
// We skip it from activating here. It is disabled later, at a higher level
// from *Channels.Start.
if ch.srv.Config().FeatureFlags.BoardsProduct && pluginID == model.PluginIdFocalboard {
return
}
updatedManifest, activated, err := pluginsEnvironment.Activate(pluginID)
if err != nil {
plugin.WrapLogger(ch.srv.Log()).Error("Unable to activate plugin", mlog.Err(err))
@@ -305,16 +310,6 @@ func (ch *Channels) syncPlugins() *model.AppError {
var wg sync.WaitGroup
for _, plugin := range availablePlugins {
// Disable focalboard in product mode.
if plugin.Manifest.Id == model.PluginIdFocalboard && ch.cfgSvc.Config().FeatureFlags.BoardsProduct {
mlog.Info("Plugin cannot run in product mode, disabling.", mlog.String("plugin_id", model.PluginIdFocalboard))
appErr := ch.disablePlugin(model.PluginIdFocalboard)
if appErr != nil {
mlog.Error("Error disabling plugin", mlog.Err(err))
}
continue
}
wg.Add(1)
go func(pluginID string) {
defer wg.Done()