summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-10-08 14:45:19 +0200
committerValentin Rothberg <rothberg@redhat.com>2021-10-08 14:47:33 +0200
commitfad14dafe186bb6cebfd7987db9cd15aa2a23585 (patch)
tree7768329980fa37ef64dee59fdbadfe900ddee916 /vendor
parent14c0fcc6b7b3e8c1f28efea329ab9a6bf0d99b70 (diff)
downloadpodman-fad14dafe186bb6cebfd7987db9cd15aa2a23585.tar.gz
podman-fad14dafe186bb6cebfd7987db9cd15aa2a23585.tar.bz2
podman-fad14dafe186bb6cebfd7987db9cd15aa2a23585.zip
faster image inspection
Vendor the latest HEAD in c/common to pull in changes for a faster inspection of images. Previously, only the size computation was optional, now the one for the parent image is as well. In many cases, the parent image is not needed but it takes around 10ms on my local machine. With this change, we cut off 10ms from many code paths, most importantly, container creation. [NO NEW TESTS NEEDED] Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/containers/common/libimage/inspect.go45
-rw-r--r--vendor/github.com/containers/common/libimage/pull.go4
-rw-r--r--vendor/github.com/containers/common/libimage/search.go5
-rw-r--r--vendor/modules.txt2
4 files changed, 40 insertions, 16 deletions
diff --git a/vendor/github.com/containers/common/libimage/inspect.go b/vendor/github.com/containers/common/libimage/inspect.go
index a872e5cf9..007cbdd89 100644
--- a/vendor/github.com/containers/common/libimage/inspect.go
+++ b/vendor/github.com/containers/common/libimage/inspect.go
@@ -50,19 +50,39 @@ type RootFS struct {
Layers []digest.Digest `json:"Layers"`
}
-// Inspect inspects the image. Use `withSize` to also perform the
-// comparatively expensive size computation of the image.
-func (i *Image) Inspect(ctx context.Context, withSize bool) (*ImageData, error) {
+// InspectOptions allow for customizing inspecting images.
+type InspectOptions struct {
+ // Compute the size of the image (expensive).
+ WithSize bool
+ // Compute the parent of the image (expensive).
+ WithParent bool
+}
+
+// Inspect inspects the image.
+func (i *Image) Inspect(ctx context.Context, options *InspectOptions) (*ImageData, error) {
logrus.Debugf("Inspecting image %s", i.ID())
+ if options == nil {
+ options = &InspectOptions{}
+ }
+
if i.cached.completeInspectData != nil {
- if withSize && i.cached.completeInspectData.Size == int64(-1) {
+ if options.WithSize && i.cached.completeInspectData.Size == int64(-1) {
size, err := i.Size()
if err != nil {
return nil, err
}
i.cached.completeInspectData.Size = size
}
+ if options.WithParent && i.cached.completeInspectData.Parent == "" {
+ parentImage, err := i.Parent(ctx)
+ if err != nil {
+ return nil, err
+ }
+ if parentImage != nil {
+ i.cached.completeInspectData.Parent = parentImage.ID()
+ }
+ }
return i.cached.completeInspectData, nil
}
@@ -75,10 +95,7 @@ func (i *Image) Inspect(ctx context.Context, withSize bool) (*ImageData, error)
if err != nil {
return nil, err
}
- parentImage, err := i.Parent(ctx)
- if err != nil {
- return nil, err
- }
+
repoTags, err := i.RepoTags()
if err != nil {
return nil, err
@@ -93,7 +110,7 @@ func (i *Image) Inspect(ctx context.Context, withSize bool) (*ImageData, error)
}
size := int64(-1)
- if withSize {
+ if options.WithSize {
size, err = i.Size()
if err != nil {
return nil, err
@@ -124,8 +141,14 @@ func (i *Image) Inspect(ctx context.Context, withSize bool) (*ImageData, error)
NamesHistory: i.NamesHistory(),
}
- if parentImage != nil {
- data.Parent = parentImage.ID()
+ if options.WithParent {
+ parentImage, err := i.Parent(ctx)
+ if err != nil {
+ return nil, err
+ }
+ if parentImage != nil {
+ data.Parent = parentImage.ID()
+ }
}
// Determine the format of the image. How we determine certain data
diff --git a/vendor/github.com/containers/common/libimage/pull.go b/vendor/github.com/containers/common/libimage/pull.go
index 1c322c37e..1d1bc201b 100644
--- a/vendor/github.com/containers/common/libimage/pull.go
+++ b/vendor/github.com/containers/common/libimage/pull.go
@@ -477,10 +477,10 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
if pullPolicy == config.PullPolicyNever {
if localImage != nil {
- logrus.Debugf("Pull policy %q but no local image has been found for %s", pullPolicy, imageName)
+ logrus.Debugf("Pull policy %q and %s resolved to local image %s", pullPolicy, imageName, resolvedImageName)
return []string{resolvedImageName}, nil
}
- logrus.Debugf("Pull policy %q and %s resolved to local image %s", pullPolicy, imageName, resolvedImageName)
+ logrus.Debugf("Pull policy %q but no local image has been found for %s", pullPolicy, imageName)
return nil, errors.Wrap(storage.ErrImageUnknown, imageName)
}
diff --git a/vendor/github.com/containers/common/libimage/search.go b/vendor/github.com/containers/common/libimage/search.go
index df29bc7da..7e20e4331 100644
--- a/vendor/github.com/containers/common/libimage/search.go
+++ b/vendor/github.com/containers/common/libimage/search.go
@@ -284,8 +284,9 @@ func searchRepositoryTags(ctx context.Context, sys *types.SystemContext, registr
paramsArr := []SearchResult{}
for i := 0; i < limit; i++ {
params := SearchResult{
- Name: imageRef.DockerReference().Name(),
- Tag: tags[i],
+ Name: imageRef.DockerReference().Name(),
+ Tag: tags[i],
+ Index: registry,
}
paramsArr = append(paramsArr, params)
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 224926b88..ae28bf9ee 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -95,7 +95,7 @@ github.com/containers/buildah/pkg/rusage
github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/util
-# github.com/containers/common v0.46.1-0.20211001143714-161e078e4c7f
+# github.com/containers/common v0.46.1-0.20211008123044-d846f5aaec0e
github.com/containers/common/libimage
github.com/containers/common/libimage/manifests
github.com/containers/common/pkg/apparmor