pruner: fail on every error that is not net.OpError.Temporary()

This commit is contained in:
Christian Schwarz 2018-10-19 15:57:38 +02:00
parent 45373168ad
commit 359ab2ca0c
2 changed files with 7 additions and 10 deletions

View File

@ -329,11 +329,8 @@ func (s snapshot) Replicated() bool { return s.replicated }
func (s snapshot) Date() time.Time { return s.date }
func shouldRetry(e error) bool {
switch e.(type) {
case nil:
return true
case net.Error:
return true
if neterr, ok := e.(net.Error); ok {
return neterr.Temporary()
}
return false
}

View File

@ -129,12 +129,12 @@ func TestPruner_Prune(t *testing.T) {
var _ net.Error = &net.OpError{} // we use it below
target := &mockTarget{
listFilesystemsErr: []error{
stubNetErr{msg: "fakerror0"},
stubNetErr{msg: "fakerror0", temporary: true},
},
listVersionsErrs: map[string][]error{
"zroot/foo": {
stubNetErr{msg: "fakeerror1"}, // should be classified as temporaty
stubNetErr{msg: "fakeerror2"},
stubNetErr{msg: "fakeerror1", temporary: true}, // should be classified as temporaty
stubNetErr{msg: "fakeerror2", temporary: true,},
},
},
destroyErrs: map[string][]error{
@ -142,7 +142,7 @@ func TestPruner_Prune(t *testing.T) {
fmt.Errorf("permanent error"),
},
"zroot/bar": {
stubNetErr{msg: "fakeerror3"},
stubNetErr{msg: "fakeerror3", temporary: true},
},
},
destroyed: make(map[string][]string),
@ -176,7 +176,7 @@ func TestPruner_Prune(t *testing.T) {
history := &mockHistory{
errs: map[string][]error{
"zroot/foo": {
stubNetErr{msg: "fakeerror4"},
stubNetErr{msg: "fakeerror4", temporary: true},
},
"zroot/baz": {
fmt.Errorf("permanent error2"),