Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload size estimate scans original directory even when folder override or filesystem snapshotting is used #3859

Open
Hakkin opened this issue May 11, 2024 · 0 comments

Comments

@Hakkin
Copy link

Hakkin commented May 11, 2024

While investigating an issue with Volume Shadow Copy, I noticed that Kopia was still scanning/reading from the original directory even when I specified to use a filesystem snapshot (VSS). I thought this was odd so I looked into it, it seems the culprit is here:

go func() {
defer scanWG.Done()
wrapped := u.wrapIgnorefs(estimateLog(ctx), entry, policyTree, false /* reportIgnoreStats */)
ds, _ := u.scanDirectory(scanctx, wrapped, policyTree)
u.Progress.EstimatedDataSize(ds.numFiles, ds.totalFileSize)
}()
wrapped := u.wrapIgnorefs(uploadLog(ctx), entry, policyTree, true /* reportIgnoreStats */)
s.RootEntry, err = u.uploadDirWithCheckpointing(ctx, wrapped, policyTree, previousDirs, sourceInfo)

A go routine for scanDirectory is started before uploadDirWithCheckpointing, and the processing of filesystem snapshotting and directory overrides is only done in uploadDirWithCheckpointing.

overrideDir, err := u.executeBeforeFolderAction(ctx, "before-snapshot-root", policyTree.EffectivePolicy().Actions.BeforeSnapshotRoot, localDirPathOrEmpty, &hc)
if err != nil {
return nil, dirReadError{errors.Wrap(err, "error executing before-snapshot-root action")}
}

switch osSnapshotDir, cleanup, err := createOSSnapshot(ctx, rootDir, p); {

This means the upload estimates when using folder overrides (including filesystem snapshots) will be incorrect.

I'm not very familiar with the codebase, so it may not be this simple, but it seems like this might be able to be fixed by simply moving the folder override and filesystem snapshot handling that is in uploadDirWithCheckpointing to before the filesize estimate go routine, and then pass the resulting fs.Directory to both the EstimatedDataSize and uploadDirWithCheckpointing functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant