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

chunked: various improvements #1072

Merged
merged 3 commits into from
Nov 23, 2021
Merged

Conversation

giuseppe
Copy link
Member

some improvements and fixes for issues I've found while playing with docker.io/gscrivano/zstd-chunked:fcos-rawhide and docker.io/gscrivano/zstd-chunked:fcos-latest.

More details in each commit.

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

@@ -230,21 +230,21 @@ func makeEstargzChunkedDiffer(ctx context.Context, store storage.Store, blobSize
func copyFileFromOtherLayer(file *internal.FileMetadata, source string, otherFile *internal.FileMetadata, dirfd int, useHardLinks bool) (bool, *os.File, int64, error) {
srcDirfd, err := unix.Open(source, unix.O_RDONLY, 0)
if err != nil {
return false, nil, 0, err
return false, nil, 0, errors.Wrapf(err, "open source file %q", source)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a stutter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unix.Open call doesn't include any extra information except the errno

}
defer unix.Close(srcDirfd)

srcFile, err := openFileUnderRoot(otherFile.Name, srcDirfd, unix.O_RDONLY, 0)
if err != nil {
return false, nil, 0, err
return false, nil, 0, errors.Wrapf(err, "open source file %q under target rootfs", otherFile.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried about stutter here as well. Doesn't this end up calling an unix.Open()? Which will report an error with the file that the open failed on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it won't use unix.Open but call directly the openat2 wrapper, that only produces the UNIX error without any additional information.

@@ -828,7 +828,10 @@ func safeSymlink(dirfd int, mode os.FileMode, metadata *internal.FileMetadata, o
destDirFd = int(f.Fd())
}

return unix.Symlinkat(metadata.Linkname, destDirFd, destBase)
if err := unix.Symlinkat(metadata.Linkname, destDirFd, destBase); err != nil {
return errors.Wrapf(err, "create symlink %q pointing to %q", metadata.Name, metadata.Linkname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stutter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the extra information, we only get the UNIX error without any pointer to what symlink we were creating

@rhatdan
Copy link
Member

rhatdan commented Nov 23, 2021

LGTM other then concerns about stutter.

Copy link
Member

@rhatdan rhatdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I fine then.
LGTM

@rhatdan
Copy link
Member

rhatdan commented Nov 23, 2021

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the nit LGTM

@@ -89,7 +89,7 @@ func copyFileContent(srcFd int, destFile string, dirfd int, mode os.FileMode, us
src := fmt.Sprintf("/proc/self/fd/%d", srcFd)
st, err := os.Stat(src)
if err != nil {
return nil, -1, err
return nil, -1, errors.Wrapf(err, "copy file content for %q", destFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: using fmt.Errorf would be more modern

@giuseppe
Copy link
Member Author

Other than the nit LGTM

thanks. Changed to use fmt.Errorf instead of errors.Wrapf

add more context to the error messages generated while unpacking the
image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
when creating a new file, handle the case where any of the parent
directories are missing and create them automatically if needed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
when dealing with symlink, open the parent directory and use the
symlink basename to set its attributes.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@rhatdan rhatdan merged commit b1f1ca7 into containers:main Nov 23, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants