From 836c637c52b74713fe58cbb0f7ca4c8fca565bd4 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 21 Jun 2021 11:19:16 +0200 Subject: [PATCH] libimage: pull: enforce pull policy for custom platforms 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 --- libimage/pull.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libimage/pull.go b/libimage/pull.go index 7576d537e..4c1749de3 100644 --- a/libimage/pull.go +++ b/libimage/pull.go @@ -369,6 +369,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 }