Skip to content

Commit

Permalink
fix local image lookup for custom platform
Browse files Browse the repository at this point in the history
Move the platform check into `resolveLocalImage` and inspect each of the
candidates in the given order.  This preserves the local lookup order
and fixes a bug reported in containers/podman/issues/9915.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
  • Loading branch information
vrothberg committed Apr 6, 2021
1 parent 2dff5e0 commit f84ae49
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion new.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ func resolveLocalImage(systemContext *types.SystemContext, store storage.Store,
if err != nil {
return nil, "", "", nil, errors.Wrapf(err, "error parsing reference to image %q", img.ID)
}
if !imageMatch(context.Background(), ref, systemContext) {
logrus.Debugf("Found local image %s but it does not match the provided context", imageName)
continue
}
return ref, ref.Transport().Name(), imageName, img, nil
}

Expand Down Expand Up @@ -188,7 +192,7 @@ func resolveImage(ctx context.Context, systemContext *types.SystemContext, store
}

if options.PullPolicy == define.PullNever || options.PullPolicy == define.PullIfMissing {
if localImage != nil && imageMatch(ctx, localImageRef, systemContext) {
if localImage != nil {
return localImageRef, localImageRef.Transport().Name(), localImage, nil
}
if options.PullPolicy == define.PullNever {
Expand Down

0 comments on commit f84ae49

Please sign in to comment.