Bump github.com/containers/storage from 1.32.3 to 1.32.5

Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.32.3 to 1.32.5.
- [Release notes](https://github.com/containers/storage/releases)
- [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md)
- [Commits](https://github.com/containers/storage/compare/v1.32.3...v1.32.5)

---
updated-dependencies:
- dependency-name: github.com/containers/storage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-06-25 10:02:34 -04:00
parent 793063e086
commit 05f39af5bd
78 changed files with 661 additions and 903 deletions

View File

@ -60,7 +60,6 @@ type containerImageRef struct {
historyComment string
annotations map[string]string
preferredManifestType string
exporting bool
squash bool
emptyLayer bool
idMappingOptions *define.IDMappingOptions
@ -70,6 +69,11 @@ type containerImageRef struct {
postEmptyLayers []v1.History
}
type blobLayerInfo struct {
ID string
Size int64
}
type containerImageSource struct {
path string
ref *containerImageRef
@ -83,8 +87,8 @@ type containerImageSource struct {
configDigest digest.Digest
manifest []byte
manifestType string
exporting bool
blobDirectory string
blobLayers map[digest.Digest]blobLayerInfo
}
func (i *containerImageRef) NewImage(ctx context.Context, sc *types.SystemContext) (types.ImageCloser, error) {
@ -222,9 +226,11 @@ func (i *containerImageRef) createConfigsAndManifests() (v1.Image, v1.Manifest,
dimage.RootFS = &docker.V2S2RootFS{}
dimage.RootFS.Type = docker.TypeLayers
dimage.RootFS.DiffIDs = []digest.Digest{}
// Only clear the history if we're squashing, otherwise leave it be so that we can append
// entries to it.
// Only clear the history if we're squashing, otherwise leave it be so
// that we can append entries to it. Clear the parent, too, we no
// longer include its layers and history.
if i.squash {
dimage.Parent = ""
dimage.History = []docker.V2S2History{}
}
@ -308,6 +314,7 @@ func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.System
}
// Extract each layer and compute its digests, both compressed (if requested) and uncompressed.
blobLayers := make(map[digest.Digest]blobLayerInfo)
for _, layerID := range layers {
what := fmt.Sprintf("layer %q", layerID)
if i.squash {
@ -326,9 +333,9 @@ func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.System
if i.emptyLayer && layerID == i.layerID {
continue
}
// If we're not re-exporting the data, and we're reusing layers individually, reuse
// the blobsum and diff IDs.
if !i.exporting && !i.squash && layerID != i.layerID && layer.UncompressedDigest != "" {
// If we already know the digest of the contents of parent
// layers, reuse their blobsums, diff IDs, and sizes.
if !i.squash && layerID != i.layerID && layer.UncompressedDigest != "" {
layerBlobSum := layer.UncompressedDigest
layerBlobSize := layer.UncompressedSize
diffID := layer.UncompressedDigest
@ -348,6 +355,10 @@ func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.System
// Note this layer in the list of diffIDs, again using the uncompressed digest.
oimage.RootFS.DiffIDs = append(oimage.RootFS.DiffIDs, diffID)
dimage.RootFS.DiffIDs = append(dimage.RootFS.DiffIDs, diffID)
blobLayers[diffID] = blobLayerInfo{
ID: layer.ID,
Size: layerBlobSize,
}
continue
}
// Figure out if we need to change the media type, in case we've changed the compression.
@ -597,8 +608,8 @@ func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.System
configDigest: digest.Canonical.FromBytes(config),
manifest: imageManifest,
manifestType: manifestType,
exporting: i.exporting,
blobDirectory: i.blobDirectory,
blobLayers: blobLayers,
}
return src, nil
}
@ -673,39 +684,51 @@ func (i *containerImageSource) GetBlob(ctx context.Context, blob types.BlobInfo,
}
return ioutils.NewReadCloserWrapper(reader, closer), reader.Size(), nil
}
var layerFile *os.File
for _, path := range []string{i.blobDirectory, i.path} {
layerFile, err = os.OpenFile(filepath.Join(path, blob.Digest.String()), os.O_RDONLY, 0600)
if err == nil {
break
}
if !os.IsNotExist(err) {
logrus.Debugf("error checking for layer %q in %q: %v", blob.Digest.String(), path, err)
}
}
if err != nil || layerFile == nil {
logrus.Debugf("error reading layer %q: %v", blob.Digest.String(), err)
return nil, -1, errors.Wrapf(err, "error opening file %q to buffer layer blob", filepath.Join(i.path, blob.Digest.String()))
}
var layerReadCloser io.ReadCloser
size = -1
st, err := layerFile.Stat()
if err != nil {
logrus.Warnf("error reading size of layer %q: %v", blob.Digest.String(), err)
if blobLayerInfo, ok := i.blobLayers[blob.Digest]; ok {
noCompression := archive.Uncompressed
diffOptions := &storage.DiffOptions{
Compression: &noCompression,
}
layerReadCloser, err = i.store.Diff("", blobLayerInfo.ID, diffOptions)
size = blobLayerInfo.Size
} else {
size = st.Size()
for _, blobDir := range []string{i.blobDirectory, i.path} {
var layerFile *os.File
layerFile, err = os.OpenFile(filepath.Join(blobDir, blob.Digest.String()), os.O_RDONLY, 0600)
if err == nil {
st, err := layerFile.Stat()
if err != nil {
logrus.Warnf("error reading size of layer file %q: %v", blob.Digest.String(), err)
} else {
size = st.Size()
layerReadCloser = layerFile
break
}
layerFile.Close()
}
if !os.IsNotExist(err) {
logrus.Debugf("error checking for layer %q in %q: %v", blob.Digest.String(), blobDir, err)
}
}
}
if err != nil || layerReadCloser == nil || size == -1 {
logrus.Debugf("error reading layer %q: %v", blob.Digest.String(), err)
return nil, -1, errors.Wrap(err, "error opening layer blob")
}
logrus.Debugf("reading layer %q", blob.Digest.String())
closer := func() error {
logrus.Debugf("finished reading layer %q", blob.Digest.String())
if err := layerFile.Close(); err != nil {
if err := layerReadCloser.Close(); err != nil {
return errors.Wrapf(err, "error closing layer %q after reading", blob.Digest.String())
}
return nil
}
return ioutils.NewReadCloserWrapper(layerFile, closer), size, nil
return ioutils.NewReadCloserWrapper(layerReadCloser, closer), size, nil
}
func (b *Builder) makeImageRef(options CommitOptions, exporting bool) (types.ImageReference, error) {
func (b *Builder) makeImageRef(options CommitOptions) (types.ImageReference, error) {
var name reference.Named
container, err := b.store.Container(b.ContainerID)
if err != nil {
@ -766,7 +789,6 @@ func (b *Builder) makeImageRef(options CommitOptions, exporting bool) (types.Ima
historyComment: b.HistoryComment(),
annotations: b.Annotations(),
preferredManifestType: manifestType,
exporting: exporting,
squash: options.Squash,
emptyLayer: options.EmptyLayer && !options.Squash,
idMappingOptions: &b.IDMappingOptions,