Add constant for the ISO cache directory
parent
ad5a192cf1
commit
ff23ccf318
|
@ -48,7 +48,6 @@ var dirs = [...]string{
|
||||||
localpath.MakeMiniPath("certs"),
|
localpath.MakeMiniPath("certs"),
|
||||||
localpath.MakeMiniPath("machines"),
|
localpath.MakeMiniPath("machines"),
|
||||||
localpath.MakeMiniPath("cache"),
|
localpath.MakeMiniPath("cache"),
|
||||||
localpath.MakeMiniPath("cache", "iso"),
|
|
||||||
localpath.MakeMiniPath("config"),
|
localpath.MakeMiniPath("config"),
|
||||||
localpath.MakeMiniPath("addons"),
|
localpath.MakeMiniPath("addons"),
|
||||||
localpath.MakeMiniPath("files"),
|
localpath.MakeMiniPath("files"),
|
||||||
|
|
|
@ -146,7 +146,10 @@ var (
|
||||||
// KubernetesReleaseBinaries are Kubernetes release binaries required for
|
// KubernetesReleaseBinaries are Kubernetes release binaries required for
|
||||||
// kubeadm (kubelet, kubeadm) and the addon manager (kubectl)
|
// kubeadm (kubelet, kubeadm) and the addon manager (kubectl)
|
||||||
KubernetesReleaseBinaries = []string{"kubelet", "kubeadm", "kubectl"}
|
KubernetesReleaseBinaries = []string{"kubelet", "kubeadm", "kubectl"}
|
||||||
// ImageCacheDir is the path to the image cache directory
|
|
||||||
|
// ISOCacheDir is the path to the virtual machine image cache directory
|
||||||
|
ISOCacheDir = localpath.MakeMiniPath("cache", "iso")
|
||||||
|
// ImageCacheDir is the path to the container image cache directory
|
||||||
ImageCacheDir = localpath.MakeMiniPath("cache", "images")
|
ImageCacheDir = localpath.MakeMiniPath("cache", "images")
|
||||||
|
|
||||||
// DefaultNamespaces are Kubernetes namespaces used by minikube, including addons
|
// DefaultNamespaces are Kubernetes namespaces used by minikube, including addons
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"github.com/juju/mutex"
|
"github.com/juju/mutex"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/minikube/pkg/minikube/localpath"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
"k8s.io/minikube/pkg/minikube/out"
|
"k8s.io/minikube/pkg/minikube/out"
|
||||||
"k8s.io/minikube/pkg/minikube/style"
|
"k8s.io/minikube/pkg/minikube/style"
|
||||||
"k8s.io/minikube/pkg/util/lock"
|
"k8s.io/minikube/pkg/util/lock"
|
||||||
|
@ -75,7 +75,7 @@ func localISOPath(u *url.URL) string {
|
||||||
return u.String()
|
return u.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Join(localpath.MiniPath(), "cache", "iso", path.Base(u.Path))
|
return filepath.Join(constants.ISOCacheDir, path.Base(u.Path))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISO downloads and returns the path to the downloaded ISO
|
// ISO downloads and returns the path to the downloaded ISO
|
||||||
|
@ -115,6 +115,9 @@ func downloadISO(isoURL string, skipChecksum bool) error {
|
||||||
|
|
||||||
// Lock before we check for existence to avoid thundering herd issues
|
// Lock before we check for existence to avoid thundering herd issues
|
||||||
dst := localISOPath(u)
|
dst := localISOPath(u)
|
||||||
|
if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil {
|
||||||
|
return errors.Wrapf(err, "making cache image directory: %s", dst)
|
||||||
|
}
|
||||||
spec := lock.PathMutexSpec(dst)
|
spec := lock.PathMutexSpec(dst)
|
||||||
spec.Timeout = 10 * time.Minute
|
spec.Timeout = 10 * time.Minute
|
||||||
klog.Infof("acquiring lock: %+v", spec)
|
klog.Infof("acquiring lock: %+v", spec)
|
||||||
|
|
|
@ -37,7 +37,7 @@ func MakeTempDir() string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(filepath.Join(tempDir, "cache", "iso"), 0777)
|
err = os.MkdirAll(filepath.Join(tempDir, "cache"), 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue