mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-12080: Added some extra logging to cluster leader changed. (#9475)
Purpose of this is to make in-field debugging of cluster leader issues (particularly around duplicate job scheduling) easier to debug from production server logs.
This commit is contained in:
committed by
Christopher Speller
parent
760e200795
commit
a257d501df
@@ -244,6 +244,7 @@ func New(options ...Option) (outApp *App, outErr error) {
|
||||
})
|
||||
|
||||
app.clusterLeaderListenerId = app.AddClusterLeaderChangedListener(func() {
|
||||
mlog.Info("Cluster leader changed. Determining if job schedulers should be running:", mlog.Bool("isLeader", app.IsLeader()))
|
||||
app.Jobs.Schedulers.HandleClusterLeaderChange(app.IsLeader())
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
|
||||
package app
|
||||
|
||||
import "github.com/mattermost/mattermost-server/model"
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
// Registers a given function to be called when the cluster leader may have changed. Returns a unique ID for the
|
||||
// listener which can later be used to remove it. If clustering is not enabled in this build, the callback will never
|
||||
@@ -20,6 +23,7 @@ func (a *App) RemoveClusterLeaderChangedListener(id string) {
|
||||
}
|
||||
|
||||
func (a *App) InvokeClusterLeaderChangedListeners() {
|
||||
mlog.Info("Cluster leader changed. Invoking ClusterLeaderChanged listeners.")
|
||||
a.Go(func() {
|
||||
a.clusterLeaderListeners.Range(func(_, listener interface{}) bool {
|
||||
listener.(func())()
|
||||
|
||||
Reference in New Issue
Block a user