Merge pull request #13539 from sharifelgamal/arch-binary
add arch to binary and image cache pathspull/13596/head
commit
d11e45aa86
|
@ -53,6 +53,7 @@ import (
|
|||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/cruntime"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/driver"
|
||||
"k8s.io/minikube/pkg/minikube/kubeconfig"
|
||||
"k8s.io/minikube/pkg/minikube/machine"
|
||||
|
@ -897,7 +898,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
|
|||
}
|
||||
|
||||
if cfg.KubernetesConfig.ShouldLoadCachedImages {
|
||||
if err := machine.LoadCachedImages(&cfg, k.c, images, constants.ImageCacheDir, false); err != nil {
|
||||
if err := machine.LoadCachedImages(&cfg, k.c, images, detect.ImageCacheDir(), false); err != nil {
|
||||
out.FailureT("Unable to load cached images: {{.error}}", out.V{"error": err})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -181,13 +180,6 @@ var (
|
|||
// kubeadm (kubelet, kubeadm) and the addon manager (kubectl)
|
||||
KubernetesReleaseBinaries = []string{"kubelet", "kubeadm", "kubectl"}
|
||||
|
||||
// ISOCacheDir is the path to the virtual machine image cache directory
|
||||
ISOCacheDir = localpath.MakeMiniPath("cache", "iso")
|
||||
// KICCacheDir is the path to the container node image cache directory
|
||||
KICCacheDir = localpath.MakeMiniPath("cache", "kic")
|
||||
// ImageCacheDir is the path to the container image cache directory
|
||||
ImageCacheDir = localpath.MakeMiniPath("cache", "images")
|
||||
|
||||
// DefaultNamespaces are Kubernetes namespaces used by minikube, including addons
|
||||
DefaultNamespaces = []string{
|
||||
"kube-system",
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
|
||||
"github.com/klauspost/cpuid"
|
||||
"golang.org/x/sys/cpu"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
)
|
||||
|
||||
// RuntimeOS returns the runtime operating system
|
||||
|
@ -113,3 +114,18 @@ func GithubActionRunner() bool {
|
|||
// based on https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
|
||||
return os.Getenv("GITHUB_ACTIONS") == "true"
|
||||
}
|
||||
|
||||
// ImageCacheDir returns the path in the minikube home directory to the container image cache for the current architecture
|
||||
func ImageCacheDir() string {
|
||||
return filepath.Join(localpath.MakeMiniPath("cache", "images"), runtime.GOARCH)
|
||||
}
|
||||
|
||||
// KICCacheDir returns the path in the minikube home directory to the container node cache for the current architecture
|
||||
func KICCacheDir() string {
|
||||
return filepath.Join(localpath.MakeMiniPath("cache", "kic"), runtime.GOARCH)
|
||||
}
|
||||
|
||||
// ISOCacheDir returns the path in the minikube home directory to the virtual machine image cache for the current architecture
|
||||
func ISOCacheDir() string {
|
||||
return filepath.Join(localpath.MakeMiniPath("cache", "iso"), runtime.GOARCH)
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ func binaryWithChecksumURL(binaryName, version, osName, archName, binaryURL stri
|
|||
|
||||
// Binary will download a binary onto the host
|
||||
func Binary(binary, version, osName, archName, binaryURL string) (string, error) {
|
||||
targetDir := localpath.MakeMiniPath("cache", osName, version)
|
||||
targetDir := localpath.MakeMiniPath("cache", osName, archName, version)
|
||||
targetFilepath := path.Join(targetDir, binary)
|
||||
targetLock := targetFilepath + ".lock"
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
)
|
||||
|
||||
|
@ -46,7 +46,7 @@ var (
|
|||
|
||||
// imagePathInCache returns path in local cache directory
|
||||
func imagePathInCache(img string) string {
|
||||
f := filepath.Join(constants.KICCacheDir, path.Base(img)+".tar")
|
||||
f := filepath.Join(detect.KICCacheDir(), path.Base(img)+".tar")
|
||||
f = localpath.SanitizeCacheDir(f)
|
||||
return f
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ func CacheToDaemon(img string) error {
|
|||
|
||||
// ImageToDaemon downloads img (if not present in daemon) and writes it to the local docker daemon
|
||||
func ImageToDaemon(img string) error {
|
||||
fileLock := filepath.Join(constants.KICCacheDir, path.Base(img)+".d.lock")
|
||||
fileLock := filepath.Join(detect.KICCacheDir(), path.Base(img)+".d.lock")
|
||||
fileLock = localpath.SanitizeCacheDir(fileLock)
|
||||
|
||||
releaser, err := lockDownload(fileLock)
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/juju/mutex"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
"k8s.io/minikube/pkg/minikube/style"
|
||||
"k8s.io/minikube/pkg/util/lock"
|
||||
|
@ -75,7 +75,7 @@ func localISOPath(u *url.URL) string {
|
|||
return u.String()
|
||||
}
|
||||
|
||||
return filepath.Join(constants.ISOCacheDir, path.Base(u.Path))
|
||||
return filepath.Join(detect.ISOCacheDir(), path.Base(u.Path))
|
||||
}
|
||||
|
||||
// ISO downloads and returns the path to the downloaded ISO
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
"k8s.io/minikube/pkg/util/lock"
|
||||
|
@ -48,7 +48,7 @@ var errCacheImageDoesntExist = &cacheError{errors.New("the image you are trying
|
|||
// DeleteFromCacheDir deletes tar files stored in cache dir
|
||||
func DeleteFromCacheDir(images []string) error {
|
||||
for _, image := range images {
|
||||
path := filepath.Join(constants.ImageCacheDir, image)
|
||||
path := filepath.Join(detect.ImageCacheDir(), image)
|
||||
path = localpath.SanitizeCacheDir(path)
|
||||
klog.Infoln("Deleting image in cache at ", path)
|
||||
if err := os.Remove(path); err != nil {
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
)
|
||||
|
||||
|
@ -198,7 +198,7 @@ func retrieveRemote(ref name.Reference, p v1.Platform) (v1.Image, error) {
|
|||
|
||||
// imagePathInCache returns path in local cache directory
|
||||
func imagePathInCache(img string) string {
|
||||
f := filepath.Join(constants.ImageCacheDir, img)
|
||||
f := filepath.Join(detect.ImageCacheDir(), img)
|
||||
f = localpath.SanitizeCacheDir(f)
|
||||
return f
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func fixPlatform(ref name.Reference, img v1.Image, p v1.Platform) (v1.Image, err
|
|||
}
|
||||
|
||||
func cleanImageCacheDir() error {
|
||||
err := filepath.Walk(constants.ImageCacheDir, func(path string, info os.FileInfo, err error) error {
|
||||
err := filepath.Walk(localpath.MakeMiniPath("cache", "images"), func(path string, info os.FileInfo, err error) error {
|
||||
// If error is not nil, it's because the path was already deleted and doesn't exist
|
||||
// Move on to next path
|
||||
if err != nil {
|
||||
|
|
|
@ -41,8 +41,8 @@ import (
|
|||
"k8s.io/minikube/pkg/minikube/bootstrapper"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/cruntime"
|
||||
"k8s.io/minikube/pkg/minikube/detect"
|
||||
"k8s.io/minikube/pkg/minikube/image"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
"k8s.io/minikube/pkg/minikube/out"
|
||||
|
@ -65,7 +65,7 @@ func CacheImagesForBootstrapper(imageRepository string, version string, clusterB
|
|||
return errors.Wrap(err, "cached images list")
|
||||
}
|
||||
|
||||
if err := image.SaveToDir(images, constants.ImageCacheDir, false); err != nil {
|
||||
if err := image.SaveToDir(images, detect.ImageCacheDir(), false); err != nil {
|
||||
return errors.Wrapf(err, "Caching images for %s", clusterBootstrapper)
|
||||
}
|
||||
|
||||
|
@ -192,11 +192,11 @@ func CacheAndLoadImages(images []string, profiles []*config.Profile, overwrite b
|
|||
}
|
||||
|
||||
// This is the most important thing
|
||||
if err := image.SaveToDir(images, constants.ImageCacheDir, overwrite); err != nil {
|
||||
if err := image.SaveToDir(images, detect.ImageCacheDir(), overwrite); err != nil {
|
||||
return errors.Wrap(err, "save to dir")
|
||||
}
|
||||
|
||||
return DoLoadImages(images, profiles, constants.ImageCacheDir, overwrite)
|
||||
return DoLoadImages(images, profiles, detect.ImageCacheDir(), overwrite)
|
||||
}
|
||||
|
||||
// DoLoadImages loads images to all profiles
|
||||
|
@ -382,7 +382,7 @@ func SaveAndCacheImages(images []string, profiles []*config.Profile) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return DoSaveImages(images, "", profiles, constants.ImageCacheDir)
|
||||
return DoSaveImages(images, "", profiles, detect.ImageCacheDir())
|
||||
}
|
||||
|
||||
// DoSaveImages saves images from all profiles
|
||||
|
|
|
@ -228,7 +228,7 @@ func saveImagesToTarFromConfig() error {
|
|||
if len(images) == 0 {
|
||||
return nil
|
||||
}
|
||||
return image.SaveToDir(images, constants.ImageCacheDir, false)
|
||||
return image.SaveToDir(images, detect.ImageCacheDir(), false)
|
||||
}
|
||||
|
||||
// CacheAndLoadImagesInConfig loads the images currently in the config file
|
||||
|
|
|
@ -143,7 +143,7 @@ func TestDownloadOnly(t *testing.T) {
|
|||
}
|
||||
// checking binaries downloaded (kubelet,kubeadm)
|
||||
for _, bin := range constants.KubernetesReleaseBinaries {
|
||||
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
|
||||
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, v, bin)
|
||||
_, err := os.Stat(fp)
|
||||
if err != nil {
|
||||
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
|
||||
|
@ -161,7 +161,7 @@ func TestDownloadOnly(t *testing.T) {
|
|||
if runtime.GOOS == "windows" {
|
||||
binary = "kubectl.exe"
|
||||
}
|
||||
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
|
||||
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, runtime.GOARCH, v, binary)
|
||||
if _, err := os.Stat(fp); err != nil {
|
||||
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue