From e9afa774073fd47aec3b5067dc86a13db201c40d Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Thu, 28 Sep 2023 14:43:34 +0800 Subject: [PATCH] flush repo after policy is set Signed-off-by: Lyndon-Li --- changelogs/unreleased/6889-Lyndon-Li | 1 + pkg/uploader/kopia/snapshot.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/6889-Lyndon-Li diff --git a/changelogs/unreleased/6889-Lyndon-Li b/changelogs/unreleased/6889-Lyndon-Li new file mode 100644 index 0000000000..24db0d6b9c --- /dev/null +++ b/changelogs/unreleased/6889-Lyndon-Li @@ -0,0 +1 @@ +Flush repo after policy is set so that policy is retrieved correctly by TreeForSource \ No newline at end of file diff --git a/pkg/uploader/kopia/snapshot.go b/pkg/uploader/kopia/snapshot.go index ce60aadb57..2e95d8a19d 100644 --- a/pkg/uploader/kopia/snapshot.go +++ b/pkg/uploader/kopia/snapshot.go @@ -198,6 +198,10 @@ func SnapshotSource( return "", 0, errors.Wrapf(err, "unable to set policy for si %v", sourceInfo) } + if err := rep.Flush(ctx); err != nil { + return "", 0, errors.Wrap(err, "error to flush policy repo") + } + policyTree, err := treeForSourceFunc(ctx, rep, sourceInfo) if err != nil { return "", 0, errors.Wrapf(err, "unable to create policy getter for si %v", sourceInfo) @@ -231,7 +235,7 @@ func reportSnapshotStatus(manifest *snapshot.Manifest, policyTree *policy.Tree) var errs []string if ds := manifest.RootEntry.DirSummary; ds != nil { for _, ent := range ds.FailedEntries { - policy := policyTree.DefinedPolicy() + policy := policyTree.EffectivePolicy() if !(policy != nil && *policy.ErrorHandlingPolicy.IgnoreUnknownTypes == true && strings.Contains(ent.Error, fs.ErrUnknown.Error())) { errs = append(errs, fmt.Sprintf("Error when processing %v: %v", ent.EntryPath, ent.Error)) }