mirror of
https://github.com/zrepl/zrepl.git
synced 2025-06-20 09:47:50 +02:00
daemon: remove last traces of watchdog mechanism
This commit is contained in:
parent
c9b812570d
commit
5aefc47f71
@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/zrepl/zrepl/pruning"
|
"github.com/zrepl/zrepl/pruning"
|
||||||
"github.com/zrepl/zrepl/replication/logic/pdu"
|
"github.com/zrepl/zrepl/replication/logic/pdu"
|
||||||
"github.com/zrepl/zrepl/util/envconst"
|
"github.com/zrepl/zrepl/util/envconst"
|
||||||
"github.com/zrepl/zrepl/util/watchdog"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -60,8 +59,6 @@ type args struct {
|
|||||||
type Pruner struct {
|
type Pruner struct {
|
||||||
args args
|
args args
|
||||||
|
|
||||||
Progress watchdog.KeepAlive
|
|
||||||
|
|
||||||
mtx sync.RWMutex
|
mtx sync.RWMutex
|
||||||
|
|
||||||
state State
|
state State
|
||||||
@ -319,10 +316,6 @@ func (s snapshot) Date() time.Time { return s.date }
|
|||||||
func doOneAttempt(a *args, u updater) {
|
func doOneAttempt(a *args, u updater) {
|
||||||
|
|
||||||
ctx, target, receiver := a.ctx, a.target, a.receiver
|
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{})
|
sfssres, err := receiver.ListFilesystems(ctx, &pdu.ListFilesystemReq{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -397,7 +390,6 @@ tfss_loop:
|
|||||||
pfsPlanErrAndLog(err, "cannot get replication cursor bookmark")
|
pfsPlanErrAndLog(err, "cannot get replication cursor bookmark")
|
||||||
continue tfss_loop
|
continue tfss_loop
|
||||||
}
|
}
|
||||||
ka.MadeProgress()
|
|
||||||
if rc.GetNotexist() {
|
if rc.GetNotexist() {
|
||||||
err := errors.New("replication cursor bookmark does not exist (one successful replication is required before pruning works)")
|
err := errors.New("replication cursor bookmark does not exist (one successful replication is required before pruning works)")
|
||||||
pfsPlanErrAndLog(err, "")
|
pfsPlanErrAndLog(err, "")
|
||||||
@ -445,11 +437,9 @@ tfss_loop:
|
|||||||
|
|
||||||
// Apply prune rules
|
// Apply prune rules
|
||||||
pfs.destroyList = pruning.PruneSnapshots(pfs.snaps, a.rules)
|
pfs.destroyList = pruning.PruneSnapshots(pfs.snaps, a.rules)
|
||||||
ka.MadeProgress()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u(func(pruner *Pruner) {
|
u(func(pruner *Pruner) {
|
||||||
pruner.Progress.MadeProgress()
|
|
||||||
pruner.execQueue = newExecQueue(len(pfss))
|
pruner.execQueue = newExecQueue(len(pfss))
|
||||||
for _, pfs := range pfss {
|
for _, pfs := range pfss {
|
||||||
pruner.execQueue.Put(pfs, nil, false)
|
pruner.execQueue.Put(pfs, nil, false)
|
||||||
|
@ -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())
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user