Go on with a backup when the destination marker cannot be checked (closes #389)
check / check (push) Waiting to run
check / check (push) Waiting to run
A source host whose credentials allow only PUT, which the documents say is enough to back up, failed every backup after its first: the marker check looks the marker up with an S3 HEAD, which those credentials are refused, and any error other than not found was fatal. Such an error now means the check could not be made: it is logged at info level, so --cron stays silent, and the command goes on. Not found still stops it. The documents now say so, and that such a host does not notice an emptied destination, so vaultik database delete must be run on it after the destination is emptied. The fault-injecting test store gains a Stat hook for the test. Model: opus-5-5
This commit was merged in pull request #392.
This commit is contained in:
@@ -2,15 +2,17 @@
|
||||
// faults on demand, so tests can reproduce the failure modes a real
|
||||
// backend exhibits: an upload that fails partway, a backend that reports
|
||||
// success while storing nothing, reads that return corrupt or truncated
|
||||
// bytes, and a delete the backend refuses. It is the seam called for by
|
||||
// the fault-injection tests (sneak/vaultik issue 72) and is meant to be
|
||||
// reused by future tests rather than re-implemented per case.
|
||||
// bytes, and a delete or a stat the backend refuses. It is the seam
|
||||
// called for by the fault-injection tests (sneak/vaultik issue 72) and
|
||||
// is meant to be reused by future tests rather than re-implemented per
|
||||
// case.
|
||||
//
|
||||
// The wrapper delegates every method to the inner Storer. Three hooks
|
||||
// The wrapper delegates every method to the inner Storer. Four hooks
|
||||
// change that: OnPut decides the fate of each write, OnGet decides how
|
||||
// each read's bytes are returned, and OnDelete decides whether each
|
||||
// delete fails. All are keyed by the object key, so a test can fault
|
||||
// only blobs, only metadata, or a single object.
|
||||
// each read's bytes are returned, OnDelete decides whether each delete
|
||||
// fails, and OnStat whether each stat fails. All are keyed by the object
|
||||
// key, so a test can fault only blobs, only metadata, or a single
|
||||
// object.
|
||||
package faultstore
|
||||
|
||||
import (
|
||||
@@ -30,6 +32,11 @@ var ErrInjectedUpload = errors.New("faultstore: injected upload failure")
|
||||
// fail.
|
||||
var ErrInjectedDelete = errors.New("faultstore: injected delete failure")
|
||||
|
||||
// ErrInjectedStat is returned by a Stat the OnStat hook chose to fail.
|
||||
// It is not storage.ErrNotFound: the backend refused the request, as S3
|
||||
// refuses a HEAD to credentials that allow only PUT.
|
||||
var ErrInjectedStat = errors.New("faultstore: injected stat failure")
|
||||
|
||||
// PutAction is the disposition OnPut assigns to a write.
|
||||
type PutAction int
|
||||
|
||||
@@ -76,6 +83,10 @@ type Storer struct {
|
||||
// object key. Returning true fails the delete and leaves the object
|
||||
// in place.
|
||||
OnDelete func(key string) bool
|
||||
|
||||
// OnStat, when set, is consulted before every Stat with the object
|
||||
// key. Returning true fails the stat with ErrInjectedStat.
|
||||
OnStat func(key string) bool
|
||||
}
|
||||
|
||||
// New wraps inner. inner must be non-nil.
|
||||
@@ -159,8 +170,12 @@ func damage(fault GetFault, data []byte) []byte {
|
||||
return out
|
||||
}
|
||||
|
||||
// Stat delegates unchanged.
|
||||
// Stat returns the object's info unless OnStat fails the stat.
|
||||
func (f *Storer) Stat(ctx context.Context, key string) (*storage.ObjectInfo, error) {
|
||||
if f.OnStat != nil && f.OnStat(key) {
|
||||
return nil, fmt.Errorf("%w for %q", ErrInjectedStat, key)
|
||||
}
|
||||
|
||||
return f.inner.Stat(ctx, key)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user