reset container if deleted in flight, not delete (#1924)

## Does this PR need a docs update or release note?

- [x]  No 

## Type of change

- [x] 🐹 Trivial/Minor

## Issue(s)

* #1923

## Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2022-12-22 17:46:36 -07:00 committed by GitHub
parent d0093fdb17
commit b6a2227acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,13 +97,15 @@ func filterContainersAndFillCollections(
jobs, newDelta, err := getJobs(ctx, service, qp.ResourceOwner, cID, prevDelta)
if err != nil {
// race conditions happen, containers might get deleted while
// this process is in flight. If it was deleted, we remake the
// tombstone, just to be sure it gets deleted from storage.
if graph.IsErrDeletedInFlight(err) == nil {
errs = support.WrapAndAppend(qp.ResourceOwner, err, errs)
} else {
tombstones[cID] = dp.path
// race conditions happen, containers might get deleted while
// this process is in flight. If that happens, force the collection
// to reset which will prevent any old items from being retained in
// storage. If the container (or its children) are sill missing
// on the next backup, they'll get tombstoned.
newDelta = deltaUpdate{reset: true}
}
continue
@ -132,13 +134,10 @@ func filterContainersAndFillCollections(
currPaths[cID] = currPath.String()
}
// A tombstone is a collection path that needs to be marked for deletion.
// Tombstones can occur for a number of reasons: the delta token expired,
// the container was deleted in flight, or the user deleted the container
// between backup runs. If events combine to both delete and write content
// to the same container (ex: container_1 gets deleted, then container_2
// gets created with the same name), it is assumed that the backup consumer
// processes deletions before creations, making the combined operation safe.
// A tombstone is a folder that needs to be marked for deletion.
// The only situation where a tombstone should appear is if the folder exists
// in the `previousPath` set, but does not exist in the current container
// resolver (which contains all the resource owners' current containers).
for id, p := range tombstones {
service, err := createService(qp.Credentials)
if err != nil {