mirror of
https://github.com/zrepl/zrepl.git
synced 2025-02-16 18:30:54 +01:00
replication: handle context cancellation errors as GlobalError
This commit is contained in:
parent
36265ff349
commit
1691839c6b
@ -82,6 +82,7 @@ const (
|
|||||||
type Error interface {
|
type Error interface {
|
||||||
error
|
error
|
||||||
Temporary() bool
|
Temporary() bool
|
||||||
|
ContextErr() bool
|
||||||
LocalToFS() bool
|
LocalToFS() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +188,8 @@ func (e *ReplicationConflictError) Error() string { return fmt.Sprintf("permanen
|
|||||||
|
|
||||||
func (e *ReplicationConflictError) LocalToFS() bool { return true }
|
func (e *ReplicationConflictError) LocalToFS() bool { return true }
|
||||||
|
|
||||||
|
func (e *ReplicationConflictError) ContextErr() bool { return false }
|
||||||
|
|
||||||
func NewReplicationConflictError(fs string, err error) *Replication {
|
func NewReplicationConflictError(fs string, err error) *Replication {
|
||||||
return &Replication{
|
return &Replication{
|
||||||
state: Completed,
|
state: Completed,
|
||||||
@ -332,6 +335,16 @@ func (e StepError) LocalToFS() bool {
|
|||||||
return true // conservative approximation: we'd like to check for specific errors returned over RPC here...
|
return true // conservative approximation: we'd like to check for specific errors returned over RPC here...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e StepError) ContextErr() bool {
|
||||||
|
switch e.err {
|
||||||
|
case context.Canceled:
|
||||||
|
return true
|
||||||
|
case context.DeadlineExceeded:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (fsr *Replication) Report() *Report {
|
func (fsr *Replication) Report() *Report {
|
||||||
fsr.lock.Lock()
|
fsr.lock.Lock()
|
||||||
defer fsr.lock.Unlock()
|
defer fsr.lock.Unlock()
|
||||||
|
@ -459,7 +459,14 @@ func stateWorking(ctx context.Context, ka *watchdog.KeepAlive, sender Sender, re
|
|||||||
}).rsf()
|
}).rsf()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.LocalToFS() {
|
if err.ContextErr() && ctx.Err() != nil {
|
||||||
|
getLogger(ctx).WithError(err).
|
||||||
|
Info("filesystem replication was cancelled")
|
||||||
|
u(func(r*Replication) {
|
||||||
|
r.err = GlobalError{Err: err, Temporary: false}
|
||||||
|
r.state = PermanentError
|
||||||
|
})
|
||||||
|
} else if err.LocalToFS() {
|
||||||
getLogger(ctx).WithError(err).
|
getLogger(ctx).WithError(err).
|
||||||
Error("filesystem replication encountered a filesystem-specific error")
|
Error("filesystem replication encountered a filesystem-specific error")
|
||||||
// we stay in this state and let the queuing logic above de-prioritize this failing FS
|
// we stay in this state and let the queuing logic above de-prioritize this failing FS
|
||||||
|
Loading…
Reference in New Issue
Block a user