diff --git a/cmd/minikube/cmd/cache.go b/cmd/minikube/cmd/cache.go index 65b16f5ab5..144e082cfe 100644 --- a/cmd/minikube/cmd/cache.go +++ b/cmd/minikube/cmd/cache.go @@ -18,12 +18,13 @@ package cmd import ( "fmt" + "os" + "github.com/spf13/cobra" cmdConfig "k8s.io/minikube/cmd/minikube/cmd/config" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/machine" - "os" ) // cacheCmd represents the cache command @@ -41,12 +42,12 @@ var addCacheCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // Cache and load images into docker daemon if err := machine.CacheAndLoadImages(args); err != nil { - fmt.Fprintf(os.Stderr, "Error caching and loading images: %s\n", err) + fmt.Fprintf(os.Stderr, "Error caching and loading images: %v\n", err) os.Exit(1) } // Add images to config file if err := cmdConfig.AddToConfigMap(constants.Cache, args); err != nil { - fmt.Fprintf(os.Stderr, "Error adding cached images to config file: %s\n", err) + fmt.Fprintf(os.Stderr, "Error adding cached images to config file: %v\n", err) os.Exit(1) } }, @@ -60,12 +61,12 @@ var deleteCacheCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // Delete images from config file if err := cmdConfig.DeleteFromConfigMap(constants.Cache, args); err != nil { - fmt.Fprintf(os.Stderr, "Error deleting images from config file: %s\n", err) + fmt.Fprintf(os.Stderr, "Error deleting images from config file: %v\n", err) os.Exit(1) } // Delete images from cache/images directory if err := machine.DeleteFromImageCacheDir(args); err != nil { - fmt.Fprintf(os.Stderr, "Error deleting images: %s\n", err) + fmt.Fprintf(os.Stderr, "Error deleting images: %v\n", err) os.Exit(1) } }, diff --git a/cmd/minikube/cmd/cache_list.go b/cmd/minikube/cmd/cache_list.go index 0549ca8eb7..d22e781d80 100644 --- a/cmd/minikube/cmd/cache_list.go +++ b/cmd/minikube/cmd/cache_list.go @@ -41,11 +41,11 @@ var listCacheCmd = &cobra.Command{ // list images from config file images, err := cmdConfig.ListConfigMap(constants.Cache) if err != nil { - fmt.Fprintf(os.Stderr, "Error listing image entries from config: %s\n", err) + fmt.Fprintf(os.Stderr, "Error listing image entries from config: %v\n", err) os.Exit(1) } if err := cacheList(images); err != nil { - fmt.Fprintf(os.Stderr, "Error listing images: %s\n", err) + fmt.Fprintf(os.Stderr, "Error listing images: %v\n", err) os.Exit(1) } }, @@ -62,13 +62,13 @@ func cacheList(images []string) error { for _, image := range images { tmpl, err := template.New("list").Parse(cacheListFormat) if err != nil { - fmt.Fprintf(os.Stderr, "Error creating list template: %s\n", err) + fmt.Fprintf(os.Stderr, "Error creating list template: %v\n", err) os.Exit(1) } listTmplt := CacheListTemplate{image} err = tmpl.Execute(os.Stdout, listTmplt) if err != nil { - fmt.Fprintf(os.Stderr, "Error executing list template: %s\n", err) + fmt.Fprintf(os.Stderr, "Error executing list template: %v\n", err) os.Exit(1) } } diff --git a/cmd/minikube/cmd/config/config_test.go b/cmd/minikube/cmd/config/config_test.go index 4f86544b9c..242270ae5b 100644 --- a/cmd/minikube/cmd/config/config_test.go +++ b/cmd/minikube/cmd/config/config_test.go @@ -80,7 +80,7 @@ func TestHiddenPrint(t *testing.T) { } result, err := concealableAskForStaticValue(b, "hello", false) if err != nil && !test.ShouldError { - t.Errorf("Error asking for concealable static value: %s", err) + t.Errorf("Error asking for concealable static value: %v", err) continue } if result != test.TestString { @@ -94,7 +94,7 @@ func TestWriteConfig(t *testing.T) { for _, tt := range configTestCases { err := encode(&b, tt.config) if err != nil { - t.Errorf("Error encoding: %s", err) + t.Errorf("Error encoding: %v", err) } if b.String() != tt.data { t.Errorf("Did not write config correctly, \n\n expected:\n %+v \n\n actual:\n %+v", tt.data, b.String()) diff --git a/cmd/minikube/cmd/config/open.go b/cmd/minikube/cmd/config/open.go index cef38512c9..fae6c10242 100644 --- a/cmd/minikube/cmd/config/open.go +++ b/cmd/minikube/cmd/config/open.go @@ -61,7 +61,7 @@ var addonsOpenCmd = &cobra.Command{ //TODO(r2d4): config should not reference API, pull this out api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() @@ -91,7 +91,7 @@ minikube addons enable %s`, addonName, addonName)) serviceList, err := service.GetServiceListByLabel(namespace, key, addonName) if err != nil { - fmt.Fprintf(os.Stderr, "Error getting service with namespace: %s and labels %s:%s: %s\n", namespace, key, addonName, err) + fmt.Fprintf(os.Stderr, "Error getting service with namespace: %s and labels %s:%s: %v\n", namespace, key, addonName, err) os.Exit(1) } if len(serviceList.Items) == 0 { diff --git a/cmd/minikube/cmd/config/util.go b/cmd/minikube/cmd/config/util.go index 44ca8ea2fc..e4d51decfd 100644 --- a/cmd/minikube/cmd/config/util.go +++ b/cmd/minikube/cmd/config/util.go @@ -104,7 +104,7 @@ func EnableOrDisableAddon(name string, val string) error { //TODO(r2d4): config package should not reference API, pull this out api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/minikube/cmd/config/util_test.go b/cmd/minikube/cmd/config/util_test.go index d140227573..274b1525d6 100644 --- a/cmd/minikube/cmd/config/util_test.go +++ b/cmd/minikube/cmd/config/util_test.go @@ -38,7 +38,7 @@ func TestFindSettingNotFound(t *testing.T) { func TestFindSetting(t *testing.T) { s, err := findSetting("vm-driver") if err != nil { - t.Fatalf("Couldn't find setting, vm-driver: %s", err) + t.Fatalf("Couldn't find setting, vm-driver: %v", err) } if s.name != "vm-driver" { t.Fatalf("Found wrong setting, expected vm-driver, got %s", s.name) @@ -48,14 +48,14 @@ func TestFindSetting(t *testing.T) { func TestSetString(t *testing.T) { err := SetString(minikubeConfig, "vm-driver", "virtualbox") if err != nil { - t.Fatalf("Couldnt set string: %s", err) + t.Fatalf("Couldnt set string: %v", err) } } func TestSetInt(t *testing.T) { err := SetInt(minikubeConfig, "cpus", "22") if err != nil { - t.Fatalf("Couldn't set int in config: %s", err) + t.Fatalf("Couldn't set int in config: %v", err) } val, ok := minikubeConfig["cpus"].(int) if !ok { @@ -69,7 +69,7 @@ func TestSetInt(t *testing.T) { func TestSetBool(t *testing.T) { err := SetBool(minikubeConfig, "show-libmachine-logs", "true") if err != nil { - t.Fatalf("Couldn't set bool in config: %s", err) + t.Fatalf("Couldn't set bool in config: %v", err) } val, ok := minikubeConfig["show-libmachine-logs"].(bool) if !ok { diff --git a/cmd/minikube/cmd/dashboard.go b/cmd/minikube/cmd/dashboard.go index 362e888694..f1bb1572a0 100644 --- a/cmd/minikube/cmd/dashboard.go +++ b/cmd/minikube/cmd/dashboard.go @@ -44,7 +44,7 @@ var dashboardCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() @@ -54,7 +54,7 @@ var dashboardCmd = &cobra.Command{ svc := "kubernetes-dashboard" if err = commonutil.RetryAfter(20, func() error { return service.CheckService(namespace, svc) }, 6*time.Second); err != nil { - fmt.Fprintf(os.Stderr, "Could not find finalized endpoint being pointed to by %s: %s\n", svc, err) + fmt.Fprintf(os.Stderr, "Could not find finalized endpoint being pointed to by %s: %v\n", svc, err) os.Exit(1) } diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 54ec6abe18..7259aaa4c4 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -44,7 +44,7 @@ associated files.`, fmt.Println("Deleting local Kubernetes cluster...") api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/minikube/cmd/env.go b/cmd/minikube/cmd/env.go index d5a0cf4ad8..7e467836b3 100644 --- a/cmd/minikube/cmd/env.go +++ b/cmd/minikube/cmd/env.go @@ -302,13 +302,13 @@ var dockerEnvCmd = &cobra.Command{ api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() host, err := cluster.CheckIfApiExistsAndLoad(api) if err != nil { - fmt.Fprintf(os.Stderr, "Error getting host: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting host: %v\n", err) os.Exit(1) } if host.Driver.DriverName() == "none" { diff --git a/cmd/minikube/cmd/env_test.go b/cmd/minikube/cmd/env_test.go index 338183ae48..408579f99a 100644 --- a/cmd/minikube/cmd/env_test.go +++ b/cmd/minikube/cmd/env_test.go @@ -244,7 +244,7 @@ func TestShellCfgSet(t *testing.T) { t.Errorf("Shell cfgs differ: expected %+v, \n\n got %+v", test.expectedShellCfg, shellCfg) } if err != nil && !test.shouldErr { - t.Errorf("Test should have failed but didn't return error: %s, error: %s", test.description, err) + t.Errorf("Test should have failed but didn't return error: %s, error: %v", test.description, err) } if err == nil && test.shouldErr { t.Errorf("Test didn't return error but should have: %s", test.description) diff --git a/cmd/minikube/cmd/ip.go b/cmd/minikube/cmd/ip.go index 65985a59e0..0c5ad830bd 100644 --- a/cmd/minikube/cmd/ip.go +++ b/cmd/minikube/cmd/ip.go @@ -34,7 +34,7 @@ var ipCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/minikube/cmd/logs.go b/cmd/minikube/cmd/logs.go index fa21d551d1..813cb653d9 100644 --- a/cmd/minikube/cmd/logs.go +++ b/cmd/minikube/cmd/logs.go @@ -41,13 +41,13 @@ var logsCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() clusterBootstrapper, err := GetClusterBootstrapper(api, viper.GetString(cmdcfg.Bootstrapper)) if err != nil { - glog.Exitf("Error getting cluster bootstrapper: %s", err) + glog.Exitf("Error getting cluster bootstrapper: %v", err) } err = clusterBootstrapper.GetClusterLogsTo(follow, os.Stdout) diff --git a/cmd/minikube/cmd/mount.go b/cmd/minikube/cmd/mount.go index a4367701ae..e286c6dd3e 100644 --- a/cmd/minikube/cmd/mount.go +++ b/cmd/minikube/cmd/mount.go @@ -93,7 +93,7 @@ var mountCmd = &cobra.Command{ } api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 0bae9b70fe..60accb97d4 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -70,7 +70,7 @@ var RootCmd = &cobra.Command{ PersistentPreRun: func(cmd *cobra.Command, args []string) { for _, path := range dirs { if err := os.MkdirAll(path, 0777); err != nil { - glog.Exitf("Error creating minikube directory: %s", err) + glog.Exitf("Error creating minikube directory: %v", err) } } @@ -143,7 +143,7 @@ func initConfig() { viper.SetConfigType("json") err := viper.ReadInConfig() if err != nil { - glog.Warningf("Error reading config file at %s: %s", configPath, err) + glog.Warningf("Error reading config file at %s: %v", configPath, err) } setupViper() } diff --git a/cmd/minikube/cmd/service.go b/cmd/minikube/cmd/service.go index bd9fa4274e..135a805aea 100644 --- a/cmd/minikube/cmd/service.go +++ b/cmd/minikube/cmd/service.go @@ -65,7 +65,7 @@ var serviceCmd = &cobra.Command{ svc := args[0] api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() @@ -74,7 +74,7 @@ var serviceCmd = &cobra.Command{ err = service.WaitAndMaybeOpenService(api, namespace, svc, serviceURLTemplate, serviceURLMode, https, wait, interval) if err != nil { - fmt.Fprintf(os.Stderr, "Error opening service: %s\n", err) + fmt.Fprintf(os.Stderr, "Error opening service: %v\n", err) os.Exit(1) } }, diff --git a/cmd/minikube/cmd/service_list.go b/cmd/minikube/cmd/service_list.go index e3febc2665..7d02756c7d 100644 --- a/cmd/minikube/cmd/service_list.go +++ b/cmd/minikube/cmd/service_list.go @@ -39,7 +39,7 @@ var serviceListCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/minikube/cmd/ssh.go b/cmd/minikube/cmd/ssh.go index 8a26f537f8..26d687010d 100644 --- a/cmd/minikube/cmd/ssh.go +++ b/cmd/minikube/cmd/ssh.go @@ -35,13 +35,13 @@ var sshCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() host, err := cluster.CheckIfApiExistsAndLoad(api) if err != nil { - fmt.Fprintf(os.Stderr, "Error getting host: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting host: %v\n", err) os.Exit(1) } if host.Driver.DriverName() == "none" { diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 3b9d136e33..84fb56aeac 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -112,14 +112,14 @@ func runStart(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() exists, err := api.Exists(cfg.GetMachineName()) if err != nil { - glog.Exitf("checking if machine exists: %s", err) + glog.Exitf("checking if machine exists: %v", err) } diskSize := viper.GetString(humanReadableDiskSize) @@ -165,7 +165,7 @@ func runStart(cmd *cobra.Command, args []string) { start := func() (err error) { host, err = cluster.StartHost(api, config) if err != nil { - glog.Errorf("Error starting host: %s.\n\n Retrying.\n", err) + glog.Errorf("Error starting host: %v.\n\n Retrying.\n", err) } return err } @@ -228,7 +228,7 @@ func runStart(cmd *cobra.Command, args []string) { k8sBootstrapper, err := GetClusterBootstrapper(api, clusterBootstrapper) if err != nil { - glog.Exitf("Error getting cluster bootstrapper: %s", err) + glog.Exitf("Error getting cluster bootstrapper: %v", err) } // Write profile cluster configuration to file @@ -321,12 +321,12 @@ func runStart(cmd *cobra.Command, args []string) { } err = mountCmd.Start() if err != nil { - glog.Errorf("Error running command minikube mount %s", err) + glog.Errorf("Error running command minikube mount %v", err) cmdutil.MaybeReportErrorAndExit(err) } err = ioutil.WriteFile(filepath.Join(constants.GetMinipath(), constants.MountProcessFileName), []byte(strconv.Itoa(mountCmd.Process.Pid)), 0644) if err != nil { - glog.Errorf("Error writing mount process pid to file: %s", err) + glog.Errorf("Error writing mount process pid to file: %v", err) cmdutil.MaybeReportErrorAndExit(err) } } diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index 6c74d7031e..f7e75629f4 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -61,7 +61,7 @@ var statusCmd = &cobra.Command{ var returnCode = 0 api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(internalErrorCode) } defer api.Close() @@ -77,7 +77,7 @@ var statusCmd = &cobra.Command{ if ms == state.Running.String() { clusterBootstrapper, err := GetClusterBootstrapper(api, viper.GetString(cmdcfg.Bootstrapper)) if err != nil { - glog.Errorf("Error getting cluster bootstrapper: %s", err) + glog.Errorf("Error getting cluster bootstrapper: %v", err) cmdUtil.MaybeReportErrorAndExitWithCode(err, internalErrorCode) } cs, err = clusterBootstrapper.GetClusterStatus() diff --git a/cmd/minikube/cmd/stop.go b/cmd/minikube/cmd/stop.go index 416e98259d..7097830911 100644 --- a/cmd/minikube/cmd/stop.go +++ b/cmd/minikube/cmd/stop.go @@ -36,7 +36,7 @@ itself, leaving all files intact. The cluster can be started again with the "sta fmt.Println("Stopping local Kubernetes cluster...") api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/minikube/cmd/update-context.go b/cmd/minikube/cmd/update-context.go index 3f1976dcf6..8463a8e0f3 100644 --- a/cmd/minikube/cmd/update-context.go +++ b/cmd/minikube/cmd/update-context.go @@ -39,7 +39,7 @@ var updateContextCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { api, err := machine.NewAPIClient() if err != nil { - fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err) + fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err) os.Exit(1) } defer api.Close() diff --git a/cmd/storage-provisioner/main.go b/cmd/storage-provisioner/main.go index 2e9622847a..ee17b091bc 100644 --- a/cmd/storage-provisioner/main.go +++ b/cmd/storage-provisioner/main.go @@ -28,7 +28,7 @@ import ( func main() { // Glog requires that /tmp exists. if err := os.MkdirAll("/tmp", 0755); err != nil { - fmt.Printf("Error creating tmpdir: %s\n", err) + fmt.Printf("Error creating tmpdir: %v\n", err) os.Exit(1) } flag.Parse() diff --git a/cmd/util/util_test.go b/cmd/util/util_test.go index 172a49789a..1fcb4b55c0 100644 --- a/cmd/util/util_test.go +++ b/cmd/util/util_test.go @@ -48,7 +48,7 @@ func TestFormatError(t *testing.T) { _, err := FormatError(testErr) if err != nil { - t.Fatalf("Unexpected error: %s", err) + t.Fatalf("Unexpected error: %v", err) } } @@ -59,7 +59,7 @@ func TestMarshallError(t *testing.T) { errMsg, _ := FormatError(testErr) if _, err := MarshallError(errMsg, "default", version.GetVersion()); err != nil { - t.Fatalf("Unexpected error: %s", err) + t.Fatalf("Unexpected error: %v", err) } } @@ -75,7 +75,7 @@ func TestUploadError(t *testing.T) { })) if err := UploadError(jsonErrMsg, server.URL); err != nil { - t.Fatalf("Unexpected error: %s", err) + t.Fatalf("Unexpected error: %v", err) } server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/deploy/minikube/release_sanity_test.go b/deploy/minikube/release_sanity_test.go index 61ccac2344..7aedbabaf7 100644 --- a/deploy/minikube/release_sanity_test.go +++ b/deploy/minikube/release_sanity_test.go @@ -50,7 +50,7 @@ func getShaFromURL(url string) (string, error) { func TestReleasesJson(t *testing.T) { releases, err := notify.GetAllVersionsFromURL(constants.GithubMinikubeReleasesURL) if err != nil { - t.Fatalf("Error getting releases.json: %s", err) + t.Fatalf("Error getting releases.json: %v", err) } for _, r := range releases { @@ -59,7 +59,7 @@ func TestReleasesJson(t *testing.T) { fmt.Printf("Checking SHA for %s.\n", platform) actualSha, err := getShaFromURL(util.GetBinaryDownloadURL(r.Name, platform)) if err != nil { - t.Errorf("Error calculating SHA for %s-%s. Error: %s", r.Name, platform, err) + t.Errorf("Error calculating SHA for %s-%s. Error: %v", r.Name, platform, err) continue } if actualSha != sha { diff --git a/pkg/drivers/hyperkit/driver.go b/pkg/drivers/hyperkit/driver.go index 41a42b122f..702f5cf19c 100644 --- a/pkg/drivers/hyperkit/driver.go +++ b/pkg/drivers/hyperkit/driver.go @@ -151,7 +151,7 @@ func (d *Driver) Kill() error { func (d *Driver) Remove() error { s, err := d.GetState() if err != nil || s == state.Error { - log.Infof("Error checking machine status: %s, assuming it has been removed already", err) + log.Infof("Error checking machine status: %v, assuming it has been removed already", err) } if s == state.Running { if err := d.Stop(); err != nil { @@ -229,7 +229,8 @@ func (d *Driver) Start() error { time.Sleep(time.Second * 30) err = d.setupNFSShare() if err != nil { - log.Errorf("NFS setup failed: %s", err.Error()) + // TODO(tstromberg): Check that logging an and error and return it is appropriate. Seems weird. + log.Errorf("NFS setup failed: %v", err) return err } } @@ -350,13 +351,13 @@ func (d *Driver) getPid() int { f, err := os.Open(pidPath) if err != nil { - log.Warnf("Error reading pid file: %s", err) + log.Warnf("Error reading pid file: %v", err) return 0 } dec := json.NewDecoder(f) config := hyperkit.HyperKit{} if err := dec.Decode(&config); err != nil { - log.Warnf("Error decoding pid file: %s", err) + log.Warnf("Error decoding pid file: %v", err) return 0 } @@ -368,12 +369,12 @@ func (d *Driver) cleanupNfsExports() { log.Infof("You must be root to remove NFS shared folders. Please type root password.") for _, share := range d.NFSShares { if _, err := nfsexports.Remove("", d.nfsExportIdentifier(share)); err != nil { - log.Errorf("failed removing nfs share (%s): %s", share, err.Error()) + log.Errorf("failed removing nfs share (%s): %v", share, err) } } if err := nfsexports.ReloadDaemon(); err != nil { - log.Errorf("failed to reload the nfs daemon: %s", err.Error()) + log.Errorf("failed to reload the nfs daemon: %v", err } } } diff --git a/pkg/drivers/kvm/kvm.go b/pkg/drivers/kvm/kvm.go index b1bc7811da..3536c7ef44 100644 --- a/pkg/drivers/kvm/kvm.go +++ b/pkg/drivers/kvm/kvm.go @@ -356,7 +356,7 @@ func (d *Driver) Stop() error { } - return fmt.Errorf("Could not stop VM, current state %s", s.String()) + return fmt.Errorf("Could not stop VM, current state %s", s.String() } func (d *Driver) Remove() error { @@ -370,7 +370,7 @@ func (d *Driver) Remove() error { // Tear down network if it exists and is not in use by another minikube instance log.Debug("Trying to delete the networks (if possible)") if err := d.deleteNetwork(); err != nil { - log.Warnf("Deleting of networks failed: %s", err.Error()) + log.Warnf("Deleting of networks failed: %v", err) } else { log.Info("Successfully deleted networks") } diff --git a/pkg/drivers/kvm/network.go b/pkg/drivers/kvm/network.go index ad81bb460f..a3f6ce2f1d 100644 --- a/pkg/drivers/kvm/network.go +++ b/pkg/drivers/kvm/network.go @@ -277,7 +277,7 @@ func (d *Driver) lookupIPFromStatusFile(conn *libvirt.Connect) (string, error) { bridge, err := network.GetBridgeName() if err != nil { - log.Warnf("Failed to get network bridge: %s", err) + log.Warnf("Failed to get network bridge: %v", err) return "", err } statusFile := fmt.Sprintf("/var/lib/libvirt/dnsmasq/%s.status", bridge) diff --git a/pkg/drivers/none/none.go b/pkg/drivers/none/none.go index a023914a97..517d1dd35a 100644 --- a/pkg/drivers/none/none.go +++ b/pkg/drivers/none/none.go @@ -124,7 +124,7 @@ func (d *Driver) Kill() error { } { cmd := exec.Command("sudo", cmdStr...) if out, err := cmd.CombinedOutput(); err != nil { - glog.Warningf("Error %s running command: %s. Output: %s", err, cmdStr, string(out)) + glog.Warningf("Error %v running command: %s. Output: %s", err, cmdStr, out) } } return nil @@ -138,7 +138,7 @@ func (d *Driver) Remove() error { for _, cmdStr := range []string{rmCmd, dockerkillcmd} { if out, err := runCommand(cmdStr, true); err != nil { - glog.Warningf("Error %s running command: %s, Output: %s", err, cmdStr, out) + glog.Warningf("Error %v running command: %s, Output: %s", err, cmdStr, out) } } @@ -192,7 +192,7 @@ fi } } if out, err := runCommand(dockerstopcmd, false); err != nil { - glog.Warningf("Error %s running command %s. Output: %s", err, dockerstopcmd, out) + glog.Warningf("Error %v running command %s. Output: %s", err, dockerstopcmd, out) } return nil } diff --git a/pkg/minikube/bootstrapper/certs_test.go b/pkg/minikube/bootstrapper/certs_test.go index c72d1614b2..3860d0ca5d 100644 --- a/pkg/minikube/bootstrapper/certs_test.go +++ b/pkg/minikube/bootstrapper/certs_test.go @@ -44,7 +44,7 @@ func TestSetupCerts(t *testing.T) { } if err := SetupCerts(f, k8s); err != nil { - t.Fatalf("Error starting cluster: %s", err) + t.Fatalf("Error starting cluster: %v", err) } for _, cert := range filesToBeTransferred { _, err := f.GetFileToContents(cert) diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go index a55cc96e62..56938c351b 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go @@ -234,7 +234,7 @@ schedulerExtraArgs: t.Run(test.description, func(t *testing.T) { actualCfg, err := generateConfig(test.cfg) if err != nil && !test.shouldErr { - t.Errorf("got unexpected error generating config: %s", err) + t.Errorf("got unexpected error generating config: %v", err) return } if err == nil && test.shouldErr { diff --git a/pkg/minikube/bootstrapper/kubeadm/versions_test.go b/pkg/minikube/bootstrapper/kubeadm/versions_test.go index 0d74cb4df1..3f7a8bb3f7 100644 --- a/pkg/minikube/bootstrapper/kubeadm/versions_test.go +++ b/pkg/minikube/bootstrapper/kubeadm/versions_test.go @@ -96,7 +96,7 @@ func TestVersionIsBetween(t *testing.T) { func TestParseKubernetesVersion(t *testing.T) { version, err := ParseKubernetesVersion("v1.8.0-alpha.5") if err != nil { - t.Fatalf("Error parsing version: %s", err) + t.Fatalf("Error parsing version: %v", err) } if version.NE(semver.MustParse("1.8.0-alpha.5")) { t.Errorf("Expected: %s, Actual:%s", "1.8.0-alpha.5", version) @@ -141,7 +141,7 @@ func TestParseFeatureArgs(t *testing.T) { kubeadm, component, err := ParseFeatureArgs(test.featureGates) if err != nil { - t.Fatalf("Error parsing feature args: %s", err) + t.Fatalf("Error parsing feature args: %v", err) } if !reflect.DeepEqual(kubeadm, test.expectedKubeadmFeatureArgs) { diff --git a/pkg/minikube/cluster/cluster_test.go b/pkg/minikube/cluster/cluster_test.go index 26e8b2ce9a..9fe1d65400 100644 --- a/pkg/minikube/cluster/cluster_test.go +++ b/pkg/minikube/cluster/cluster_test.go @@ -229,7 +229,7 @@ func TestDeleteHost(t *testing.T) { createHost(api, defaultMachineConfig) if err := DeleteHost(api); err != nil { - t.Fatalf("Unexpected error deleting host: %s", err) + t.Fatalf("Unexpected error deleting host: %v", err) } } @@ -274,7 +274,7 @@ func TestDeleteHostMultipleErrors(t *testing.T) { expectedErrors := []string{"Error removing " + config.GetMachineName(), "Error deleting machine"} for _, expectedError := range expectedErrors { if !strings.Contains(err.Error(), expectedError) { - t.Fatalf("Error %s expected to contain: %s.", err, expectedError) + t.Fatalf("Error %v expected to contain: %s.", err, expectedError) } } } @@ -285,7 +285,7 @@ func TestGetHostStatus(t *testing.T) { checkState := func(expected string) { s, err := GetHostStatus(api) if err != nil { - t.Fatalf("Unexpected error getting status: %s", err) + t.Fatalf("Unexpected error getting status: %v", err) } if s != expected { t.Fatalf("Expected status: %s, got %s", s, expected) @@ -319,7 +319,7 @@ func TestGetHostDockerEnv(t *testing.T) { envMap, err := GetHostDockerEnv(api) if err != nil { - t.Fatalf("Unexpected error getting env: %s", err) + t.Fatalf("Unexpected error getting env: %v", err) } dockerEnvKeys := [...]string{ @@ -352,7 +352,7 @@ func TestGetHostDockerEnvIPv6(t *testing.T) { envMap, err := GetHostDockerEnv(api) if err != nil { - t.Fatalf("Unexpected error getting env: %s", err) + t.Fatalf("Unexpected error getting env: %v", err) } expected := "tcp://[fe80::215:5dff:fe00:a903]:2376" @@ -368,7 +368,7 @@ func TestCreateSSHShell(t *testing.T) { s, _ := tests.NewSSHServer() port, err := s.Start() if err != nil { - t.Fatalf("Error starting ssh server: %s", err) + t.Fatalf("Error starting ssh server: %v", err) } d := &tests.MockDriver{ @@ -383,7 +383,7 @@ func TestCreateSSHShell(t *testing.T) { cliArgs := []string{"exit"} if err := CreateSSHShell(api, cliArgs); err != nil { - t.Fatalf("Error running ssh command: %s", err) + t.Fatalf("Error running ssh command: %v", err) } if !s.IsSessionRequested() { diff --git a/pkg/minikube/cluster/cluster_windows.go b/pkg/minikube/cluster/cluster_windows.go index b0d98dc831..21f2b94dc9 100644 --- a/pkg/minikube/cluster/cluster_windows.go +++ b/pkg/minikube/cluster/cluster_windows.go @@ -62,7 +62,7 @@ func detectVBoxManageCmd() string { func findVBoxInstallDirInRegistry() (string, error) { registryKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Oracle\VirtualBox`, registry.QUERY_VALUE) if err != nil { - errorMessage := fmt.Sprintf("Can't find VirtualBox registry entries, is VirtualBox really installed properly? %s", err) + errorMessage := fmt.Sprintf("Can't find VirtualBox registry entries, is VirtualBox really installed properly? %v", err) glog.Errorf(errorMessage) return "", errors.New(errorMessage) } @@ -71,7 +71,7 @@ func findVBoxInstallDirInRegistry() (string, error) { installDir, _, err := registryKey.GetStringValue("InstallDir") if err != nil { - errorMessage := fmt.Sprintf("Can't find InstallDir registry key within VirtualBox registries entries, is VirtualBox really installed properly? %s", err) + errorMessage := fmt.Sprintf("Can't find InstallDir registry key within VirtualBox registries entries, is VirtualBox really installed properly? %v", err) glog.Errorf(errorMessage) return "", errors.New(errorMessage) } diff --git a/pkg/minikube/config/config.go b/pkg/minikube/config/config.go index 8a53d54b2b..dd7b4b231c 100644 --- a/pkg/minikube/config/config.go +++ b/pkg/minikube/config/config.go @@ -63,13 +63,13 @@ func ReadConfig() (MinikubeConfig, error) { if os.IsNotExist(err) { return make(map[string]interface{}), nil } - return nil, fmt.Errorf("Could not open file %s: %s", constants.ConfigFile, err) + return nil, fmt.Errorf("Could not open file %s: %v", constants.ConfigFile, err) } defer f.Close() m, err := decode(f) if err != nil { - return nil, fmt.Errorf("Could not decode config %s: %s", constants.ConfigFile, err) + return nil, fmt.Errorf("Could not decode config %s: %v", constants.ConfigFile, err) } return m, nil diff --git a/pkg/minikube/machine/cache_images_test.go b/pkg/minikube/machine/cache_images_test.go index 5f28a94653..6cf9ead4ac 100644 --- a/pkg/minikube/machine/cache_images_test.go +++ b/pkg/minikube/machine/cache_images_test.go @@ -26,7 +26,7 @@ import ( func TestReplaceWinDriveLetterToVolumeName(t *testing.T) { path, err := ioutil.TempDir("", "repwindl2vn") if err != nil { - t.Fatalf("Error make tmp directory: %s", err) + t.Fatalf("Error make tmp directory: %v", err) } defer os.RemoveAll(path) @@ -40,7 +40,7 @@ func TestReplaceWinDriveLetterToVolumeName(t *testing.T) { } if _, err := replaceWinDriveLetterToVolumeName(path); err != nil { - t.Errorf("Error replace a Windows drive letter to a volume name: %s", err) + t.Errorf("Error replace a Windows drive letter to a volume name: %v", err) } } diff --git a/pkg/minikube/machine/client_test.go b/pkg/minikube/machine/client_test.go index 6671449181..06fed6d801 100644 --- a/pkg/minikube/machine/client_test.go +++ b/pkg/minikube/machine/client_test.go @@ -102,7 +102,7 @@ func TestLocalClientNewHost(t *testing.T) { } } if err != nil && !test.err { - t.Errorf("Unexpected error: %s", err) + t.Errorf("Unexpected error: %v", err) } if err == nil && test.err { t.Errorf("No error returned, but expected err") diff --git a/pkg/minikube/service/service.go b/pkg/minikube/service/service.go index 2fb7c82a2d..e36ccb52c7 100644 --- a/pkg/minikube/service/service.go +++ b/pkg/minikube/service/service.go @@ -76,7 +76,7 @@ func (*K8sClientGetter) GetClientset() (*kubernetes.Clientset, error) { kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) clientConfig, err := kubeConfig.ClientConfig() if err != nil { - return nil, fmt.Errorf("Error creating kubeConfig: %s", err) + return nil, fmt.Errorf("Error creating kubeConfig: %v", err) } client, err := kubernetes.NewForConfig(clientConfig) if err != nil { diff --git a/pkg/minikube/service/service_test.go b/pkg/minikube/service/service_test.go index f28bce3f97..81d8929f6e 100644 --- a/pkg/minikube/service/service_test.go +++ b/pkg/minikube/service/service_test.go @@ -274,7 +274,7 @@ func TestPrintURLsForService(t *testing.T) { t.Parallel() urls, err := printURLsForService(client, "127.0.0.1", test.serviceName, test.namespace, test.tmpl) if err != nil && !test.err { - t.Errorf("Error: %s", err) + t.Errorf("Error: %v", err) } if err == nil && test.err { t.Errorf("Expected error but got none") @@ -398,7 +398,7 @@ func TestGetServiceURLs(t *testing.T) { } urls, err := GetServiceURLs(test.api, test.namespace, defaultTemplate) if err != nil && !test.err { - t.Errorf("Error GetServiceURLs %s", err) + t.Errorf("Error GetServiceURLs %v", err) } if err == nil && test.err { t.Errorf("Test should have failed, but didn't") @@ -461,7 +461,7 @@ func TestGetServiceURLsForService(t *testing.T) { } urls, err := GetServiceURLsForService(test.api, test.namespace, test.service, defaultTemplate) if err != nil && !test.err { - t.Errorf("Error GetServiceURLsForService %s", err) + t.Errorf("Error GetServiceURLsForService %v", err) } if err == nil && test.err { t.Errorf("Test should have failed, but didn't") diff --git a/pkg/minikube/sshutil/sshutil_test.go b/pkg/minikube/sshutil/sshutil_test.go index fb0972d1e1..8d9280e2a9 100644 --- a/pkg/minikube/sshutil/sshutil_test.go +++ b/pkg/minikube/sshutil/sshutil_test.go @@ -28,7 +28,7 @@ func TestNewSSHClient(t *testing.T) { s, _ := tests.NewSSHServer() port, err := s.Start() if err != nil { - t.Fatalf("Error starting ssh server: %s", err) + t.Fatalf("Error starting ssh server: %v", err) } d := &tests.MockDriver{ Port: port, @@ -39,7 +39,7 @@ func TestNewSSHClient(t *testing.T) { } c, err := NewSSHClient(d) if err != nil { - t.Fatalf("Unexpected error: %s", err) + t.Fatalf("Unexpected error: %v", err) } cmd := "foo" @@ -75,7 +75,7 @@ func TestNewSSHHost(t *testing.T) { h, err := newSSHHost(&d) if err != nil { - t.Fatalf("Unexpected error creating host: %s", err) + t.Fatalf("Unexpected error creating host: %v", err) } if h.SSHKeyPath != sshKeyPath { diff --git a/pkg/minikube/tests/ssh_mock.go b/pkg/minikube/tests/ssh_mock.go index 567a9ab562..2e2d0bdf83 100644 --- a/pkg/minikube/tests/ssh_mock.go +++ b/pkg/minikube/tests/ssh_mock.go @@ -120,7 +120,7 @@ func (s *SSHServer) Start() (int, error) { // Note: string(req.Payload) adds additional characters to start of input. var cmd execRequest if err := ssh.Unmarshal(req.Payload, &cmd); err != nil { - glog.Errorf("Unmarshall encountered error: %s with req: %v", err, req.Type) + glog.Errorf("Unmarshall encountered error: %v with req: %v", err, req.Type) return } s.Commands[cmd.Command] = 1 diff --git a/pkg/provision/buildroot.go b/pkg/provision/buildroot.go index 088e3202c4..b558b05eb8 100644 --- a/pkg/provision/buildroot.go +++ b/pkg/provision/buildroot.go @@ -208,7 +208,7 @@ CRIO_MINIKUBE_OPTIONS='{{ range .EngineOptions.InsecureRegistry }}--insecure-reg // This is unlikely to cause issues unless the user has explicitly requested CRIO, so just log a warning. if err := p.Service("crio", serviceaction.Restart); err != nil { - log.Warn("Unable to restart crio service. Error: %s", err) + log.Warn("Unable to restart crio service. Error: %v", err) } return nil @@ -264,7 +264,7 @@ func configureAuth(p *BuildrootProvisioner) error { }) if err != nil { - return fmt.Errorf("error generating server cert: %s", err) + return fmt.Errorf("error generating server cert: %v", err) } remoteCerts := map[string]string{ diff --git a/pkg/util/config.go b/pkg/util/config.go index 751fbae48f..fc62d9d4a4 100644 --- a/pkg/util/config.go +++ b/pkg/util/config.go @@ -66,19 +66,19 @@ func setElement(e reflect.Value, v string) error { case net.IPNet: _, cidr, err := net.ParseCIDR(v) if err != nil { - return fmt.Errorf("Error converting input %s to a CIDR: %s", v, err) + return fmt.Errorf("Error converting input %s to a CIDR: %v", v, err) } e.Set(reflect.ValueOf(*cidr)) case utilnet.PortRange: pr, err := utilnet.ParsePortRange(v) if err != nil { - return fmt.Errorf("Error converting input %s to PortRange: %s", v, err) + return fmt.Errorf("Error converting input %s to PortRange: %v", v, err) } e.Set(reflect.ValueOf(*pr)) case time.Duration: dur, err := time.ParseDuration(v) if err != nil { - return fmt.Errorf("Error converting input %s to Duration: %s", v, err) + return fmt.Errorf("Error converting input %s to Duration: %v", v, err) } e.Set(reflect.ValueOf(dur)) case []string: @@ -126,7 +126,7 @@ func convertMap(e reflect.Value, v string) error { func convertInt(e reflect.Value, v string) error { i, err := strconv.Atoi(v) if err != nil { - return fmt.Errorf("Error converting input %s to an integer: %s", v, err) + return fmt.Errorf("Error converting input %s to an integer: %v", v, err) } e.SetInt(int64(i)) return nil @@ -140,7 +140,7 @@ func convertString(e reflect.Value, v string) error { func convertFloat(e reflect.Value, v string) error { f, err := strconv.ParseFloat(v, 64) if err != nil { - return fmt.Errorf("Error converting input %s to a float: %s", v, err) + return fmt.Errorf("Error converting input %s to a float: %v", v, err) } e.SetFloat(f) return nil @@ -149,7 +149,7 @@ func convertFloat(e reflect.Value, v string) error { func convertBool(e reflect.Value, v string) error { b, err := strconv.ParseBool(v) if err != nil { - return fmt.Errorf("Error converting input %s to a bool: %s", v, err) + return fmt.Errorf("Error converting input %s to a bool: %v", v, err) } e.SetBool(b) return nil diff --git a/pkg/util/config_test.go b/pkg/util/config_test.go index 743f2abc2a..c261dbe34c 100644 --- a/pkg/util/config_test.go +++ b/pkg/util/config_test.go @@ -104,7 +104,7 @@ func TestFindNestedStrings(t *testing.T) { } { v, err := findNestedElement(tc.input, &a) if err != nil { - t.Fatalf("Did not expect error. Got: %s", err) + t.Fatalf("Did not expect error. Got: %v", err) } if v.String() != tc.output { t.Fatalf("Expected: %s, got %s", tc.output, v.String()) @@ -126,7 +126,7 @@ func TestFindNestedInts(t *testing.T) { } { v, err := findNestedElement(tc.input, &a) if err != nil { - t.Fatalf("Did not expect error. Got: %s", err) + t.Fatalf("Did not expect error. Got: %v", err) } if v.Int() != tc.output { t.Fatalf("Expected: %d, got %d", tc.output, v.Int()) @@ -151,7 +151,7 @@ func TestFindNestedFloats(t *testing.T) { } { v, err := findNestedElement(tc.input, &a) if err != nil { - t.Fatalf("Did not expect error. Got: %s", err) + t.Fatalf("Did not expect error. Got: %v", err) } // Floating point comparison is tricky. @@ -187,7 +187,7 @@ func TestSetElement(t *testing.T) { } { a := buildConfig() if err := FindAndSet(tc.path, &a, tc.newval); err != nil { - t.Fatalf("Error setting value: %s", err) + t.Fatalf("Error setting value: %v", err) } if !tc.checker(a) { t.Fatalf("Error, values not correct: %v, %s, %s", a, tc.newval, tc.path) diff --git a/pkg/util/downloader_test.go b/pkg/util/downloader_test.go index 933c23ddf1..1208127922 100644 --- a/pkg/util/downloader_test.go +++ b/pkg/util/downloader_test.go @@ -59,7 +59,7 @@ func TestCacheMinikubeISOFromURL(t *testing.T) { })) isoURL := server.URL + "/minikube-test.iso" if err := dler.CacheMinikubeISOFromURL(isoURL); err != nil { - t.Fatalf("Unexpected error from CacheMinikubeISOFromURL: %s", err) + t.Fatalf("Unexpected error from CacheMinikubeISOFromURL: %v", err) } transferred, err := ioutil.ReadFile(filepath.Join(isoPath)) diff --git a/pkg/util/extra_options_test.go b/pkg/util/extra_options_test.go index 04d12c43e5..852dcfc053 100644 --- a/pkg/util/extra_options_test.go +++ b/pkg/util/extra_options_test.go @@ -70,7 +70,7 @@ func TestValidFlags(t *testing.T) { var e ExtraOptionSlice flags.Var(&e, "e", "usage") if err := flags.Parse(tc.args); err != nil { - t.Errorf("Unexpected error: %s for %s.", err, tc) + t.Errorf("Unexpected error: %v for %s.", err, tc) } if !reflect.DeepEqual(e, tc.values) { diff --git a/pkg/util/kubeconfig/config_test.go b/pkg/util/kubeconfig/config_test.go index dd6a54cd98..f68ef8e217 100644 --- a/pkg/util/kubeconfig/config_test.go +++ b/pkg/util/kubeconfig/config_test.go @@ -143,7 +143,7 @@ func TestSetupKubeConfig(t *testing.T) { t.Parallel() tmpDir, err := ioutil.TempDir("", "") if err != nil { - t.Fatalf("Error making temp directory %s", err) + t.Fatalf("Error making temp directory %v", err) } test.cfg.SetKubeConfigFile(filepath.Join(tmpDir, "kubeconfig")) if len(test.existingCfg) != 0 { @@ -151,14 +151,14 @@ func TestSetupKubeConfig(t *testing.T) { } err = SetupKubeConfig(test.cfg) if err != nil && !test.err { - t.Errorf("Got unexpected error: %s", err) + t.Errorf("Got unexpected error: %v", err) } if err == nil && test.err { t.Errorf("Expected error but got none") } config, err := ReadConfigOrNew(test.cfg.GetKubeConfigFile()) if err != nil { - t.Errorf("Error reading kubeconfig file: %s", err) + t.Errorf("Error reading kubeconfig file: %v", err) } if test.cfg.KeepContext && config.CurrentContext == test.cfg.ClusterName { t.Errorf("Context was changed even though KeepContext was true") @@ -213,10 +213,10 @@ func TestGetKubeConfigStatus(t *testing.T) { configFilename := tempFile(t, test.existing) statusActual, err := GetKubeConfigStatus(test.ip, configFilename, "minikube") if err != nil && !test.err { - t.Errorf("Got unexpected error: %s", err) + t.Errorf("Got unexpected error: %v", err) } if err == nil && test.err { - t.Errorf("Expected error but got none: %s", err) + t.Errorf("Expected error but got none: %v", err) } if test.status != statusActual { t.Errorf("Expected status %t, but got %t", test.status, statusActual) @@ -270,10 +270,10 @@ func TestUpdateKubeconfigIP(t *testing.T) { configFilename := tempFile(t, test.existing) statusActual, err := UpdateKubeconfigIP(test.ip, configFilename, "minikube") if err != nil && !test.err { - t.Errorf("Got unexpected error: %s", err) + t.Errorf("Got unexpected error: %v", err) } if err == nil && test.err { - t.Errorf("Expected error but got none: %s", err) + t.Errorf("Expected error but got none: %v", err) } if test.status != statusActual { t.Errorf("Expected status %t, but got %t", test.status, statusActual) @@ -357,10 +357,10 @@ func TestGetIPFromKubeConfig(t *testing.T) { configFilename := tempFile(t, test.cfg) ip, err := getIPFromKubeConfig(configFilename, "minikube") if err != nil && !test.err { - t.Errorf("Got unexpected error: %s", err) + t.Errorf("Got unexpected error: %v", err) } if err == nil && test.err { - t.Errorf("Expected error but got none: %s", err) + t.Errorf("Expected error but got none: %v", err) } if !ip.Equal(test.ip) { t.Errorf("IP returned: %s does not match ip given: %s", ip, test.ip) diff --git a/pkg/util/kubernetes.go b/pkg/util/kubernetes.go index 59e408b326..c14f591a00 100644 --- a/pkg/util/kubernetes.go +++ b/pkg/util/kubernetes.go @@ -66,7 +66,7 @@ func GetClient() (kubernetes.Interface, error) { kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) config, err := kubeConfig.ClientConfig() if err != nil { - return nil, fmt.Errorf("Error creating kubeConfig: %s", err) + return nil, fmt.Errorf("Error creating kubeConfig: %v", err) } client, err := kubernetes.NewForConfig(config) if err != nil { diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 40cc5491e3..1cc037aa7c 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -46,7 +46,7 @@ func (r RetriableError) Error() string { return "Temporary Error: " + r.Err.Erro func CalculateDiskSizeInMB(humanReadableDiskSize string) int { diskSize, err := units.FromHumanSize(humanReadableDiskSize) if err != nil { - glog.Errorf("Invalid disk size: %s", err) + glog.Errorf("Invalid disk size: %v", err) } return int(diskSize / units.MB) } diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index 2e904c1256..eeea378564 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -130,12 +130,12 @@ func TestMultiError(t *testing.T) { expected := `Error 1 Error 2` if err.Error() != expected { - t.Fatalf("%s != %s", err, expected) + t.Fatalf("%s != %s", err.Error(), expected) } m = MultiError{} if err := m.ToError(); err != nil { - t.Fatalf("Unexpected error: %s", err) + t.Fatalf("Unexpected error: %v", err) } } diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 02b4605b3d..6c7ac759e8 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -37,7 +37,7 @@ func testAddons(t *testing.T) { t.Parallel() client, err := pkgutil.GetClient() if err != nil { - t.Fatalf("Could not get kubernetes client: %s", err) + t.Fatalf("Could not get kubernetes client: %v", err) } selector := labels.SelectorFromSet(labels.Set(map[string]string{"component": "kube-addon-manager"})) if err := pkgutil.WaitForPodsWithLabelRunning(client, "kube-system", selector); err != nil { @@ -65,7 +65,7 @@ func testDashboard(t *testing.T) { } if err := util.Retry(t, checkDashboard, 2*time.Second, 60); err != nil { - t.Fatalf("error checking dashboard URL: %s", err) + t.Fatalf("error checking dashboard URL: %v", err) } if u.Scheme != "http" { @@ -87,25 +87,25 @@ func testIngressController(t *testing.T) { minikubeRunner.RunCommand("addons enable ingress", true) if err := util.WaitForIngressControllerRunning(t); err != nil { - t.Fatalf("waiting for ingress-controller to be up: %s", err) + t.Fatalf("waiting for ingress-controller to be up: %v", err) } if err := util.WaitForIngressDefaultBackendRunning(t); err != nil { - t.Fatalf("waiting for default-http-backend to be up: %s", err) + t.Fatalf("waiting for default-http-backend to be up: %v", err) } ingressPath, _ := filepath.Abs("testdata/nginx-ing.yaml") if _, err := kubectlRunner.RunCommand([]string{"create", "-f", ingressPath}); err != nil { - t.Fatalf("creating nginx ingress resource: %s", err) + t.Fatalf("creating nginx ingress resource: %v", err) } podPath, _ := filepath.Abs("testdata/nginx-pod-svc.yaml") if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { - t.Fatalf("creating nginx ingress resource: %s", err) + t.Fatalf("creating nginx ingress resource: %v", err) } if err := util.WaitForNginxRunning(t); err != nil { - t.Fatalf("waiting for nginx to be up: %s", err) + t.Fatalf("waiting for nginx to be up: %v", err) } checkIngress := func() error { diff --git a/test/integration/cluster_dns_test.go b/test/integration/cluster_dns_test.go index 6a41eaaebd..7d2fda01dd 100644 --- a/test/integration/cluster_dns_test.go +++ b/test/integration/cluster_dns_test.go @@ -19,56 +19,69 @@ limitations under the License. package integration import ( + "bytes" "path/filepath" - "strings" "testing" + "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - pkgutil "k8s.io/minikube/pkg/util" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/kubernetes" + commonutil "k8s.io/minikube/pkg/util" + pkgutil "k8s.io/minikube/pkg/util" "k8s.io/minikube/test/integration/util" ) func testClusterDNS(t *testing.T) { t.Parallel() - - kubectlRunner := util.NewKubectlRunner(t) - podPath := filepath.Join(*testdataDir, "busybox.yaml") - client, err := pkgutil.GetClient() if err != nil { - t.Fatalf("Error getting kubernetes client %s", err) + t.Fatalf("Error getting kubernetes client %v", err) } + waitForDNS(t, client) - if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { - t.Fatalf("creating busybox pod: %s", err) - } + kr := util.NewKubectlRunner(t) + busybox := busyBoxPod(t, client, kr) + defer kr.RunCommand([]string{"delete", "po", busybox}) - if err := util.WaitForBusyboxRunning(t, "default"); err != nil { - t.Fatalf("Waiting for busybox pod to be up: %s", err) - } - listOpts := metav1.ListOptions{LabelSelector: "integration-test=busybox"} - pods, err := client.CoreV1().Pods("default").List(listOpts) + // The query result is not as important as service reachability + out, err := kr.RunCommand([]string{"exec", busybox, "nslookup", "localhost"}) if err != nil { - t.Fatalf("Unable to list default pods: %v", err) + t.Errorf("nslookup within busybox failed: %v", err) + } + clusterIP := []byte("10.96.0.1") + if !bytes.Contains(out, clusterIP) { + t.Errorf("nslookup did not mention %s:\n%s", clusterIP, out) + } +} + +func waitForDNS(t *testing.T, c kubernetes.Interface) { + // Implementation note: both kube-dns and coredns have k8s-app=kube-dns labels. + sel := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": "kube-dns"})) + if err := commonutil.WaitForPodsWithLabelRunning(c, "kube-system", sel); err != nil { + t.Fatalf("Waited too long for k8s-app=kube-dns pods") + } + if err := commonutil.WaitForDeploymentToStabilize(c, "kube-system", "kube-dns", time.Minute*2); err != nil { + t.Fatalf("kube-dns deployment failed became stable within 2 minutes") + } +} + +func busyBoxPod(t *testing.T, c kubernetes.Interface, kr *util.KubectlRunner) string { + if _, err := kr.RunCommand([]string{"create", "-f", filepath.Join(*testdataDir, "busybox.yaml")}); err != nil { + t.Fatalf("creating busybox pod: %v", err) +- } + // TODO(tstromberg): Refactor WaitForBusyboxRunning to return name of pod. + if err := util.WaitForBusyboxRunning(t, "default"); err != nil { + t.Fatalf("Waiting for busybox pod to be up: %v", err) + } + + pods, err := c.CoreV1().Pods("default").List(metav1.ListOptions{LabelSelector: "integration-test=busybox"}) + if err != nil { + t.Fatalf("list error: %v", err) } if len(pods.Items) == 0 { t.Fatal("Expected a busybox pod to be running") } - - bbox := pods.Items[0].Name - defer func() { - if out, err := kubectlRunner.RunCommand([]string{"delete", "po", bbox}); err != nil { - t.Logf("delete po %s failed: %v\noutput: %s\n", bbox, err, out) - } - }() - - dnsByteArr, err := kubectlRunner.RunCommand([]string{"exec", bbox, "nslookup", "kubernetes"}) - if err != nil { - t.Fatalf("running nslookup in pod:%s", err) - } - dnsOutput := string(dnsByteArr) - if !strings.Contains(dnsOutput, "10.96.0.1") || !strings.Contains(dnsOutput, "10.96.0.10") { - t.Errorf("DNS lookup failed, could not find both 10.96.0.1 and 10.96.0.10. Output: %s", dnsOutput) - } + return pods.Items[0].Name } diff --git a/test/integration/cluster_env_test.go b/test/integration/cluster_env_test.go index 04ba05ce09..27adfadf6c 100644 --- a/test/integration/cluster_env_test.go +++ b/test/integration/cluster_env_test.go @@ -33,7 +33,7 @@ func testClusterEnv(t *testing.T) { dockerEnvVars := minikubeRunner.RunCommand("docker-env", true) if err := minikubeRunner.SetEnvFromEnvCmdOutput(dockerEnvVars); err != nil { - t.Fatalf("Error parsing output: %s", err) + t.Fatalf("Error parsing output: %v", err) } path, err := exec.LookPath("docker") @@ -47,6 +47,6 @@ func testClusterEnv(t *testing.T) { return nil } if err := util.Retry(t, dockerPs, 3*time.Second, 5); err != nil { - t.Fatalf("Error running command: %s. Error: %s Output: %s", "docker ps", err, output) + t.Fatalf("Error running command: %s. Error: %v Output: %s", "docker ps", err, output) } } diff --git a/test/integration/cluster_status_test.go b/test/integration/cluster_status_test.go index bfefcbab95..b5cef118d5 100644 --- a/test/integration/cluster_status_test.go +++ b/test/integration/cluster_status_test.go @@ -47,7 +47,7 @@ func testClusterStatus(t *testing.T) { } if status != api.ConditionTrue { err := fmt.Errorf("Component %s is not Healthy! Status: %s", i.GetName(), status) - t.Logf("Retrying, %s", err) + t.Logf("Retrying, %v", err) return err } } @@ -55,6 +55,6 @@ func testClusterStatus(t *testing.T) { } if err := util.Retry(t, healthy, 1*time.Second, 5); err != nil { - t.Fatalf("Cluster is not healthy: %s", err) + t.Fatalf("Cluster is not healthy: %v", err) } } diff --git a/test/integration/iso_test.go b/test/integration/iso_test.go index 1276710aad..7ebead9344 100644 --- a/test/integration/iso_test.go +++ b/test/integration/iso_test.go @@ -74,7 +74,7 @@ func testPackages(t *testing.T) { for _, pkg := range packages { if output, err := minikubeRunner.SSH(fmt.Sprintf("which %s", pkg)); err != nil { - t.Errorf("Error finding package: %s. Error: %s. Output: %s", pkg, err, output) + t.Errorf("Error finding package: %s. Error: %v. Output: %s", pkg, err, output) } } @@ -94,7 +94,7 @@ func testPersistence(t *testing.T) { } { output, err := minikubeRunner.SSH(fmt.Sprintf("df %s | tail -n 1 | awk '{print $1}'", dir)) if err != nil { - t.Errorf("Error checking device for %s. Error: %s.", dir, err) + t.Errorf("Error checking device for %s. Error: %v", dir, err) } if !strings.Contains(output, "/dev/sda1") { t.Errorf("Path %s is not mounted persistently. %s", dir, output) diff --git a/test/integration/mount_test.go b/test/integration/mount_test.go index 83e0acf171..9975d205ae 100644 --- a/test/integration/mount_test.go +++ b/test/integration/mount_test.go @@ -41,7 +41,7 @@ func testMounting(t *testing.T) { tempDir, err := ioutil.TempDir("", "mounttest") if err != nil { - t.Fatalf("Unexpected error while creating tempDir: %s", err) + t.Fatalf("Unexpected error while creating tempDir: %v", err) } defer os.RemoveAll(tempDir) @@ -88,11 +88,11 @@ func testMounting(t *testing.T) { client, err := pkgutil.GetClient() if err != nil { - t.Fatalf("getting kubernetes client: %s", err) + t.Fatalf("getting kubernetes client: %v", err) } selector := labels.SelectorFromSet(labels.Set(map[string]string{"integration-test": "busybox-mount"})) if err := pkgutil.WaitForPodsWithLabelRunning(client, "default", selector); err != nil { - t.Fatalf("Error waiting for busybox mount pod to be up: %s", err) + t.Fatalf("Error waiting for busybox mount pod to be up: %v", err) } mountTest := func() error { diff --git a/test/integration/persistence_test.go b/test/integration/persistence_test.go index b63538f7ca..5f048c8b2f 100644 --- a/test/integration/persistence_test.go +++ b/test/integration/persistence_test.go @@ -40,16 +40,16 @@ func TestPersistence(t *testing.T) { // Create a pod and wait for it to be running. if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil { - t.Fatalf("Error creating test pod: %s", err) + t.Fatalf("Error creating test pod: %v", err) } verify := func(t *testing.T) { if err := util.WaitForDashboardRunning(t); err != nil { - t.Fatalf("waiting for dashboard to be up: %s", err) + t.Fatalf("waiting for dashboard to be up: %v", err) } if err := util.WaitForBusyboxRunning(t, "default"); err != nil { - t.Fatalf("waiting for busybox to be up: %s", err) + t.Fatalf("waiting for busybox to be up: %v", err) } } @@ -66,7 +66,7 @@ func TestPersistence(t *testing.T) { } if err := util.Retry(t, checkStop, 5*time.Second, 6); err != nil { - t.Fatalf("timed out while checking stopped status: %s", err) + t.Fatalf("timed out while checking stopped status: %v", err) } minikubeRunner.Start() diff --git a/test/integration/pv_test.go b/test/integration/pv_test.go index 8f3c870acd..a886df8671 100644 --- a/test/integration/pv_test.go +++ b/test/integration/pv_test.go @@ -64,7 +64,7 @@ func testProvisioning(t *testing.T) { } if err := util.Retry(t, checkStorageClass, 5*time.Second, 20); err != nil { - t.Fatalf("no default storage class after retry: %s", err) + t.Fatalf("no default storage class after retry: %v", err) } // Check that the storage provisioner pod is running @@ -83,13 +83,13 @@ func testProvisioning(t *testing.T) { } if err := checkPodRunning(); err != nil { - t.Fatal("Check storage-provisioner pod running failed with error: ", err) + t.Fatalf("Check storage-provisioner pod running failed with error: %v", err) } // Now create the PVC pvcPath := filepath.Join(*testdataDir, "pvc.yaml") if _, err := kubectlRunner.RunCommand([]string{"create", "-f", pvcPath}); err != nil { - t.Fatalf("Error creating pvc") + t.Fatalf("Error creating pvc: %v", err) } // And check that it gets bound to a PV. @@ -106,7 +106,7 @@ func testProvisioning(t *testing.T) { } if err := util.Retry(t, checkStorage, 2*time.Second, 5); err != nil { - t.Fatal("PV Creation failed with error:", err) + t.Fatalf("PV Creation failed with error: %v", err) } } diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index f94e72d184..9efd5cf35c 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -50,7 +50,7 @@ func TestStartStop(t *testing.T) { } if err := util.Retry(t, checkStop, 5*time.Second, 6); err != nil { - t.Fatalf("timed out while checking stopped status: %s", err) + t.Fatalf("timed out while checking stopped status: %v", err) } runner.Start() diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 96bdad2928..788145b756 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -75,7 +75,7 @@ func (m *MinikubeRunner) RunCommand(command string, checkError bool) string { if exitError, ok := err.(*exec.ExitError); ok { m.T.Fatalf("Error running command: %s %s. Output: %s", command, exitError.Stderr, stdout) } else { - m.T.Fatalf("Error running command: %s %s. Output: %s", command, err, stdout) + m.T.Fatalf("Error running command: %s %v. Output: %s", command, err, stdout) } } return string(stdout) @@ -87,7 +87,7 @@ func (m *MinikubeRunner) RunDaemon(command string) *exec.Cmd { cmd := exec.Command(path, commandArr...) err := cmd.Start() if err != nil { - m.T.Fatalf("Error running command: %s %s", command, err) + m.T.Fatalf("Error running command: %s %v", command, err) } return cmd } @@ -182,8 +182,8 @@ func (k *KubectlRunner) RunCommand(args []string) (stdout []byte, err error) { cmd := exec.Command(k.BinaryPath, args...) stdout, err = cmd.CombinedOutput() if err != nil { - k.T.Logf("Error %s running command %s. Return code: %s", stdout, args, err) - return &commonutil.RetriableError{Err: fmt.Errorf("Error running command. Error %s. Output: %s", err, stdout)} + k.T.Logf("Error %s running command %s. Return code: %v", stdout, args, err) + return &commonutil.RetriableError{Err: fmt.Errorf("Error running command: %v. Output: %s", err, stdout)} } return nil } @@ -196,7 +196,7 @@ func (k *KubectlRunner) CreateRandomNamespace() string { const strLen = 20 name := genRandString(strLen) if _, err := k.RunCommand([]string{"create", "namespace", name}); err != nil { - k.T.Fatalf("Error creating namespace: %s", err) + k.T.Fatalf("Error creating namespace: %v", err) } return name } @@ -300,7 +300,7 @@ func Retry(t *testing.T, callback func() error, d time.Duration, attempts int) ( if err == nil { return nil } - t.Logf("Error: %s, Retrying in %s. %d Retries remaining.", err, d, attempts-i) + t.Logf("Error: %v, Retrying in %s. %d Retries remaining.", err, d, attempts-i) time.Sleep(d) } return err