[MM-18277] Refactor plugin/health_check.go to use structured l… (#12734)

Этот коммит содержится в:
Santosh Desani
2019-10-14 13:00:23 -05:00
коммит произвёл Michael Kochell
родитель 06866952b6
Коммит dc05e81012

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

@@ -4,7 +4,6 @@
package plugin
import (
"fmt"
"sync"
"time"
@@ -88,7 +87,7 @@ func (job *PluginHealthCheckJob) checkPlugin(id string) {
pluginErr := sup.PerformHealthCheck()
if pluginErr != nil {
mlog.Error(fmt.Sprintf("Health check failed for plugin %s, error: %s", id, pluginErr.Error()))
mlog.Error("Health check failed for plugin", mlog.String("id", id), mlog.Err(pluginErr))
job.handleHealthCheckFail(id, pluginErr)
}
}
@@ -107,13 +106,13 @@ func (job *PluginHealthCheckJob) handleHealthCheckFail(id string, err error) {
if shouldDeactivatePlugin(p) {
p.failTimeStamps = []time.Time{}
mlog.Debug(fmt.Sprintf("Deactivating plugin due to multiple crashes `%s`", id))
mlog.Debug("Deactivating plugin due to multiple crashes", mlog.String("id", id))
job.env.Deactivate(id)
job.env.SetPluginState(id, model.PluginStateFailedToStayRunning)
} else {
mlog.Debug(fmt.Sprintf("Restarting plugin due to failed health check `%s`", id))
mlog.Debug("Restarting plugin due to failed health check", mlog.String("id", id))
if err := job.env.RestartPlugin(id); err != nil {
mlog.Error(fmt.Sprintf("Failed to restart plugin `%s`: %s", id, err.Error()))
mlog.Error("Failed to restart plugin", mlog.String("id", id), mlog.Err(err))
}
}
}