Merge pull request #7247 from Lyndon-Li/release-1.12

[1.12] Issue 7244: delete incomplete snapshot automatically for kopia uploader
This commit is contained in:
Shubham Pampattiwar
2023-12-22 10:47:32 -08:00
committed by GitHub
3 changed files with 8 additions and 0 deletions

View File

@@ -0,0 +1 @@
Fix issue #7244. By the end of the upload, check the outstanding incomplete snapshots and delete them by calling ApplyRetentionPolicy

View File

@@ -44,6 +44,7 @@ import (
)
// All function mainly used to make testing more convenient
var applyRetentionPolicyFunc = policy.ApplyRetentionPolicy
var treeForSourceFunc = policy.TreeForSource
var setPolicyFunc = policy.SetPolicy
var saveSnapshotFunc = snapshot.SaveSnapshot
@@ -277,6 +278,11 @@ func SnapshotSource(
return "", 0, errors.Wrapf(err, "Failed to save kopia manifest %v", manifest.ID)
}
_, err = applyRetentionPolicyFunc(ctx, rep, sourceInfo, true)
if err != nil {
return "", 0, errors.Wrapf(err, "Failed to apply kopia retention policy for si %v", sourceInfo)
}
if err = rep.Flush(ctx); err != nil {
return "", 0, errors.Wrapf(err, "Failed to flush kopia repository")
}

View File

@@ -60,6 +60,7 @@ func injectSnapshotFuncs() *snapshotMockes {
repoWriterMock: &repomocks.RepositoryWriter{},
}
applyRetentionPolicyFunc = s.policyMock.ApplyRetentionPolicy
setPolicyFunc = s.policyMock.SetPolicy
treeForSourceFunc = s.policyMock.TreeForSource
loadSnapshotFunc = s.snapshotMock.LoadSnapshot