From 1fb5c3b1cfb4c2124885f4dfad7ef30f5883f0db Mon Sep 17 00:00:00 2001 From: Doug Lauder Date: Tue, 20 Feb 2024 14:10:08 -0500 Subject: [PATCH] Log warning when plugin using Shared Channels APIs is uninstalled (#26262) * don't log error every minute when plugin uninstalled --- server/channels/app/shared_channel.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/channels/app/shared_channel.go b/server/channels/app/shared_channel.go index d6223fea3b..5986c02c23 100644 --- a/server/channels/app/shared_channel.go +++ b/server/channels/app/shared_channel.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "net/http" + "time" "github.com/mattermost/mattermost/server/public/model" "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 { pluginHooks, err := getPluginHooks(a.GetPluginsEnvironment(), rc.PluginID) 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 }