From 8329aea3b34c9ff5eb8ceb0b9757bdcda56db728 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Fri, 25 Jul 2025 12:58:19 +0530 Subject: [PATCH 01/12] Skip Kubernetes preloads and binary downloads when --no-kubernetes is set --- pkg/minikube/download/binary.go | 6 ++++++ pkg/minikube/download/preload.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/pkg/minikube/download/binary.go b/pkg/minikube/download/binary.go index 6de9d9c42814..e67c0b0e60d8 100644 --- a/pkg/minikube/download/binary.go +++ b/pkg/minikube/download/binary.go @@ -24,6 +24,7 @@ import ( "github.com/blang/semver/v4" "github.com/pkg/errors" + "github.com/spf13/viper" "k8s.io/klog/v2" "k8s.io/minikube/pkg/minikube/localpath" ) @@ -53,6 +54,11 @@ 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) { + // Prevent Kubernetes binary downloads in --no-kubernetes mode + if viper.GetBool("no-kubernetes") { + klog.Infof("Skipping Kubernetes binary download due to --no-kubernetes flag") + return "", nil + } targetDir := localpath.MakeMiniPath("cache", osName, archName, version) targetFilepath := path.Join(targetDir, binary) targetLock := targetFilepath + ".lock" diff --git a/pkg/minikube/download/preload.go b/pkg/minikube/download/preload.go index 6d6696b7a675..b562bcc671dd 100644 --- a/pkg/minikube/download/preload.go +++ b/pkg/minikube/download/preload.go @@ -121,6 +121,11 @@ var checkRemotePreloadExists = func(k8sVersion, containerRuntime string) bool { // PreloadExists returns true if there is a preloaded tarball that can be used func PreloadExists(k8sVersion, containerRuntime, driverName string, forcePreload ...bool) bool { + // Prevent preload logic in --no-kubernetes mode + if viper.GetBool("no-kubernetes") { + klog.Infof("Skipping preload logic due to --no-kubernetes flag") + return false + } // TODO (#8166): Get rid of the need for this and viper at all force := false if len(forcePreload) > 0 { From 801ea3be7692f70fd8345635cd118d70776924d9 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Sun, 10 Aug 2025 09:42:15 +0530 Subject: [PATCH 02/12] Added VerifyNoK8sDownloadCache test for check the v0.0.0 cache --- test/integration/no_kubernetes_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 7b5b86c32a2c..4e60bd1751b1 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -22,7 +22,9 @@ import ( "context" "encoding/json" "fmt" + "os" "os/exec" + "path/filepath" "strings" "testing" ) @@ -46,6 +48,7 @@ func TestNoKubernetes(t *testing.T) { name string validator validateFunc }{ + {"VerifyNoK8sDownloadCache", VerifyNoK8sDownloadCache}, {"StartNoK8sWithVersion", validateStartNoK8sWithVersion}, {"StartWithK8s", validateStartWithK8S}, {"StartWithStopK8s", validateStartWithStopK8s}, @@ -74,6 +77,28 @@ func TestNoKubernetes(t *testing.T) { }) } +// VerifyNoK8sDownloadCache verifies that starting minikube with --no-kubernetes does not create a download cache. +func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) { + defer PostMortemLogs(t, profile) + + // Start minikube with --no-kubernetes flag + args := append([]string{"start", "-p", profile, "--no-kubernetes", "--memory=2048"}, StartArgs()...) + rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) + if err != nil { + t.Fatalf("failed to start minikube with --no-kubernetes: args %q : %v", rr.Command(), err) + } + + // Verify cache directory doesn't exist + homeDir := os.Getenv("HOME") + cachePath := filepath.Join(homeDir, ".minikube", "cache", "linux", "amd64", "v0.0.0") + + if _, err := os.Stat(cachePath); err == nil { + t.Fatalf("Cache directory %s should not exist when using --no-kubernetes", cachePath) + } else if err != nil && !os.IsNotExist(err) { + t.Fatalf("Error checking cache directory %s: %v", cachePath, err) + } +} + // validateStartNoK8sWithVersion expect an error when starting a minikube cluster without kubernetes and with a kubernetes version. func validateStartNoK8sWithVersion(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) From ac7ef42e0089400ff586d00a2deffa8370793e76 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Tue, 12 Aug 2025 01:16:44 +0530 Subject: [PATCH 03/12] Removed extra minikube instance by reusing the validateStartNoK8S instace --- test/integration/no_kubernetes_test.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 4e60bd1751b1..cde0dcf015fe 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -48,11 +48,11 @@ func TestNoKubernetes(t *testing.T) { name string validator validateFunc }{ - {"VerifyNoK8sDownloadCache", VerifyNoK8sDownloadCache}, {"StartNoK8sWithVersion", validateStartNoK8sWithVersion}, {"StartWithK8s", validateStartWithK8S}, {"StartWithStopK8s", validateStartWithStopK8s}, {"Start", validateStartNoK8S}, + {"VerifyNok8sNoK8sDownloads", VerifyNoK8sDownloadCache}, {"VerifyK8sNotRunning", validateK8SNotRunning}, {"ProfileList", validateProfileListNoK8S}, {"Stop", validateStopNoK8S}, @@ -81,14 +81,7 @@ func TestNoKubernetes(t *testing.T) { func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - // Start minikube with --no-kubernetes flag - args := append([]string{"start", "-p", profile, "--no-kubernetes", "--memory=2048"}, StartArgs()...) - rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) - if err != nil { - t.Fatalf("failed to start minikube with --no-kubernetes: args %q : %v", rr.Command(), err) - } - - // Verify cache directory doesn't exist + // Reuse the minikube instance started by validateStartNoK8S. homeDir := os.Getenv("HOME") cachePath := filepath.Join(homeDir, ".minikube", "cache", "linux", "amd64", "v0.0.0") From 99bf5f7e47ee4ca3b2a2e4bf2e71f2a7c9daf46e Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Thu, 18 Sep 2025 00:58:29 +0530 Subject: [PATCH 04/12] Fixed the path issue --- test/integration/no_kubernetes_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index cde0dcf015fe..c2c142178b5f 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -25,8 +25,11 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "testing" + + "k8s.io/minikube/pkg/minikube/localpath" ) // TestNoKubernetes tests starting minikube without Kubernetes, @@ -82,8 +85,7 @@ func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) defer PostMortemLogs(t, profile) // Reuse the minikube instance started by validateStartNoK8S. - homeDir := os.Getenv("HOME") - cachePath := filepath.Join(homeDir, ".minikube", "cache", "linux", "amd64", "v0.0.0") + cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0") if _, err := os.Stat(cachePath); err == nil { t.Fatalf("Cache directory %s should not exist when using --no-kubernetes", cachePath) From 85dc9bf88532b44b65483c5fe045de140e0b77ff Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Thu, 25 Sep 2025 22:26:05 +0530 Subject: [PATCH 05/12] Added one more check in cache.go fixing the binary building issue, NoKubernetesT est now pass locally also fixed the error from fatel to Errorf --- pkg/minikube/node/cache.go | 14 +++++++++----- test/integration/no_kubernetes_test.go | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 72f03fe18d0c..733882110aa8 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -81,11 +81,15 @@ func handleDownloadOnly(cacheGroup, kicGroup *errgroup.Group, k8sVersion, contai } binariesURL := viper.GetString("binary-mirror") - if err := doCacheBinaries(k8sVersion, containerRuntime, driverName, binariesURL); err != nil { - exit.Error(reason.InetCacheBinaries, "Failed to cache binaries", err) - } - if _, err := CacheKubectlBinary(k8sVersion, binariesURL); err != nil { - exit.Error(reason.InetCacheKubectl, "Failed to cache kubectl", err) + + // Skip binary downloads in --no-kubernetes mode + if !viper.GetBool("no-kubernetes") { + if err := doCacheBinaries(k8sVersion, containerRuntime, driverName, binariesURL); err != nil { + exit.Error(reason.InetCacheBinaries, "Failed to cache binaries", err) + } + if _, err := CacheKubectlBinary(k8sVersion, binariesURL); err != nil { + exit.Error(reason.InetCacheKubectl, "Failed to cache kubectl", err) + } } waitCacheRequiredImages(cacheGroup) if driver.IsKIC(driverName) { diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 4d0a098324ef..4ea6715ca21f 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -89,9 +89,9 @@ func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0") if _, err := os.Stat(cachePath); err == nil { - t.Fatalf("Cache directory %s should not exist when using --no-kubernetes", cachePath) + t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath) } else if err != nil && !os.IsNotExist(err) { - t.Fatalf("Error checking cache directory %s: %v", cachePath, err) + t.Errorf("Error checking cache directory %s: %v", cachePath, err) } } From f4817ca3ef8390864c14eed53903943b8e1fdb65 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Fri, 26 Sep 2025 14:48:18 +0530 Subject: [PATCH 06/12] Deleted Old test Directory --- test/integration/no_kubernetes_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 4ea6715ca21f..f4d23cd713ea 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -29,8 +29,8 @@ import ( "strings" "testing" - "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/constants" + "k8s.io/minikube/pkg/minikube/localpath" ) // TestNoKubernetes tests starting minikube without Kubernetes, @@ -122,6 +122,13 @@ func validateStartWithK8S(ctx context.Context, t *testing.T, profile string) { if k8sStatus := getK8sStatus(ctx, t, profile); k8sStatus != "Running" { t.Errorf("Kubernetes status, got: %s, want: Running", k8sStatus) } + + // docs: delete minikube profile to clean up cache for subsequent --no-kubernetes tests. + args = []string{"delete", "-p", profile} + rr, err = Run(t, exec.CommandContext(ctx, Target(), args...)) + if err != nil { + t.Fatalf("failed to delete minikube profile with args: %q : %v", rr.Command(), err) + } } // validateStartWithStopK8s starts a minikube cluster while stopping Kubernetes. From 389ec44a30889459a0360b6e5bca42b0ca90c674 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Fri, 26 Sep 2025 18:00:26 +0530 Subject: [PATCH 07/12] Cleared Cache insde the VerifyNoK8sDownloadCache test and restarted with no kubernetes --- test/integration/no_kubernetes_test.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index f4d23cd713ea..ce100db18802 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -85,9 +85,21 @@ func TestNoKubernetes(t *testing.T) { func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - // Reuse the minikube instance started by validateStartNoK8S. + // Clean any existing cache from previous tests to ensure we test only --no-kubernetes behavior cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0") + if err := os.RemoveAll(cachePath); err != nil { + t.Fatalf("failed to remove cache directory %s: %v", cachePath, err) + } + + // Restart the existing minikube instance with --no-kubernetes to verify no cache is created + args := append([]string{"start", "-p", profile, "--no-kubernetes", "--memory=3072"}, StartArgs()...) + rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) + if err != nil { + t.Errorf("failed to restart minikube with --no-kubernetes: %v", err) + return + } + // Now check that cache was not created during the --no-kubernetes start if _, err := os.Stat(cachePath); err == nil { t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath) } else if err != nil && !os.IsNotExist(err) { @@ -122,13 +134,6 @@ func validateStartWithK8S(ctx context.Context, t *testing.T, profile string) { if k8sStatus := getK8sStatus(ctx, t, profile); k8sStatus != "Running" { t.Errorf("Kubernetes status, got: %s, want: Running", k8sStatus) } - - // docs: delete minikube profile to clean up cache for subsequent --no-kubernetes tests. - args = []string{"delete", "-p", profile} - rr, err = Run(t, exec.CommandContext(ctx, Target(), args...)) - if err != nil { - t.Fatalf("failed to delete minikube profile with args: %q : %v", rr.Command(), err) - } } // validateStartWithStopK8s starts a minikube cluster while stopping Kubernetes. From a0b3b30bffdb58e85140b88589648b83d5fbab61 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Sun, 28 Sep 2025 17:48:32 +0530 Subject: [PATCH 08/12] Did not refresh the instance and logged the cache files to understand better --- test/integration/no_kubernetes_test.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index ce100db18802..172335bcbdf9 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -85,25 +85,20 @@ func TestNoKubernetes(t *testing.T) { func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - // Clean any existing cache from previous tests to ensure we test only --no-kubernetes behavior cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0") - if err := os.RemoveAll(cachePath); err != nil { - t.Fatalf("failed to remove cache directory %s: %v", cachePath, err) - } - - // Restart the existing minikube instance with --no-kubernetes to verify no cache is created - args := append([]string{"start", "-p", profile, "--no-kubernetes", "--memory=3072"}, StartArgs()...) - rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) - if err != nil { - t.Errorf("failed to restart minikube with --no-kubernetes: %v", err) - return - } - // Now check that cache was not created during the --no-kubernetes start - if _, err := os.Stat(cachePath); err == nil { - t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath) + // Printing Cache files for debugging purposes + t.Logf("Checking cache directory: %s", cachePath) + if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 { + t.Logf("Files found in cache after --no-kubernetes start:") + for _, file := range files { + t.Logf(" - %s", file) + } + t.Errorf("Cache directory %s should not contain files when using --no-kubernetes, but found %d files", cachePath, len(files)) } else if err != nil && !os.IsNotExist(err) { t.Errorf("Error checking cache directory %s: %v", cachePath, err) + } else { + t.Logf("No files found in cache directory after --no-kubernetes start (as expected)") } } From 860101a3dc07939a08b1f0a3ad89df017708242a Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Thu, 2 Oct 2025 12:59:37 +0530 Subject: [PATCH 09/12] Updated VerifyNoK8sDownloadCache test --- test/integration/no_kubernetes_test.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 172335bcbdf9..18a2d4181387 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -87,18 +87,23 @@ func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0") - // Printing Cache files for debugging purposes + // Check if the cache directory exists at all t.Logf("Checking cache directory: %s", cachePath) - if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 { - t.Logf("Files found in cache after --no-kubernetes start:") - for _, file := range files { - t.Logf(" - %s", file) + if _, err := os.Stat(cachePath); err == nil { + // Directory exists - let's see what's in it for debugging + if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 { + t.Logf("Files found in cache directory:") + for _, file := range files { + t.Logf(" - %s", file) + } + } else { + t.Logf("Cache directory exists but is empty") } - t.Errorf("Cache directory %s should not contain files when using --no-kubernetes, but found %d files", cachePath, len(files)) - } else if err != nil && !os.IsNotExist(err) { - t.Errorf("Error checking cache directory %s: %v", cachePath, err) + t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath) + } else if os.IsNotExist(err) { + t.Logf("No cache directory found (as expected)") } else { - t.Logf("No files found in cache directory after --no-kubernetes start (as expected)") + t.Errorf("Error checking cache directory %s: %v", cachePath, err) } } From cbd40f5ef48ef196ff9034d9e4d6a404cd3b7467 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Thu, 2 Oct 2025 17:17:09 +0530 Subject: [PATCH 10/12] ix Linux-specific cache directory creation in --no-kubernetes mode --- pkg/minikube/node/cache.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 733882110aa8..f57487913e92 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -53,6 +53,12 @@ const ( // BeginCacheKubernetesImages caches images required for Kubernetes version in the background func beginCacheKubernetesImages(g *errgroup.Group, imageRepository string, k8sVersion string, cRuntime string, driverName string) { + // Skip all caching operations in --no-kubernetes mode + if viper.GetBool("no-kubernetes") { + klog.Infof("Skipping Kubernetes image caching due to --no-kubernetes flag") + return + } + // TODO: remove imageRepository check once #7695 is fixed if imageRepository == "" && download.PreloadExists(k8sVersion, cRuntime, driverName) { klog.Info("Caching tarball of preloaded images") From acfd8b7155af18aff79ff1a575a474dfb6fd930f Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Thu, 9 Oct 2025 22:58:25 +0530 Subject: [PATCH 11/12] Added No-kubernetes flag check in TransferBinaries Function and also used GOOS to get the current OS --- pkg/minikube/bootstrapper/bsutil/binaries.go | 7 +++++++ test/integration/no_kubernetes_test.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/bootstrapper/bsutil/binaries.go b/pkg/minikube/bootstrapper/bsutil/binaries.go index 2800f489dfdd..f5cb91828be0 100644 --- a/pkg/minikube/bootstrapper/bsutil/binaries.go +++ b/pkg/minikube/bootstrapper/bsutil/binaries.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/pkg/errors" + "github.com/spf13/viper" "golang.org/x/sync/errgroup" "k8s.io/klog/v2" @@ -39,6 +40,12 @@ import ( // TransferBinaries transfers all required Kubernetes binaries func TransferBinaries(cfg config.KubernetesConfig, c command.Runner, sm sysinit.Manager, binariesURL string) error { + // Skip binary transfer in --no-kubernetes mode + if viper.GetBool("no-kubernetes") { + klog.Info("Skipping Kubernetes binary transfer due to --no-kubernetes flag") + return nil + } + ok, err := binariesExist(cfg, c) if err == nil && ok { klog.Info("Found k8s binaries, skipping transfer") diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 18a2d4181387..092849edcca7 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -85,7 +85,7 @@ func TestNoKubernetes(t *testing.T) { func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) - cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0") + cachePath := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, runtime.GOARCH, constants.NoKubernetesVersion) // Check if the cache directory exists at all t.Logf("Checking cache directory: %s", cachePath) From c4345f2baa4ca80c4898fac9368be2207cfcb3f0 Mon Sep 17 00:00:00 2001 From: Divy Singhvi Date: Sun, 9 Nov 2025 18:40:19 +0530 Subject: [PATCH 12/12] Updated test to not fail when directory is present --- test/integration/no_kubernetes_test.go | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/test/integration/no_kubernetes_test.go b/test/integration/no_kubernetes_test.go index 092849edcca7..096879cd5a1d 100644 --- a/test/integration/no_kubernetes_test.go +++ b/test/integration/no_kubernetes_test.go @@ -22,7 +22,6 @@ import ( "context" "encoding/json" "fmt" - "os" "os/exec" "path/filepath" "runtime" @@ -87,23 +86,16 @@ func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) cachePath := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, runtime.GOARCH, constants.NoKubernetesVersion) - // Check if the cache directory exists at all t.Logf("Checking cache directory: %s", cachePath) - if _, err := os.Stat(cachePath); err == nil { - // Directory exists - let's see what's in it for debugging - if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 { - t.Logf("Files found in cache directory:") - for _, file := range files { - t.Logf(" - %s", file) - } - } else { - t.Logf("Cache directory exists but is empty") - } - t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath) - } else if os.IsNotExist(err) { - t.Logf("No cache directory found (as expected)") - } else { - t.Errorf("Error checking cache directory %s: %v", cachePath, err) + files, err := filepath.Glob(filepath.Join(cachePath, "*")) + if err != nil { + t.Errorf("Error reading cache directory: %v", err) + return + } + + if len(files) > 0 { + t.Logf("Files found in cache directory: %v", files) + t.Errorf("Cache directory should not contain files when using --no-kubernetes") } }