From 5aefc47f71e6ef1047a5a7b33c46efa4552b1352 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Tue, 19 Mar 2019 18:15:34 +0100 Subject: [PATCH] daemon: remove last traces of watchdog mechanism --- daemon/pruner/pruner.go | 10 ---------- util/watchdog/watchdog.go | 31 ------------------------------- 2 files changed, 41 deletions(-) delete mode 100644 util/watchdog/watchdog.go diff --git a/daemon/pruner/pruner.go b/daemon/pruner/pruner.go index 2acd1a6..47cb08e 100644 --- a/daemon/pruner/pruner.go +++ b/daemon/pruner/pruner.go @@ -10,7 +10,6 @@ import ( "github.com/zrepl/zrepl/pruning" "github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/util/envconst" - "github.com/zrepl/zrepl/util/watchdog" "sort" "strings" "sync" @@ -60,8 +59,6 @@ type args struct { type Pruner struct { args args - Progress watchdog.KeepAlive - mtx sync.RWMutex state State @@ -319,10 +316,6 @@ func (s snapshot) Date() time.Time { return s.date } func doOneAttempt(a *args, u updater) { ctx, target, receiver := a.ctx, a.target, a.receiver - var ka *watchdog.KeepAlive - u(func(pruner *Pruner) { - ka = &pruner.Progress - }) sfssres, err := receiver.ListFilesystems(ctx, &pdu.ListFilesystemReq{}) if err != nil { @@ -397,7 +390,6 @@ tfss_loop: pfsPlanErrAndLog(err, "cannot get replication cursor bookmark") continue tfss_loop } - ka.MadeProgress() if rc.GetNotexist() { err := errors.New("replication cursor bookmark does not exist (one successful replication is required before pruning works)") pfsPlanErrAndLog(err, "") @@ -445,11 +437,9 @@ tfss_loop: // Apply prune rules pfs.destroyList = pruning.PruneSnapshots(pfs.snaps, a.rules) - ka.MadeProgress() } u(func(pruner *Pruner) { - pruner.Progress.MadeProgress() pruner.execQueue = newExecQueue(len(pfss)) for _, pfs := range pfss { pruner.execQueue.Put(pfs, nil, false) diff --git a/util/watchdog/watchdog.go b/util/watchdog/watchdog.go deleted file mode 100644 index f7f98ee..0000000 --- a/util/watchdog/watchdog.go +++ /dev/null @@ -1,31 +0,0 @@ -package watchdog - -import ( - "fmt" - "sync" - "time" -) - -type KeepAlive struct { - mtx sync.Mutex - lastUpd time.Time -} - -func (p *KeepAlive) String() string { - if p.lastUpd.IsZero() { - return fmt.Sprintf("never updated") - } - return fmt.Sprintf("last update at %s", p.lastUpd) -} - -func (k *KeepAlive) MadeProgress() { - k.mtx.Lock() - defer k.mtx.Unlock() - k.lastUpd = time.Now() -} - -func (k *KeepAlive) CheckTimeout(timeout time.Duration, jitter time.Duration) (didTimeOut bool) { - k.mtx.Lock() - defer k.mtx.Unlock() - return k.lastUpd.Add(timeout - jitter).Before(time.Now()) -}