Skip to content

Commit

Permalink
Add delay for synchronizer restart not to flood output with logs (kub…
Browse files Browse the repository at this point in the history
…ernetes#2752)

* Add delay for synchronizer restart not to flood output with logs

* Format code
  • Loading branch information
Sebastian Florek authored Jan 10, 2018
1 parent 90904bd commit d64874d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/backend/sync/overwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package sync

import (
"log"
"time"

syncApi "github.com/kubernetes/dashboard/src/app/backend/sync/api"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -46,6 +47,8 @@ const (
// In case of synchronizer error it will be restarted.
AlwaysRestart RestartPolicy = "always"
NeverRestart RestartPolicy = "never"

RestartDelay = 2 * time.Second
)

type overwatch struct {
Expand Down Expand Up @@ -106,6 +109,8 @@ func (self *overwatch) monitorSynchronizerStatus(synchronizer syncApi.Synchroniz
case err := <-synchronizer.Error():
log.Printf("Synchronizer %s exited with error: %s", name, err.Error())
if self.policyMap[name] == AlwaysRestart {
// Wait a sec before restarting synchronizer in case it exited with error.
time.Sleep(RestartDelay)
self.broadcastRestartEvent(name)
}

Expand Down

0 comments on commit d64874d

Please sign in to comment.