Log warning when plugin using Shared Channels APIs is uninstalled (#26262)

* don't log error every minute when plugin uninstalled
This commit is contained in:
Doug Lauder 2024-02-20 14:10:08 -05:00 committed by GitHub
parent 6541708a93
commit 1fb5c3b1cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
"time"
"github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/plugin" "github.com/mattermost/mattermost/server/public/plugin"
@ -244,7 +245,16 @@ func (a *App) OnSharedChannelsSyncMsg(msg *model.SyncMsg, rc *model.RemoteCluste
func (a *App) OnSharedChannelsPing(rc *model.RemoteCluster) bool { func (a *App) OnSharedChannelsPing(rc *model.RemoteCluster) bool {
pluginHooks, err := getPluginHooks(a.GetPluginsEnvironment(), rc.PluginID) pluginHooks, err := getPluginHooks(a.GetPluginsEnvironment(), rc.PluginID)
if err != nil { if err != nil {
a.Log().Error("Ping for shared channels cannot get plugin hooks", mlog.String("plugin_id", rc.PluginID), mlog.Err(err)) // plugin was likely uninstalled. Issue a warning once per hour, with instructions how to clean up if this is
// intentional.
if time.Now().Minute() == 0 {
msg := "Cannot find plugin for shared channels ping; if the plugin was intentionally uninstalled, "
msg = msg + "stop this warning using `/secure-connection remove --connectionID %s`"
a.Log().Warn(fmt.Sprintf(msg, rc.RemoteId),
mlog.String("plugin_id", rc.PluginID),
mlog.Err(err),
)
}
return false return false
} }