-
Notifications
You must be signed in to change notification settings - Fork 247
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
Enable zstd:chunked support in containers/image #775
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -705,6 +705,7 @@ func (d *Driver) Metadata(id string) (map[string]string, error) { | |
// is being shutdown. For now, we just have to unmount the bind mounted | ||
// we had created. | ||
func (d *Driver) Cleanup() error { | ||
_ = os.RemoveAll(d.getStagingDir()) | ||
return mount.Unmount(d.home) | ||
} | ||
|
||
|
@@ -1490,6 +1491,10 @@ func (f fileGetNilCloser) Close() error { | |
return nil | ||
} | ||
|
||
func (d *Driver) getStagingDir() string { | ||
return filepath.Join(d.home, "staging") | ||
} | ||
|
||
// DiffGetter returns a FileGetCloser that can read files from the directory that | ||
// contains files for the layer differences. Used for direct access for tar-split. | ||
func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) { | ||
|
@@ -1500,6 +1505,75 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) { | |
return fileGetNilCloser{storage.NewPathFileGetter(p)}, nil | ||
} | ||
|
||
// CleanupStagingDirectory cleanups the staging directory. | ||
func (d *Driver) CleanupStagingDirectory(stagingDirectory string) error { | ||
return os.RemoveAll(stagingDirectory) | ||
} | ||
|
||
// ApplyDiff applies the changes in the new layer using the specified function | ||
func (d *Driver) ApplyDiffWithDiffer(id, parent string, options *graphdriver.ApplyDiffOpts, differ graphdriver.Differ) (output graphdriver.DriverWithDifferOutput, err error) { | ||
var idMappings *idtools.IDMappings | ||
if options != nil { | ||
idMappings = options.Mappings | ||
} | ||
if idMappings == nil { | ||
idMappings = &idtools.IDMappings{} | ||
} | ||
|
||
applyDir := "" | ||
|
||
if id == "" { | ||
err := os.MkdirAll(d.getStagingDir(), 0700) | ||
if err != nil && !os.IsExist(err) { | ||
return graphdriver.DriverWithDifferOutput{}, err | ||
} | ||
applyDir, err = ioutil.TempDir(d.getStagingDir(), "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are these cleaned up if the pull is abruptly killed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they are cleaned up at shutdown, so if anything is left in the staging directory it will be cleaned up at some point. It could still be a problem for long running processes like CRI-O though. |
||
if err != nil { | ||
return graphdriver.DriverWithDifferOutput{}, err | ||
} | ||
|
||
} else { | ||
var err error | ||
applyDir, err = d.getDiffPath(id) | ||
if err != nil { | ||
return graphdriver.DriverWithDifferOutput{}, err | ||
} | ||
} | ||
|
||
logrus.Debugf("Applying differ in %s", applyDir) | ||
|
||
out, err := differ.ApplyDiff(applyDir, &archive.TarOptions{ | ||
UIDMaps: idMappings.UIDs(), | ||
GIDMaps: idMappings.GIDs(), | ||
IgnoreChownErrors: d.options.ignoreChownErrors, | ||
WhiteoutFormat: d.getWhiteoutFormat(), | ||
InUserNS: rsystem.RunningInUserNS(), | ||
}) | ||
out.Target = applyDir | ||
return out, err | ||
} | ||
|
||
// ApplyDiffFromStagingDirectory applies the changes using the specified staging directory. | ||
func (d *Driver) ApplyDiffFromStagingDirectory(id, parent, stagingDirectory string, diffOutput *graphdriver.DriverWithDifferOutput, options *graphdriver.ApplyDiffOpts) error { | ||
if filepath.Dir(stagingDirectory) != d.getStagingDir() { | ||
return fmt.Errorf("%q is not a staging directory", stagingDirectory) | ||
} | ||
|
||
diff, err := d.getDiffPath(id) | ||
if err != nil { | ||
return err | ||
} | ||
if err := os.RemoveAll(diff); err != nil && !os.IsNotExist(err) { | ||
return err | ||
} | ||
return os.Rename(stagingDirectory, diff) | ||
} | ||
|
||
// DifferTarget gets the location where files are stored for the layer. | ||
func (d *Driver) DifferTarget(id string) (string, error) { | ||
return d.getDiffPath(id) | ||
} | ||
|
||
// ApplyDiff applies the new layer into a root | ||
func (d *Driver) ApplyDiff(id, parent string, options graphdriver.ApplyDiffOpts) (size int64, err error) { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m mostly unable to guess the data held in the individual fields (and if I’m not missing anything, most are not actually used). Either way, could they be documented, both as to purpose (“the result of $function” is not a purpose) and values/meaning?