Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm64: Fix incorrect image arch in the manifest for etcd and other kube images #10642

Merged
merged 7 commits into from
Mar 22, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions pkg/minikube/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package image
import (
"context"
"fmt"
"github.com/google/go-containerregistry/pkg/v1/mutate"
spowelljr marked this conversation as resolved.
Show resolved Hide resolved
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -172,19 +173,45 @@ func retrieveImage(ref name.Reference) (v1.Image, error) {
return img, nil
}
// reference does not exist in the local daemon
klog.Infof("daemon lookup for %+v: %v", ref, err)

img, err = retrieveRemote(ref, defaultPlatform)
if err != nil {
klog.Infof("daemon lookup for %+v: %v", ref, err)
return nil, err
}
return fixPlatform(ref, img, defaultPlatform)
}

platform := defaultPlatform
img, err = remote.Image(ref, remote.WithAuthFromKeychain(authn.DefaultKeychain), remote.WithPlatform(platform))
func retrieveRemote(ref name.Reference, p v1.Platform) (v1.Image, error) {
img, err := remote.Image(ref, remote.WithAuthFromKeychain(authn.DefaultKeychain), remote.WithPlatform(p))
if err == nil {
return img, nil
}

klog.Warningf("authn lookup for %+v (trying anon): %+v", ref, err)
img, err = remote.Image(ref)
return img, err
return remote.Image(ref, remote.WithPlatform(p))
}

func fixPlatform(ref name.Reference, img v1.Image, p v1.Platform) (v1.Image, error) {
spowelljr marked this conversation as resolved.
Show resolved Hide resolved
cfg, err := img.ConfigFile()
if err != nil {
klog.Warningf("failed to get config for %s: %v", ref, err)
return img, err
}

if cfg.Architecture == p.Architecture {
return img, nil
}
klog.Warningf("image %s arch mismatch: want %s got %s. fixing",
ref, p.Architecture, cfg.Architecture)

cfg.Architecture = p.Architecture
img, err = mutate.ConfigFile(img, cfg)
if err != nil {
klog.Warningf("failed to change config for %s: %v", ref, err)
return img, errors.Wrap(err, "failed to change image config")
}
return img, nil
}

func cleanImageCacheDir() error {
Expand Down