Skip to content

sync: non-ErrNotExist stat errors silently treated as "copy" in Tar.Sync() #13654

@ishwar170695

Description

@ishwar170695

Location: internal/sync/tar.go, Sync() function

Problem:
The current logic buckets paths into copy vs delete:

if _, err := os.Stat(p.HostPath); err != nil && errors.Is(err, fs.ErrNotExist) {
    pathsToDelete = append(pathsToDelete, p.ContainerPath)
} else {
    pathsToCopy = append(pathsToCopy, *p)
}

Non-NotExist errors (e.g. EACCES, EIO) are silently ignored and the path is
treated as copyable. This means permission or IO errors don't stop the sync ,
the operation may fail later in a less obvious place with the original cause lost.

Expected behavior:

    if err == nil {
        pathsToCopy = append(pathsToCopy, *p)
    } else if errors.Is(err, fs.ErrNotExist) {
        pathsToDelete = append(pathsToDelete, p.ContainerPath)
    } else {
        return fmt.Errorf("stat %q: %w", p.HostPath, err)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions