From 4e04f8d3d22f497f098977b199cfffa26ec3a7a6 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 24 Sep 2018 12:29:34 +0200 Subject: [PATCH] snapper: make error mode an error wait mode Just because taking one snapshot fails does not mean snapper needs to stop for all others. Since users are advised to monitor error logs, snapshot-taking errors can still be addressed. The ErrorWait mode allows a potential future Report / Status command to distinguish normal waits from error waits. --- daemon/snapper/snapper.go | 14 ++++++++------ daemon/snapper/state_string.go | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/daemon/snapper/snapper.go b/daemon/snapper/snapper.go index 2071389..8a6d811 100644 --- a/daemon/snapper/snapper.go +++ b/daemon/snapper/snapper.go @@ -74,7 +74,7 @@ const ( Planning Snapshotting Waiting - Error + ErrorWait ) func (s State) sf() state { @@ -83,7 +83,7 @@ func (s State) sf() state { Planning: plan, Snapshotting: snapshot, Waiting: wait, - Error: nil, + ErrorWait: wait, } return m[s] } @@ -163,7 +163,7 @@ func (s *Snapper) Run(ctx context.Context, snapshotsTaken chan<- struct{}) { func onErr(err error, u updater) state { return u(func(s *Snapper) { s.err = err - s.state = Error + s.state = ErrorWait }).sf() } @@ -254,13 +254,15 @@ func snapshot(a args, u updater) state { select { case a.snapshotsTaken <- struct{}{}: default: - a.log.Warn("callback channel is full, discarding snapshot update event") + if a.snapshotsTaken != nil { + a.log.Warn("callback channel is full, discarding snapshot update event") + } } return u(func(snapper *Snapper) { if hadErr { - snapper.state = Error - snapper.err = errors.New("one or more snapshots could not be created") + snapper.state = ErrorWait + snapper.err = errors.New("one or more snapshots could not be created, check logs for details") } else { snapper.state = Waiting } diff --git a/daemon/snapper/state_string.go b/daemon/snapper/state_string.go index 485e7d9..136baf5 100644 --- a/daemon/snapper/state_string.go +++ b/daemon/snapper/state_string.go @@ -8,7 +8,7 @@ const ( _State_name_0 = "SyncUpPlanning" _State_name_1 = "Snapshotting" _State_name_2 = "Waiting" - _State_name_3 = "Error" + _State_name_3 = "ErrorWait" ) var (