Fix overlay2 ignoring whiteout files
Currently when overlay creates a whiteout file then the overlay2 layer is archived, the correct tar header will be created for the whiteout file, but the tar logic will then attempt to open the file causing a failure. When tar encounters such failures the file is skipped and excluded for the archive, causing the whiteout to be ignored. By skipping the copy of empty files, no open attempt will be made on whiteout files. Fixes #23863 Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
d112f3fb84
commit
c880caae4e
2 changed files with 2 additions and 1 deletions
|
@ -359,7 +359,7 @@ func (ta *tarAppender) addTarFile(path, name string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if hdr.Typeflag == tar.TypeReg {
|
if hdr.Typeflag == tar.TypeReg && hdr.Size > 0 {
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -26,6 +26,7 @@ func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os
|
||||||
hdr.Name = WhiteoutPrefix + hdr.Name
|
hdr.Name = WhiteoutPrefix + hdr.Name
|
||||||
hdr.Mode = 0600
|
hdr.Mode = 0600
|
||||||
hdr.Typeflag = tar.TypeReg
|
hdr.Typeflag = tar.TypeReg
|
||||||
|
hdr.Size = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Mode()&os.ModeDir != 0 {
|
if fi.Mode()&os.ModeDir != 0 {
|
||||||
|
|
Loading…
Reference in a new issue