flush repo after policy is set

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2023-09-28 14:55:55 +08:00
parent 1939d633d5
commit 4d8c630123
2 changed files with 6 additions and 1 deletions

View File

@@ -0,0 +1 @@
Flush repo after policy is set so that policy is retrieved correctly by TreeForSource

View File

@@ -199,6 +199,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)
@@ -232,7 +236,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))
}