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.
This commit is contained in:
Christian Schwarz 2018-09-24 12:29:34 +02:00
parent d04b9713c4
commit 4e04f8d3d2
2 changed files with 9 additions and 7 deletions

View File

@ -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:
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
}

View File

@ -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 (