Skip to content

Commit

Permalink
libimage: pull: enforce pull policy for custom platforms
Browse files Browse the repository at this point in the history
Enforce the pull policy to always if a custom platform is requested by
the user.  Some images ship with invalid platforms which we must
pessimistically assume, see containers/podman/issues/10682.

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jun 21, 2021
1 parent 82c6ef5 commit d3d1223
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
return nil, errors.Wrap(storage.ErrImageUnknown, imageName)
}

// Unless the pull policy is "always", we must pessimistically assume
// that the local image has an invalid architecture (see
// containers/podman/issues/10682). Hence, whenever the user requests
// a custom platform, set the pull policy to "always" to make sure
// we're pulling down the image.
if pullPolicy != config.PullPolicyAlways && len(options.Architecture)+len(options.OS)+len(options.Variant) > 0 {
logrus.Debugf("Enforcing pull policy to %q to support custom platform (arch: %q, os: %q, variant: %q)", "always", options.Architecture, options.OS, options.Variant)
pullPolicy = config.PullPolicyAlways
}

if pullPolicy == config.PullPolicyMissing && localImage != nil {
return []string{resolvedImageName}, nil
}
Expand Down

0 comments on commit d3d1223

Please sign in to comment.