Add constant for the ISO cache directory

pull/10918/head
Anders F Björklund 2021-03-30 20:09:44 +02:00
parent ad5a192cf1
commit ff23ccf318
4 changed files with 10 additions and 5 deletions

View File

@ -48,7 +48,6 @@ var dirs = [...]string{
localpath.MakeMiniPath("certs"),
localpath.MakeMiniPath("machines"),
localpath.MakeMiniPath("cache"),
localpath.MakeMiniPath("cache", "iso"),
localpath.MakeMiniPath("config"),
localpath.MakeMiniPath("addons"),
localpath.MakeMiniPath("files"),

View File

@ -146,7 +146,10 @@ var (
// KubernetesReleaseBinaries are Kubernetes release binaries required for
// kubeadm (kubelet, kubeadm) and the addon manager (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")
// DefaultNamespaces are Kubernetes namespaces used by minikube, including addons

View File

@ -28,7 +28,7 @@ import (
"github.com/juju/mutex"
"github.com/pkg/errors"
"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/style"
"k8s.io/minikube/pkg/util/lock"
@ -75,7 +75,7 @@ func localISOPath(u *url.URL) 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
@ -115,6 +115,9 @@ func downloadISO(isoURL string, skipChecksum bool) error {
// Lock before we check for existence to avoid thundering herd issues
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.Timeout = 10 * time.Minute
klog.Infof("acquiring lock: %+v", spec)

View File

@ -37,7 +37,7 @@ func MakeTempDir() string {
if err != nil {
log.Fatal(err)
}
err = os.MkdirAll(filepath.Join(tempDir, "cache", "iso"), 0777)
err = os.MkdirAll(filepath.Join(tempDir, "cache"), 0777)
if err != nil {
log.Fatal(err)
}