diff --git a/Makefile b/Makefile index 89ace1bfa0..f4efa1dfdb 100755 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ # Bump these on release - and please check ISO_VERSION for correctness. VERSION_MAJOR ?= 1 VERSION_MINOR ?= 4 -VERSION_BUILD ?= 0 +VERSION_BUILD ?= 1 RAW_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).${VERSION_BUILD} VERSION ?= v$(RAW_VERSION) @@ -29,7 +29,7 @@ RPM_VERSION ?= $(DEB_VERSION) GO_VERSION ?= 1.12.9 INSTALL_SIZE ?= $(shell du out/minikube-windows-amd64.exe | cut -f1) -BUILDROOT_BRANCH ?= 2018.05.3 +BUILDROOT_BRANCH ?= 2019.02.6 REGISTRY?=gcr.io/k8s-minikube # Get git commit id @@ -49,17 +49,17 @@ MINIKUBE_BUCKET ?= minikube/releases MINIKUBE_UPLOAD_LOCATION := gs://${MINIKUBE_BUCKET} MINIKUBE_RELEASES_URL=https://github.com/kubernetes/minikube/releases/download -KERNEL_VERSION ?= 4.15 +KERNEL_VERSION ?= 4.19.76 # latest from https://github.com/golangci/golangci-lint/releases -GOLINT_VERSION ?= v1.18.0 +GOLINT_VERSION ?= v1.20.0 # Limit number of default jobs, to avoid the CI builds running out of memory GOLINT_JOBS ?= 4 # see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint -GOLINT_GOGC ?= 8 +GOLINT_GOGC ?= 100 # options for lint (golangci-lint) -GOLINT_OPTIONS = --deadline 4m \ +GOLINT_OPTIONS = --timeout 4m \ --build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \ - --enable goimports,gocritic,golint,gocyclo,interfacer,misspell,nakedret,stylecheck,unconvert,unparam \ + --enable goimports,gocritic,golint,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam \ --exclude 'variable on range scope.*in function literal|ifElseChain' diff --git a/cmd/minikube/cmd/config/profile.go b/cmd/minikube/cmd/config/profile.go index 8c59829840..cbf6f1fe6d 100644 --- a/cmd/minikube/cmd/config/profile.go +++ b/cmd/minikube/cmd/config/profile.go @@ -47,6 +47,12 @@ var ProfileCmd = &cobra.Command{ profile := args[0] if profile == "default" { profile = "minikube" + } else { + // not validating when it is default profile + errProfile, ok := ValidateProfile(profile) + if !ok && errProfile != nil { + out.FailureT(errProfile.Msg) + } } if !pkgConfig.ProfileExists(profile) { diff --git a/cmd/minikube/cmd/config/util.go b/cmd/minikube/cmd/config/util.go index d103ba36ea..10be06c4f5 100644 --- a/cmd/minikube/cmd/config/util.go +++ b/cmd/minikube/cmd/config/util.go @@ -232,3 +232,42 @@ func EnableOrDisableStorageClasses(name, val string) error { return EnableOrDisableAddon(name, val) } + +// ErrValidateProfile Error to validate profile +type ErrValidateProfile struct { + Name string + Msg string +} + +func (e ErrValidateProfile) Error() string { + return e.Msg +} + +// ValidateProfile checks if the profile user is trying to switch exists, else throws error +func ValidateProfile(profile string) (*ErrValidateProfile, bool) { + + validProfiles, invalidProfiles, err := config.ListProfiles() + if err != nil { + out.FailureT(err.Error()) + } + + // handling invalid profiles + for _, invalidProf := range invalidProfiles { + if profile == invalidProf.Name { + return &ErrValidateProfile{Name: profile, Msg: fmt.Sprintf("%q is an invalid profile", profile)}, false + } + } + + profileFound := false + // valid profiles if found, setting profileFound to trueexpectedMsg + for _, prof := range validProfiles { + if prof.Name == profile { + profileFound = true + break + } + } + if !profileFound { + return &ErrValidateProfile{Name: profile, Msg: fmt.Sprintf("profile %q not found", profile)}, false + } + return nil, true +} diff --git a/cmd/minikube/cmd/config/util_test.go b/cmd/minikube/cmd/config/util_test.go index 3cbab76a38..11845ba6c4 100644 --- a/cmd/minikube/cmd/config/util_test.go +++ b/cmd/minikube/cmd/config/util_test.go @@ -17,6 +17,7 @@ limitations under the License. package config import ( + "fmt" "testing" "k8s.io/minikube/pkg/minikube/assets" @@ -111,3 +112,26 @@ func TestIsAddonAlreadySet(t *testing.T) { } } } + +func TestValidateProfile(t *testing.T) { + testCases := []struct { + profileName string + }{ + { + profileName: "82374328742_2974224498", + }, + { + profileName: "minikube", + }, + } + + for _, test := range testCases { + profileNam := test.profileName + expectedMsg := fmt.Sprintf("profile %q not found", test.profileName) + + err, ok := ValidateProfile(profileNam) + if !ok && err.Error() != expectedMsg { + t.Errorf("Didnt receive expected message") + } + } +} diff --git a/cmd/minikube/cmd/delete.go b/cmd/minikube/cmd/delete.go index 9125650c00..6aac39c98f 100644 --- a/cmd/minikube/cmd/delete.go +++ b/cmd/minikube/cmd/delete.go @@ -42,6 +42,8 @@ import ( "k8s.io/minikube/pkg/minikube/out" ) +var deleteAll bool + // deleteCmd represents the delete command var deleteCmd = &cobra.Command{ Use: "delete", @@ -51,26 +53,121 @@ associated files.`, Run: runDelete, } +type typeOfError int + +const ( + Fatal typeOfError = 0 + MissingProfile typeOfError = 1 + MissingCluster typeOfError = 2 +) + +type DeletionError struct { + Err error + Errtype typeOfError +} + +func (error DeletionError) Error() string { + return error.Err.Error() +} + // runDelete handles the executes the flow of "minikube delete" func runDelete(cmd *cobra.Command, args []string) { if len(args) > 0 { exit.UsageT("Usage: minikube delete") } - profile := viper.GetString(pkg_config.MachineProfile) + profileFlag, err := cmd.Flags().GetString("profile") + if err != nil { + exit.WithError("Could not get profile flag", err) + } + + if deleteAll { + if profileFlag != constants.DefaultMachineName { + exit.UsageT("usage: minikube delete --all") + } + + validProfiles, invalidProfiles, err := pkg_config.ListProfiles() + profilesToDelete := append(validProfiles, invalidProfiles...) + + if err != nil { + exit.WithError("Error getting profiles to delete", err) + } + + errs := DeleteProfiles(profilesToDelete) + if len(errs) > 0 { + HandleDeletionErrors(errs) + } else { + out.T(out.DeletingHost, "Successfully deleted all profiles") + } + } else { + if len(args) > 0 { + exit.UsageT("usage: minikube delete") + } + + profileName := viper.GetString(pkg_config.MachineProfile) + profile, err := pkg_config.LoadProfile(profileName) + if err != nil { + out.ErrT(out.Meh, `"{{.name}}" profile does not exist`, out.V{"name": profileName}) + } + + errs := DeleteProfiles([]*pkg_config.Profile{profile}) + if len(errs) > 0 { + HandleDeletionErrors(errs) + } else { + out.T(out.DeletingHost, "Successfully deleted profile \"{{.name}}\"", out.V{"name": profileName}) + } + } +} + +// Deletes one or more profiles +func DeleteProfiles(profiles []*pkg_config.Profile) []error { + var errs []error + for _, profile := range profiles { + err := deleteProfile(profile) + + if err != nil { + mm, loadErr := cluster.LoadMachine(profile.Name) + + if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) { + invalidProfileDeletionErrs := deleteInvalidProfile(profile) + if len(invalidProfileDeletionErrs) > 0 { + errs = append(errs, invalidProfileDeletionErrs...) + } + } else { + errs = append(errs, err) + } + } + } + return errs +} + +func deleteProfile(profile *pkg_config.Profile) error { + viper.Set(pkg_config.MachineProfile, profile.Name) + api, err := machine.NewAPIClient() if err != nil { - exit.WithError("Error getting client", err) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error getting client %v", err)) + return DeletionError{Err: delErr, Errtype: Fatal} } defer api.Close() cc, err := pkg_config.Load() if err != nil && !os.IsNotExist(err) { out.ErrT(out.Sad, "Error loading profile {{.name}}: {{.error}}", out.V{"name": profile, "error": err}) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("error loading profile config: %v", err)) + return DeletionError{Err: delErr, Errtype: MissingProfile} } // In the case of "none", we want to uninstall Kubernetes as there is no VM to delete if err == nil && cc.MachineConfig.VMDriver == constants.DriverNone { - uninstallKubernetes(api, cc.KubernetesConfig, viper.GetString(cmdcfg.Bootstrapper)) + if err := uninstallKubernetes(api, cc.KubernetesConfig, viper.GetString(cmdcfg.Bootstrapper)); err != nil { + deletionError, ok := err.(DeletionError) + if ok { + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("%v", err)) + deletionError.Err = delErr + return deletionError + } + return err + } } if err := killMountProcess(); err != nil { @@ -83,39 +180,111 @@ func runDelete(cmd *cobra.Command, args []string) { out.T(out.Meh, `"{{.name}}" cluster does not exist. Proceeding ahead with cleanup.`, out.V{"name": profile}) default: out.T(out.FailureType, "Failed to delete cluster: {{.error}}", out.V{"error": err}) - out.T(out.Notice, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": profile}) + out.T(out.Notice, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": profile.Name}) } } // In case DeleteHost didn't complete the job. - deleteProfileDirectory(profile) + deleteProfileDirectory(profile.Name) - if err := pkg_config.DeleteProfile(profile); err != nil { + if err := pkg_config.DeleteProfile(profile.Name); err != nil { if os.IsNotExist(err) { - out.T(out.Meh, `"{{.name}}" profile does not exist`, out.V{"name": profile}) - os.Exit(0) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("\"%s\" profile does not exist", profile.Name)) + return DeletionError{Err: delErr, Errtype: MissingProfile} } - exit.WithError("Failed to remove profile", err) + delErr := profileDeletionErr(profile.Name, fmt.Sprintf("failed to remove profile %v", err)) + return DeletionError{Err: delErr, Errtype: Fatal} } - out.T(out.Crushed, `The "{{.name}}" cluster has been deleted.`, out.V{"name": profile}) + + out.T(out.Crushed, `The "{{.name}}" cluster has been deleted.`, out.V{"name": profile.Name}) machineName := pkg_config.GetMachineName() if err := kubeconfig.DeleteContext(constants.KubeconfigPath, machineName); err != nil { - exit.WithError("update config", err) + return DeletionError{Err: fmt.Errorf("update config: %v", err), Errtype: Fatal} } if err := cmdcfg.Unset(pkg_config.MachineProfile); err != nil { - exit.WithError("unset minikube profile", err) + return DeletionError{Err: fmt.Errorf("unset minikube profile: %v", err), Errtype: Fatal} } + return nil } -func uninstallKubernetes(api libmachine.API, kc pkg_config.KubernetesConfig, bsName string) { +func deleteInvalidProfile(profile *pkg_config.Profile) []error { + out.T(out.DeletingHost, "Trying to delete invalid profile {{.profile}}", out.V{"profile": profile.Name}) + + var errs []error + pathToProfile := pkg_config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + err := os.RemoveAll(pathToProfile) + if err != nil { + errs = append(errs, DeletionError{err, Fatal}) + } + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + err := os.RemoveAll(pathToMachine) + if err != nil { + errs = append(errs, DeletionError{err, Fatal}) + } + } + return errs +} + +func profileDeletionErr(profileName string, additionalInfo string) error { + return fmt.Errorf("error deleting profile \"%s\": %s", profileName, additionalInfo) +} + +func uninstallKubernetes(api libmachine.API, kc pkg_config.KubernetesConfig, bsName string) error { out.T(out.Resetting, "Uninstalling Kubernetes {{.kubernetes_version}} using {{.bootstrapper_name}} ...", out.V{"kubernetes_version": kc.KubernetesVersion, "bootstrapper_name": bsName}) clusterBootstrapper, err := getClusterBootstrapper(api, bsName) if err != nil { - out.ErrT(out.Empty, "Unable to get bootstrapper: {{.error}}", out.V{"error": err}) + return DeletionError{Err: fmt.Errorf("unable to get bootstrapper: %v", err), Errtype: Fatal} } else if err = clusterBootstrapper.DeleteCluster(kc); err != nil { - out.ErrT(out.Empty, "Failed to delete cluster: {{.error}}", out.V{"error": err}) + return DeletionError{Err: fmt.Errorf("failed to delete cluster: %v", err), Errtype: Fatal} + } + return nil +} + +// Handles deletion error from DeleteProfiles +func HandleDeletionErrors(errors []error) { + if len(errors) == 1 { + handleSingleDeletionError(errors[0]) + } else { + handleMultipleDeletionErrors(errors) + } +} + +func handleSingleDeletionError(err error) { + deletionError, ok := err.(DeletionError) + + if ok { + switch deletionError.Errtype { + case Fatal: + out.FatalT(deletionError.Error()) + case MissingProfile: + out.ErrT(out.Sad, deletionError.Error()) + case MissingCluster: + out.ErrT(out.Meh, deletionError.Error()) + default: + out.FatalT(deletionError.Error()) + } + } else { + exit.WithError("Could not process error from failed deletion", err) + } +} + +func handleMultipleDeletionErrors(errors []error) { + out.ErrT(out.Sad, "Multiple errors deleting profiles") + + for _, err := range errors { + deletionError, ok := err.(DeletionError) + + if ok { + glog.Errorln(deletionError.Error()) + } else { + exit.WithError("Could not process errors from failed deletion", err) + } } } @@ -177,3 +346,8 @@ func killMountProcess() error { } return nil } + +func init() { + deleteCmd.Flags().BoolVar(&deleteAll, "all", false, "Set flag to delete all profiles") + RootCmd.AddCommand(deleteCmd) +} diff --git a/cmd/minikube/cmd/delete_test.go b/cmd/minikube/cmd/delete_test.go new file mode 100644 index 0000000000..042b86dd4c --- /dev/null +++ b/cmd/minikube/cmd/delete_test.go @@ -0,0 +1,493 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cmd + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/cluster" + "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/localpath" +) + +func TestDeleteProfileWithValidConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p1" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithEmptyProfileConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p2_empty_profile_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithInvalidProfileConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p3_invalid_profile_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithPartialProfileConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p4_partial_profile_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithMissingMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p5_missing_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != numberOfMachineDirs { + t.Fatal("Deleted a machine config when it should not") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithEmptyMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p6_empty_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithInvalidMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p7_invalid_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteProfileWithPartialMachineConfig(t *testing.T) { + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-single/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + profileToDelete := "p8_partial_machine_config" + profile, _ := config.LoadProfile(profileToDelete) + + errs := DeleteProfiles([]*config.Profile{profile}) + + if len(errs) > 0 { + HandleDeletionErrors(errs) + t.Fatal("Errors while deleting profiles") + } + + pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToProfile); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + pathToMachine := cluster.MachinePath(profile.Name, localpath.MiniPath()) + if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) { + t.Fatalf("Profile folder of profile \"%s\" was not deleted", profile.Name) + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")); len(files) != (numberOfProfileDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + if files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")); len(files) != (numberOfMachineDirs - 1) { + t.Fatal("Did not delete exactly one profile") + } + + viper.Set(config.MachineProfile, "") +} + +func TestDeleteAllProfiles(t *testing.T) { + const numberOfTotalProfileDirs = 8 + const numberOfTotalMachineDirs = 7 + + testMinikubeDir := "../../../pkg/minikube/config/testdata/delete-all/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs := len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + if numberOfTotalProfileDirs != numberOfProfileDirs { + t.Error("invalid testdata") + } + + if numberOfTotalMachineDirs != numberOfMachineDirs { + t.Error("invalid testdata") + } + + validProfiles, inValidProfiles, err := config.ListProfiles() + + if err != nil { + t.Error(err) + } + + if numberOfTotalProfileDirs != len(validProfiles)+len(inValidProfiles) { + t.Error("invalid testdata") + } + + profiles := append(validProfiles, inValidProfiles...) + errs := DeleteProfiles(profiles) + + if errs != nil { + t.Errorf("errors while deleting all profiles: %v", errs) + } + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "profiles")) + numberOfProfileDirs = len(files) + + files, _ = ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs = len(files) + + if numberOfProfileDirs != 0 { + t.Errorf("Did not delete all profiles: still %d profiles left", numberOfProfileDirs) + } + + if numberOfMachineDirs != 0 { + t.Errorf("Did not delete all profiles: still %d machines left", numberOfMachineDirs) + } + + viper.Set(config.MachineProfile, "") +} diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 9adf964c34..21b522eddb 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -99,6 +99,7 @@ const ( imageMirrorCountry = "image-mirror-country" mountString = "mount-string" disableDriverMounts = "disable-driver-mounts" + addons = "addons" cacheImages = "cache-images" uuid = "uuid" vpnkitSock = "hyperkit-vpnkit-sock" @@ -119,14 +120,14 @@ const ( ) var ( - registryMirror []string - dockerEnv []string - dockerOpt []string - insecureRegistry []string - apiServerNames []string - apiServerIPs []net.IP - extraOptions cfg.ExtraOptionSlice - enableUpdateNotification = true + registryMirror []string + dockerEnv []string + dockerOpt []string + insecureRegistry []string + apiServerNames []string + addonList []string + apiServerIPs []net.IP + extraOptions cfg.ExtraOptionSlice ) func init() { @@ -162,6 +163,7 @@ func initMinikubeFlags() { startCmd.Flags().String(containerRuntime, "docker", "The container runtime to be used (docker, crio, containerd).") startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube.") startCmd.Flags().String(mountString, constants.DefaultMountDir+":/minikube-host", "The argument to pass the minikube mount command on start.") + startCmd.Flags().StringArrayVar(&addonList, addons, nil, "Enable addons. see `minikube addons list` for a list of valid addon names.") startCmd.Flags().String(criSocket, "", "The cri socket path to be used.") startCmd.Flags().String(networkPlugin, "", "The name of the network plugin.") startCmd.Flags().Bool(enableDefaultCNI, false, "Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with \"--network-plugin=cni\".") @@ -342,6 +344,15 @@ func runStart(cmd *cobra.Command, args []string) { // pull images or restart cluster bootstrapCluster(bs, cr, mRunner, config.KubernetesConfig, preExists, isUpgrade) configureMounts() + + // enable addons with start command + for _, a := range addonList { + err = cmdcfg.Set(a, "true") + if err != nil { + exit.WithError("addon enable failed", err) + } + } + if err = loadCachedImagesInConfigFile(); err != nil { out.T(out.FailureType, "Unable to load cached images from config file.") } diff --git a/cmd/minikube/cmd/update-check.go b/cmd/minikube/cmd/update-check.go index 5fab5cfe05..ec519cae35 100644 --- a/cmd/minikube/cmd/update-check.go +++ b/cmd/minikube/cmd/update-check.go @@ -28,10 +28,6 @@ var updateCheckCmd = &cobra.Command{ Use: "update-check", Short: "Print current and latest version number", Long: `Print current and latest version number`, - PersistentPreRun: func(cmd *cobra.Command, args []string) { - // Explicitly disable update checking for the version command - enableUpdateNotification = false - }, Run: func(command *cobra.Command, args []string) { url := notify.GithubMinikubeReleasesURL r, err := notify.GetAllVersionsFromURL(url) diff --git a/cmd/minikube/cmd/version.go b/cmd/minikube/cmd/version.go index a7cb944d0d..00c61efd88 100644 --- a/cmd/minikube/cmd/version.go +++ b/cmd/minikube/cmd/version.go @@ -26,10 +26,6 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version of minikube", Long: `Print the version of minikube.`, - PersistentPreRun: func(cmd *cobra.Command, args []string) { - // Explicitly disable update checking for the version command - enableUpdateNotification = false - }, Run: func(command *cobra.Command, args []string) { out.Ln("minikube version: %v", version.GetVersion()) gitCommitID := version.GetGitCommitID() diff --git a/deploy/addons/ingress-dns/ingress-dns-configmap.yaml b/deploy/addons/ingress-dns/ingress-dns-configmap.yaml deleted file mode 100644 index 4e2fb5a6e1..0000000000 --- a/deploy/addons/ingress-dns/ingress-dns-configmap.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2016 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - ---- -apiVersion: v1 -data: - map-hash-bucket-size: "128" - hsts: "false" -kind: ConfigMap -metadata: - name: minikube-ingress-dns-nginx-load-balancer-conf - namespace: kube-system - labels: - app: minikube-ingress-dns - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: minikube-ingress-dns-tcp-services - namespace: kube-system - labels: - app: minikube-ingress-dns - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists -data: - 53: "kube-system/kube-ingress-dns-minikube:5353" ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: minikube-ingress-dns-udp-services - namespace: kube-system - labels: - app: minikube-ingress-dns - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists -data: - 53: "kube-system/kube-ingress-dns-minikube:5353" \ No newline at end of file diff --git a/deploy/addons/ingress-dns/ingress-dns-nginx-pod.yaml.tmpl b/deploy/addons/ingress-dns/ingress-dns-nginx-pod.yaml.tmpl deleted file mode 100644 index 33900b6198..0000000000 --- a/deploy/addons/ingress-dns/ingress-dns-nginx-pod.yaml.tmpl +++ /dev/null @@ -1,229 +0,0 @@ -# Copyright 2016 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: minikube-ingress-dns-nginx-ingress - namespace: kube-system - labels: - kubernetes.io/bootstrapping: rbac-defaults - app: minikube-ingress-dns-nginx-ingress-controller - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: Reconcile ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole -metadata: - name: system:minikube-ingress-dns-nginx-ingress - labels: - kubernetes.io/bootstrapping: rbac-defaults - app: minikube-ingress-dns-nginx-ingress-controller - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: Reconcile -rules: - - apiGroups: - - "" - resources: - - configmaps - - endpoints - - nodes - - pods - - secrets - verbs: - - list - - watch - - apiGroups: - - "" - resources: - - nodes - verbs: - - get - - apiGroups: - - "" - resources: - - services - verbs: - - get - - list - - watch - - apiGroups: - - "extensions" - - "networking.k8s.io" - resources: - - ingresses - verbs: - - get - - list - - watch - - apiGroups: - - "" - resources: - - events - verbs: - - create - - patch - - apiGroups: - - "extensions" - - "networking.k8s.io" - resources: - - ingresses/status - verbs: - - update ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role -metadata: - name: system::minikube-ingress-dns-nginx-ingress-role - namespace: kube-system - labels: - kubernetes.io/bootstrapping: rbac-defaults - app: minikube-ingress-dns-nginx-ingress-controller - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: Reconcile -rules: - - apiGroups: - - "" - resources: - - configmaps - - pods - - secrets - - namespaces - verbs: - - get - - apiGroups: - - "" - resources: - - configmaps - resourceNames: - # Defaults to "-" - # Here: "-" - # This has to be adapted if you change either parameter - # when launching the nginx-ingress-controller. - - ingress-controller-leader-nginx - verbs: - - get - - update - - apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - apiGroups: - - "" - resources: - - endpoints - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding -metadata: - name: system::minikube-ingress-dns-nginx-ingress-role-binding - namespace: kube-system - labels: - kubernetes.io/bootstrapping: rbac-defaults - app: minikube-ingress-dns-nginx-ingress-controller - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: system::minikube-ingress-dns-nginx-ingress-role -subjects: - - kind: ServiceAccount - name: minikube-ingress-dns-nginx-ingress - namespace: kube-system ---- -apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRoleBinding -metadata: - name: system:minikube-ingress-dns-nginx-ingress - labels: - kubernetes.io/bootstrapping: rbac-defaults - app: minikube-ingress-dns-nginx-ingress-controller - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:minikube-ingress-dns-nginx-ingress -subjects: - - kind: ServiceAccount - name: minikube-ingress-dns-nginx-ingress - namespace: kube-system ---- -apiVersion: v1 -kind: Pod -metadata: - name: minikube-ingress-dns-nginx-ingress-controller - namespace: kube-system - labels: - app: minikube-ingress-dns-nginx-ingress-controller - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists -spec: - serviceAccountName: minikube-ingress-dns-nginx-ingress - terminationGracePeriodSeconds: 60 - hostNetwork: true - containers: - - image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller{{.ExoticArch}}:0.26.1 - name: nginx-ingress-controller - imagePullPolicy: IfNotPresent - readinessProbe: - httpGet: - path: /healthz - port: 10254 - scheme: HTTP - livenessProbe: - httpGet: - path: /healthz - port: 10254 - scheme: HTTP - initialDelaySeconds: 10 - timeoutSeconds: 1 - env: - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - ports: - - containerPort: 53 - hostPort: 53 - - containerPort: 8008 - - containerPort: 4333 - args: - - /nginx-ingress-controller - - --configmap=$(POD_NAMESPACE)/minikube-ingress-dns-nginx-load-balancer-conf - - --tcp-services-configmap=$(POD_NAMESPACE)/minikube-ingress-dns-tcp-services - - --udp-services-configmap=$(POD_NAMESPACE)/minikube-ingress-dns-udp-services - - --annotations-prefix=nginx.ingress.kubernetes.io - - --http-port=8008 - - --https-port=4333 - # use minikube IP address in ingress status field - - --report-node-internal-ip-address - securityContext: - capabilities: - drop: - - ALL - add: - - NET_BIND_SERVICE - # www-data -> 33 - runAsUser: 33 \ No newline at end of file diff --git a/deploy/addons/ingress-dns/ingress-dns-dns-server-pod.yaml b/deploy/addons/ingress-dns/ingress-dns-pod.yaml similarity index 81% rename from deploy/addons/ingress-dns/ingress-dns-dns-server-pod.yaml rename to deploy/addons/ingress-dns/ingress-dns-pod.yaml index aaaea7425b..5c16e12c01 100644 --- a/deploy/addons/ingress-dns/ingress-dns-dns-server-pod.yaml +++ b/deploy/addons/ingress-dns/ingress-dns-pod.yaml @@ -35,16 +35,6 @@ metadata: app.kubernetes.io/part-of: kube-system addonmanager.kubernetes.io/mode: Reconcile rules: - - apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - patch - resourceNames: - - tcp-services - - udp-services - apiGroups: - "" - "extensions" @@ -65,11 +55,11 @@ metadata: app: minikube-ingress-dns kubernetes.io/bootstrapping: rbac-defaults app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists + addonmanager.kubernetes.io/mode: Reconcile roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: cluster-admin + name: minikube-ingress-dns subjects: - kind: ServiceAccount name: minikube-ingress-dns @@ -83,20 +73,21 @@ metadata: labels: app: minikube-ingress-dns app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists + addonmanager.kubernetes.io/mode: Reconcile spec: serviceAccountName: minikube-ingress-dns + hostNetwork: true containers: - name: minikube-ingress-dns - image: "cryptexlabs/minikube-ingress-dns:0.1.1" + image: "cryptexlabs/minikube-ingress-dns:0.2.0" imagePullPolicy: IfNotPresent ports: - - containerPort: 5353 - hostPort: 5353 - protocol: TCP - - containerPort: 5353 - hostPort: 5353 + - containerPort: 53 protocol: UDP env: - name: DNS_PORT - value: "5353" \ No newline at end of file + value: "53" + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP \ No newline at end of file diff --git a/deploy/addons/ingress-dns/ingress-dns-svc.yaml b/deploy/addons/ingress-dns/ingress-dns-svc.yaml deleted file mode 100644 index 41187d95d8..0000000000 --- a/deploy/addons/ingress-dns/ingress-dns-svc.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2016 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - ---- -apiVersion: v1 -kind: Service -metadata: - name: kube-ingress-dns-minikube - namespace: kube-system - labels: - app: minikube-ingress-dns - app.kubernetes.io/part-of: kube-system - addonmanager.kubernetes.io/mode: EnsureExists -spec: - selector: - app: minikube-ingress-dns - clusterIP: None - ports: - - name: tcp-port - port: 5353 - targetPort: 5353 - protocol: TCP - - name: udp-port - port: 5353 - targetPort: 5353 - protocol: UDP \ No newline at end of file diff --git a/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl b/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl index 2dbc0b4e82..8d3c3f1fd4 100644 --- a/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl +++ b/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl @@ -1,27 +1,24 @@ -apiVersion: v1 -kind: ReplicationController +apiVersion: apps/v1 +kind: Deployment metadata: name: registry-creds namespace: kube-system labels: - version: v1.9 addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/minikube-addons: registry-creds spec: replicas: 1 selector: - name: registry-creds - version: v1.9 - addonmanager.kubernetes.io/mode: Reconcile + matchLabels: + name: registry-creds template: metadata: labels: name: registry-creds - version: v1.9 addonmanager.kubernetes.io/mode: Reconcile spec: containers: - - image: registry.hub.docker.com/upmcenterprises/registry-creds:1.9 + - image: upmcenterprises/registry-creds:1.9 name: registry-creds imagePullPolicy: Always env: diff --git a/deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/var/run/crio.sock b/deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/var/run/crio.sock deleted file mode 120000 index 2c31ff8a45..0000000000 --- a/deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/var/run/crio.sock +++ /dev/null @@ -1 +0,0 @@ -crio/crio.sock \ No newline at end of file diff --git a/deploy/iso/minikube-iso/configs/minikube_defconfig b/deploy/iso/minikube-iso/configs/minikube_defconfig index 01010e85da..abcb1c8491 100644 --- a/deploy/iso/minikube-iso/configs/minikube_defconfig +++ b/deploy/iso/minikube-iso/configs/minikube_defconfig @@ -3,7 +3,7 @@ BR2_CCACHE=y BR2_OPTIMIZE_2=y BR2_TOOLCHAIN_BUILDROOT_VENDOR="minikube" BR2_TOOLCHAIN_BUILDROOT_GLIBC=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_15=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y BR2_BINUTILS_VERSION_2_30_X=y BR2_GCC_VERSION_7_X=y BR2_TOOLCHAIN_BUILDROOT_CXX=y @@ -18,8 +18,6 @@ BR2_SYSTEM_BIN_SH_BASH=y BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_MINIKUBE_PATH)/board/coreos/minikube/users" BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_MINIKUBE_PATH)/board/coreos/minikube/rootfs-overlay" BR2_LINUX_KERNEL=y -BR2_LINUX_KERNEL_CUSTOM_VERSION=y -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.15" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_MINIKUBE_PATH)/board/coreos/minikube/linux_defconfig" BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y diff --git a/deploy/iso/minikube-iso/package/containerd-bin/containerd-bin.mk b/deploy/iso/minikube-iso/package/containerd-bin/containerd-bin.mk index 9a8072fb81..85ec682257 100644 --- a/deploy/iso/minikube-iso/package/containerd-bin/containerd-bin.mk +++ b/deploy/iso/minikube-iso/package/containerd-bin/containerd-bin.mk @@ -11,6 +11,7 @@ CONTAINERD_BIN_DEPENDENCIES = host-go libgpgme CONTAINERD_BIN_GOPATH = $(@D)/_output CONTAINERD_BIN_ENV = \ CGO_ENABLED=1 \ + GO111MODULE=off \ GOPATH="$(CONTAINERD_BIN_GOPATH)" \ GOBIN="$(CONTAINERD_BIN_GOPATH)/bin" \ PATH=$(CONTAINERD_BIN_GOPATH)/bin:$(BR_PATH) diff --git a/deploy/iso/minikube-iso/package/hyperv-daemons/hyperv-daemons.mk b/deploy/iso/minikube-iso/package/hyperv-daemons/hyperv-daemons.mk index a069741c65..c6f87675be 100644 --- a/deploy/iso/minikube-iso/package/hyperv-daemons/hyperv-daemons.mk +++ b/deploy/iso/minikube-iso/package/hyperv-daemons/hyperv-daemons.mk @@ -4,8 +4,8 @@ # ################################################################################ -HYPERV_DAEMONS_VERSION = 4.15.1 -HYPERV_DAEMONS_SITE = https://www.kernel.org/pub/linux/kernel/v${HYPERV_DAEMONS_VERSION%%.*}.x +HYPERV_DAEMONS_VERSION = 4.19.76 +HYPERV_DAEMONS_SITE = https://www.kernel.org/pub/linux/kernel/v4.x HYPERV_DAEMONS_SOURCE = linux-$(HYPERV_DAEMONS_VERSION).tar.xz define HYPERV_DAEMONS_BUILD_CMDS diff --git a/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.hash b/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.hash index 191a7c833d..f8dd11fe31 100644 --- a/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.hash +++ b/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.hash @@ -1,3 +1,6 @@ # From http://download.virtualbox.org/virtualbox/5.1.30/SHA256SUMS sha256 96cab2296fb014ce0a16b7b9603b52208b9403c10c1524b44201d3c274e8a821 VirtualBox-5.1.38.tar.bz2 sha256 0e7ee2c78ebf7cd0d3a933d51148bef04a64f64fb27ccf70d59cddf9ca1e517a VBoxGuestAdditions_5.1.38.iso +# From http://download.virtualbox.org/virtualbox/5.2.32/SHA256SUMS +sha256 ff6390e50cb03718cd3f5779627910999c12279b465e340c80d7175778a33958 VirtualBox-5.2.32.tar.bz2 +sha256 4311c7408a3410e6a33264a9062347d9eec04f58339a49f0a60488c0cabc8996 VBoxGuestAdditions_5.2.32.iso diff --git a/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.mk b/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.mk index 63b9bcea5a..7b092b8695 100644 --- a/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.mk +++ b/deploy/iso/minikube-iso/package/vbox-guest/vbox-guest.mk @@ -4,7 +4,7 @@ # ################################################################################ -VBOX_GUEST_VERSION = 5.1.38 +VBOX_GUEST_VERSION = 5.2.32 VBOX_GUEST_SITE = http://download.virtualbox.org/virtualbox/$(VBOX_GUEST_VERSION) VBOX_GUEST_LICENSE = GPLv2 VBOX_GUEST_LICENSE_FILES = COPYING @@ -12,7 +12,7 @@ VBOX_GUEST_SOURCE = VirtualBox-$(VBOX_GUEST_VERSION).tar.bz2 VBOX_GUEST_EXTRA_DOWNLOADS = http://download.virtualbox.org/virtualbox/${VBOX_GUEST_VERSION}/VBoxGuestAdditions_${VBOX_GUEST_VERSION}.iso define VBOX_GUEST_EXPORT_MODULES - ( cd $(@D)/src/VBox/Additions/linux; ./export_modules modules.tar.gz ) + ( cd $(@D)/src/VBox/Additions/linux; ./export_modules.sh modules.tar.gz ) mkdir -p $(@D)/vbox-modules tar -C $(@D)/vbox-modules -xzf $(@D)/src/VBox/Additions/linux/modules.tar.gz endef @@ -20,7 +20,7 @@ endef VBOX_GUEST_POST_EXTRACT_HOOKS += VBOX_GUEST_EXPORT_MODULES VBOX_GUEST_MODULE_SUBDIRS = vbox-modules/ -VBOX_GUEST_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED) +VBOX_GUEST_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED) KERN_DIR=$(LINUX_DIR) define VBOX_GUEST_USERS - -1 vboxsf -1 - - - - - diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index 25c12d8b40..96a6658b37 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -82,6 +82,7 @@ gsutil -qm cp "gs://minikube-builds/${MINIKUBE_LOCATION}/gvisor-addon" testdata/ export MINIKUBE_BIN="out/minikube-${OS_ARCH}" export E2E_BIN="out/e2e-${OS_ARCH}" chmod +x "${MINIKUBE_BIN}" "${E2E_BIN}" out/docker-machine-driver-* +"${MINIKUBE_BIN}" version procs=$(pgrep "minikube-${OS_ARCH}|e2e-${OS_ARCH}" || true) if [[ "${procs}" != "" ]]; then @@ -91,28 +92,36 @@ if [[ "${procs}" != "" ]]; then kill -9 ${procs} || true fi +# Quickly notice misconfigured test roots +mkdir -p "${TEST_ROOT}" + # Cleanup stale test outputs. echo "" echo ">> Cleaning up after previous test runs ..." - -for stale_dir in ${TEST_ROOT}/*; do - echo "* Cleaning stale test root: ${stale_dir}" - - for tunnel in $(find ${stale_dir} -name tunnels.json -type f); do +for entry in $(ls ${TEST_ROOT}); do + echo "* Cleaning stale test path: ${entry}" + for tunnel in $(find ${entry} -name tunnels.json -type f); do env MINIKUBE_HOME="$(dirname ${tunnel})" ${MINIKUBE_BIN} tunnel --cleanup || true done - for home in $(find ${stale_dir} -name .minikube -type d); do - env MINIKUBE_HOME="$(dirname ${home})" ${MINIKUBE_BIN} delete || true - sudo rm -Rf "${home}" + for home in $(find ${entry} -name .minikube -type d); do + env MINIKUBE_HOME="$(dirname ${home})" ${MINIKUBE_BIN} delete || true + sudo rm -Rf "${home}" done - for kconfig in $(find ${stale_dir} -name kubeconfig -type f); do + ${MINIKUBE_BIN} delete --all || true + + for kconfig in $(find ${entry} -name kubeconfig -type f); do sudo rm -f "${kconfig}" done - rm -f "${stale_dir}/*" || true - rmdir "${stale_dir}" || ls "${stale_dir}" + # Be very specific to avoid accidentally deleting other items, like wildcards or devices + if [[ -d "${entry}" ]]; then + rm -Rf "${entry}" || true + elif [[ -f "${entry}" ]]; then + rm -f "${entry}" || true + fi + done # sometimes tests left over zombie procs that won't exit @@ -134,11 +143,16 @@ if type -P virsh; then fi if type -P vboxmanage; then - vboxmanage list vms || true - vboxmanage list vms \ - | egrep -o '{.*?}' \ - | xargs -I {} sh -c "vboxmanage startvm {} --type emergencystop; vboxmanage unregistervm {} --delete" \ - || true + for guid in $(vboxmanage list vms | egrep -Eo '\{[-a-Z0-9]+\}'); do + echo "- Removing stale VirtualBox VM: $guid" + vboxmanage startvm $guid --type emergencystop || true + vboxmanage unregistervm $guid || true + done + + vboxmanage list hostonlyifs \ + | grep "^Name:" \ + | awk '{ print $2 }' \ + | xargs -n1 vboxmanage hostonlyif remove || true echo ">> VirtualBox VM list after clean up (should be empty):" vboxmanage list vms || true diff --git a/hack/jenkins/minikube_cross_build_and_upload.sh b/hack/jenkins/minikube_cross_build_and_upload.sh index eb510d578a..382adacea7 100755 --- a/hack/jenkins/minikube_cross_build_and_upload.sh +++ b/hack/jenkins/minikube_cross_build_and_upload.sh @@ -41,6 +41,8 @@ docker kill $(docker ps -q) || true docker rm $(docker ps -aq) || true make -j 16 all && failed=$? || failed=$? +"out/minikube-$(go env GOOS)-$(go env GOARCH)" version + gsutil cp "gs://${bucket}/logs/index.html" \ "gs://${bucket}/logs/${ghprbPullId}/index.html" @@ -58,9 +60,16 @@ if [[ "${rebuild}" -eq 1 ]]; then make release-iso fi + cp -r test/integration/testdata out/ # Don't upload the buildroot artifacts if they exist rm -r out/buildroot || true -gsutil -m cp -r out/ "gs://${bucket}/${ghprbPullId}/" +# At this point, the out directory contains the jenkins scripts (populated by jenkins), +# testdata, and our build output. Push the changes to GCS so that worker nodes can re-use them. + +# -d: delete remote files that don't exist (removed test files, for instance) +# -J: gzip compression +# -R: recursive. strangely, this is not the default for sync. +gsutil -m rsync -dJR out "gs://${bucket}/${ghprbPullId}" diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index f2c73b9813..18cfd22251 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -350,27 +350,9 @@ var Addons = map[string]*Addon{ }, false, "helm-tiller"), "ingress-dns": NewAddon([]*BinAsset{ MustBinAsset( - "deploy/addons/ingress-dns/ingress-dns-configmap.yaml", + "deploy/addons/ingress-dns/ingress-dns-pod.yaml", vmpath.GuestAddonsDir, - "ingress-dns-configmap.yaml", - "0640", - false), - MustBinAsset( - "deploy/addons/ingress-dns/ingress-dns-dns-server-pod.yaml", - vmpath.GuestAddonsDir, - "ingress-dns-dns-server-pod.yaml", - "0640", - false), - MustBinAsset( - "deploy/addons/ingress-dns/ingress-dns-nginx-pod.yaml.tmpl", - vmpath.GuestAddonsDir, - "ingress-dns-nginx-pod.yaml", - "0640", - true), - MustBinAsset( - "deploy/addons/ingress-dns/ingress-dns-svc.yaml", - vmpath.GuestAddonsDir, - "ingress-dns-svc.yaml", + "ingress-dns-pod.yaml", "0640", false), }, false, "ingress-dns"), diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index ebc0ec8f96..95c35a087c 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -177,7 +177,7 @@ func (k *Bootstrapper) GetAPIServerStatus(ip net.IP, apiserverPort int) (string, // LogCommands returns a map of log type to a command which will display that log. func (k *Bootstrapper) LogCommands(o bootstrapper.LogOptions) map[string]string { var kubelet strings.Builder - kubelet.WriteString("journalctl -u kubelet") + kubelet.WriteString("sudo journalctl -u kubelet") if o.Lines > 0 { kubelet.WriteString(fmt.Sprintf(" -n %d", o.Lines)) } diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go index 8a880dc49a..f6d696816d 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go @@ -66,7 +66,7 @@ Wants=crio.service [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m +ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m [Install] `, @@ -84,7 +84,7 @@ Wants=containerd.service [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m +ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m [Install] `, @@ -109,7 +109,7 @@ Wants=containerd.service [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.200 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m +ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=unix:///run/containerd/containerd.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.200 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m [Install] `, @@ -128,7 +128,7 @@ Wants=docker.socket [Service] ExecStart= -ExecStart=/var/lib/minikube/binaries/v1.16.0/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-infra-container-image=docker-proxy-image.io/google_containers/pause:3.1 --pod-manifest-path=/etc/kubernetes/manifests +ExecStart=/var/lib/minikube/binaries/v1.16.1/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --container-runtime=docker --fail-swap-on=false --hostname-override=minikube --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-infra-container-image=docker-proxy-image.io/google_containers/pause:3.1 --pod-manifest-path=/etc/kubernetes/manifests [Install] `, diff --git a/pkg/minikube/cluster/machine.go b/pkg/minikube/cluster/machine.go new file mode 100644 index 0000000000..8a24b04e3c --- /dev/null +++ b/pkg/minikube/cluster/machine.go @@ -0,0 +1,127 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster + +import ( + "io/ioutil" + "path/filepath" + + "github.com/docker/machine/libmachine/host" + "github.com/pkg/errors" + "k8s.io/minikube/pkg/minikube/localpath" + "k8s.io/minikube/pkg/minikube/machine" +) + +type Machine struct { + *host.Host +} + +// IsValid checks if the machine has the essential info needed for a machine +func (h *Machine) IsValid() bool { + if h == nil { + return false + } + + if h.Host == nil { + return false + } + + if h.Host.Name == "" { + return false + } + + if h.Host.Driver == nil { + return false + } + + if h.Host.HostOptions == nil { + return false + } + + if h.Host.RawDriver == nil { + return false + } + return true +} + +// ListsMachines return all valid and invalid machines +// If a machine is valid or invalid is determined by the cluster.IsValid function +func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) { + pDirs, err := machineDirs(miniHome...) + if err != nil { + return nil, nil, err + } + for _, n := range pDirs { + p, err := LoadMachine(n) + if err != nil { + inValidMachines = append(inValidMachines, p) + continue + } + if !p.IsValid() { + inValidMachines = append(inValidMachines, p) + continue + } + validMachines = append(validMachines, p) + } + return validMachines, inValidMachines, nil +} + +// Loads a machine or throws an error if the machine could not be loadedG +func LoadMachine(name string) (*Machine, error) { + api, err := machine.NewAPIClient() + if err != nil { + return nil, err + } + + h, err := CheckIfHostExistsAndLoad(api, name) + if err != nil { + return nil, err + } + + var mm Machine + if h != nil { + mm.Host = h + } else { + return nil, errors.New("host is nil") + } + + return &mm, nil +} + +func machineDirs(miniHome ...string) (dirs []string, err error) { + miniPath := localpath.MiniPath() + if len(miniHome) > 0 { + miniPath = miniHome[0] + } + mRootDir := filepath.Join(miniPath, "machines") + items, err := ioutil.ReadDir(mRootDir) + for _, f := range items { + if f.IsDir() { + dirs = append(dirs, f.Name()) + } + } + return dirs, err +} + +// MachinePath returns the Minikube machine path of a machine +func MachinePath(machine string, miniHome ...string) string { + miniPath := localpath.MiniPath() + if len(miniHome) > 0 { + miniPath = miniHome[0] + } + return filepath.Join(miniPath, "machines", machine) +} diff --git a/pkg/minikube/cluster/machine_test.go b/pkg/minikube/cluster/machine_test.go new file mode 100644 index 0000000000..a04f40aa8b --- /dev/null +++ b/pkg/minikube/cluster/machine_test.go @@ -0,0 +1,75 @@ +/* +Copyright 2019 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/localpath" +) + +func TestListMachines(t *testing.T) { + const ( + numberOfValidMachines = 2 + numberOfInValidMachines = 3 + totalNumberOfMachines = numberOfValidMachines + numberOfInValidMachines + ) + + viper.Set(config.MachineProfile, "") + + testMinikubeDir := "./testdata/list-machines/.minikube" + miniDir, err := filepath.Abs(testMinikubeDir) + + if err != nil { + t.Errorf("error getting dir path for %s : %v", testMinikubeDir, err) + } + + err = os.Setenv(localpath.MinikubeHome, miniDir) + if err != nil { + t.Errorf("error setting up test environment. could not set %s", localpath.MinikubeHome) + } + + files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines")) + numberOfMachineDirs := len(files) + + validMachines, inValidMachines, err := ListMachines() + + if err != nil { + t.Error(err) + } + + if numberOfValidMachines != len(validMachines) { + t.Errorf("expected %d valid machines, got %d", numberOfValidMachines, len(validMachines)) + } + + if numberOfInValidMachines != len(inValidMachines) { + t.Errorf("expected %d invalid machines, got %d", numberOfInValidMachines, len(inValidMachines)) + } + + if totalNumberOfMachines != len(validMachines)+len(inValidMachines) { + t.Errorf("expected %d total machines, got %d", totalNumberOfMachines, len(validMachines)+len(inValidMachines)) + } + + if numberOfMachineDirs != len(validMachines)+len(inValidMachines) { + t.Error("expected number of machine directories to be equal to the number of total machines") + } +} diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json new file mode 100644 index 0000000000..83a27c78b2 --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p1/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p1", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p1/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p1", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "virtualbox", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p1" +} diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json new file mode 100644 index 0000000000..4bb1814211 --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p2/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p2", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p2/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p2", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p2/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p2/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "virtualbox", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p2" +} diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p3_empty/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p3_empty_config/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p3_empty/config.json rename to pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p3_empty_config/config.json diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json new file mode 100644 index 0000000000..581f9e648f --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p4_invalid_machine_config/config.json @@ -0,0 +1 @@ +invalid json file :) diff --git a/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json new file mode 100644 index 0000000000..d7b7092761 --- /dev/null +++ b/pkg/minikube/cluster/testdata/list-machines/.minikube/machines/p5_partial_config/config.json @@ -0,0 +1,72 @@ +{ + "ConfigVersion": 3, + "Driver": { + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p5_partial_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p5_partial_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "4f16872c-aee8-11e9-8815-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p5_partial_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p5_partial_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, +} diff --git a/pkg/minikube/config/profile.go b/pkg/minikube/config/profile.go index 9280c6de9a..2c09f4b446 100644 --- a/pkg/minikube/config/profile.go +++ b/pkg/minikube/config/profile.go @@ -27,8 +27,12 @@ import ( "k8s.io/minikube/pkg/util/lock" ) -// isValid checks if the profile has the essential info needed for a profile -func (p *Profile) isValid() bool { +// IsValid checks if the profile has the essential info needed for a profile +func (p *Profile) IsValid() bool { + if p.Config == nil { + return false + } + if p.Config.MachineConfig.VMDriver == "" { return false } @@ -106,7 +110,7 @@ func DeleteProfile(profile string, miniHome ...string) error { if len(miniHome) > 0 { miniPath = miniHome[0] } - return os.RemoveAll(profileFolderPath(profile, miniPath)) + return os.RemoveAll(ProfileFolderPath(profile, miniPath)) } // ListProfiles returns all valid and invalid (if any) minikube profiles @@ -118,12 +122,12 @@ func ListProfiles(miniHome ...string) (validPs []*Profile, inValidPs []*Profile, return nil, nil, err } for _, n := range pDirs { - p, err := loadProfile(n, miniHome...) + p, err := LoadProfile(n, miniHome...) if err != nil { inValidPs = append(inValidPs, p) continue } - if !p.isValid() { + if !p.IsValid() { inValidPs = append(inValidPs, p) continue } @@ -133,7 +137,7 @@ func ListProfiles(miniHome ...string) (validPs []*Profile, inValidPs []*Profile, } // loadProfile loads type Profile based on its name -func loadProfile(name string, miniHome ...string) (*Profile, error) { +func LoadProfile(name string, miniHome ...string) (*Profile, error) { cfg, err := DefaultLoader.LoadConfigFromFile(name, miniHome...) p := &Profile{ Name: name, @@ -168,8 +172,8 @@ func profileFilePath(profile string, miniHome ...string) string { return filepath.Join(miniPath, "profiles", profile, "config.json") } -// profileFolderPath returns path of profile folder -func profileFolderPath(profile string, miniHome ...string) string { +// ProfileFolderPath returns path of profile folder +func ProfileFolderPath(profile string, miniHome ...string) string { miniPath := localpath.MiniPath() if len(miniHome) > 0 { miniPath = miniHome[0] diff --git a/pkg/minikube/config/profile_test.go b/pkg/minikube/config/profile_test.go index 2ef38378ac..2cd674a8ef 100644 --- a/pkg/minikube/config/profile_test.go +++ b/pkg/minikube/config/profile_test.go @@ -23,7 +23,7 @@ import ( // TestListProfiles uses a different uses different MINIKUBE_HOME with rest of tests since it relies on file list index func TestListProfiles(t *testing.T) { - miniDir, err := filepath.Abs("./testdata/.minikube") + miniDir, err := filepath.Abs("./testdata/profile/.minikube") if err != nil { t.Errorf("error getting dir path for ./testdata/.minikube : %v", err) } diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p1/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p1/config.json new file mode 100644 index 0000000000..90a026a01c --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p1/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p1", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p1/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p1", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p1" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p2_empty_profile_config/config.json new file mode 100644 index 0000000000..a9e6592c7a --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p2_empty_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.52", + "MachineName": "p2_empty_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p2_empty_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p2_empty_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "ddd37c1c-aedf-11e9-afa7-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p2_empty_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p3_invalid_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p3_invalid_profile_config/config.json new file mode 100644 index 0000000000..8d23c98dc6 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p3_invalid_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.53", + "MachineName": "p3_invalid_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p3_invalid_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "759044c8-aee4-11e9-bd0a-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p3_invalid_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p4_partial_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p4_partial_profile_config/config.json new file mode 100644 index 0000000000..14b416d3c2 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p4_partial_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.54", + "MachineName": "p4_partial_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p4_partial_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p4_partial_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "faf8face-aee4-11e9-9ba1-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p4_partial_profile_config" +} diff --git a/deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/var/run/crio/.empty b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p6_empty_machine_config/config.json similarity index 100% rename from deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/var/run/crio/.empty rename to pkg/minikube/config/testdata/delete-all/.minikube/machines/p6_empty_machine_config/config.json diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p7_invalid_machine_config/config.json new file mode 100644 index 0000000000..581f9e648f --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p7_invalid_machine_config/config.json @@ -0,0 +1 @@ +invalid json file :) diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/machines/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p8_partial_machine_config/config.json new file mode 100644 index 0000000000..d4525a7861 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/machines/p8_partial_machine_config/config.json @@ -0,0 +1,72 @@ +{ + "ConfigVersion": 3, + "Driver": { + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p8_partial_machine_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p8_partial_machine_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "4f16872c-aee8-11e9-8815-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, +} diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p1/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p1/config.json new file mode 100644 index 0000000000..00655266e6 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p1/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.50", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p2_empty_profile_config/config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p4_invalid_file/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p3_invalid_profile_config/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p4_invalid_file/config.json rename to pkg/minikube/config/testdata/delete-all/.minikube/profiles/p3_invalid_profile_config/config.json diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p5_partial_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p4_partial_profile_config/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p5_partial_config/config.json rename to pkg/minikube/config/testdata/delete-all/.minikube/profiles/p4_partial_profile_config/config.json diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p5_missing_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p5_missing_machine_config/config.json new file mode 100644 index 0000000000..1e0980752a --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p5_missing_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.55", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p6_empty_machine_config/config.json new file mode 100644 index 0000000000..a1557f6df1 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p6_empty_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.57", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p7_invalid_machine_config/config.json new file mode 100644 index 0000000000..ea47981d29 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p7_invalid_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.59", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p8_partial_machine_config/config.json new file mode 100644 index 0000000000..789b9b5557 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-all/.minikube/profiles/p8_partial_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.60", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p1/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p1/config.json new file mode 100644 index 0000000000..90a026a01c --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p1/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.50", + "MachineName": "p1", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p1/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p1", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "5e6787b6-aecb-11e9-81cf-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p1/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p1" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p2_empty_profile_config/config.json new file mode 100644 index 0000000000..a9e6592c7a --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p2_empty_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.52", + "MachineName": "p2_empty_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p2_empty_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p2_empty_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "ddd37c1c-aedf-11e9-afa7-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p2_empty_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p2_empty_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p3_invalid_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p3_invalid_profile_config/config.json new file mode 100644 index 0000000000..8d23c98dc6 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p3_invalid_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.53", + "MachineName": "p3_invalid_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p3_invalid_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "759044c8-aee4-11e9-bd0a-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p3_invalid_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p3_invalid_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p4_partial_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p4_partial_profile_config/config.json new file mode 100644 index 0000000000..14b416d3c2 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p4_partial_profile_config/config.json @@ -0,0 +1,80 @@ +{ + "ConfigVersion": 3, + "Driver": { + "IPAddress": "192.168.64.54", + "MachineName": "p4_partial_profile_config", + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p4_partial_profile_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "Boot2DockerURL": "file:///Users/someuser/.minikube/cache/iso/minikube-v1.2.0.iso", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p4_partial_profile_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "faf8face-aee4-11e9-9ba1-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p4_partial_profile_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "DriverName": "hyperkit", + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertPath": "/Users/someuser/.minikube/machines/server.pem", + "ServerKeyPath": "/Users/someuser/.minikube/machines/server-key.pem", + "ClientKeyPath": "/Users/someuser/.minikube/certs/key.pem", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, + "Name": "p4_partial_profile_config" +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p6_empty_machine_config/config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p7_invalid_machine_config/config.json new file mode 100644 index 0000000000..581f9e648f --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p7_invalid_machine_config/config.json @@ -0,0 +1 @@ +invalid json file :) diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/machines/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p8_partial_machine_config/config.json new file mode 100644 index 0000000000..d4525a7861 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/machines/p8_partial_machine_config/config.json @@ -0,0 +1,72 @@ +{ + "ConfigVersion": 3, + "Driver": { + "SSHUser": "docker", + "SSHPort": 22, + "SSHKeyPath": "/Users/someuser/.minikube/machines/p8_partial_machine_config/id_rsa", + "StorePath": "/Users/someuser/.minikube", + "SwarmMaster": false, + "SwarmHost": "", + "SwarmDiscovery": "", + "DiskSize": 20000, + "CPU": 2, + "Memory": 2000, + "Cmdline": "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes base host=p8_partial_machine_config", + "NFSShares": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "4f16872c-aee8-11e9-8815-8c8590c3b8b4", + "BootKernel": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/bzImage", + "BootInitrd": "/Users/someuser/.minikube/machines/p8_partial_machine_config/b2d-image/boot/initrd", + "Initrd": "initrd", + "Vmlinuz": "bzImage" + }, + "HostOptions": { + "Driver": "", + "Memory": 0, + "Disk": 0, + "EngineOptions": { + "ArbitraryFlags": null, + "Dns": null, + "GraphDir": "", + "Env": null, + "Ipv6": false, + "InsecureRegistry": [ + "10.96.0.0/12" + ], + "Labels": null, + "LogLevel": "", + "StorageDriver": "", + "SelinuxEnabled": false, + "TlsVerify": false, + "RegistryMirror": null, + "InstallURL": "" + }, + "SwarmOptions": { + "IsSwarm": false, + "Address": "", + "Discovery": "", + "Agent": false, + "Master": false, + "Host": "tcp://0.0.0.0:3376", + "Image": "swarm:latest", + "Strategy": "spread", + "Heartbeat": 0, + "Overcommit": 0, + "ArbitraryFlags": null, + "ArbitraryJoinFlags": null, + "Env": null, + "IsExperimental": false + }, + "AuthOptions": { + "CertDir": "/Users/someuser/.minikube", + "CaCertPath": "/Users/someuser/.minikube/certs/ca.pem", + "CaPrivateKeyPath": "/Users/someuser/.minikube/certs/ca-key.pem", + "CaCertRemotePath": "", + "ServerCertRemotePath": "", + "ServerKeyRemotePath": "", + "ClientCertPath": "/Users/someuser/.minikube/certs/cert.pem", + "ServerCertSANs": null, + "StorePath": "/Users/someuser/.minikube" + } + }, +} diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p1/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p1/config.json new file mode 100644 index 0000000000..00655266e6 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p1/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.50", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p2_empty_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p2_empty_profile_config/config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p3_invalid_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p3_invalid_profile_config/config.json new file mode 100644 index 0000000000..9e2e347718 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p3_invalid_profile_config/config.json @@ -0,0 +1 @@ +invalid json file :) \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p4_partial_profile_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p4_partial_profile_config/config.json new file mode 100644 index 0000000000..29f62c0149 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p4_partial_profile_config/config.json @@ -0,0 +1,47 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "XhyveDiskDriver": "ahci-hd", + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p5_missing_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p5_missing_machine_config/config.json new file mode 100644 index 0000000000..1e0980752a --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p5_missing_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.55", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p6_empty_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p6_empty_machine_config/config.json new file mode 100644 index 0000000000..a1557f6df1 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p6_empty_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.57", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p7_invalid_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p7_invalid_machine_config/config.json new file mode 100644 index 0000000000..ea47981d29 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p7_invalid_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.59", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p8_partial_machine_config/config.json b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p8_partial_machine_config/config.json new file mode 100644 index 0000000000..789b9b5557 --- /dev/null +++ b/pkg/minikube/config/testdata/delete-single/.minikube/profiles/p8_partial_machine_config/config.json @@ -0,0 +1,49 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "VMDriver": "hyperkit", + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "KubernetesVersion": "v1.15.0", + "NodeIP": "192.168.64.60", + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p1/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p1/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p1/config.json rename to pkg/minikube/config/testdata/profile/.minikube/profiles/p1/config.json diff --git a/pkg/minikube/config/testdata/.minikube/profiles/p2/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p2/config.json similarity index 100% rename from pkg/minikube/config/testdata/.minikube/profiles/p2/config.json rename to pkg/minikube/config/testdata/profile/.minikube/profiles/p2/config.json diff --git a/pkg/minikube/config/testdata/profile/.minikube/profiles/p3_empty/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p3_empty/config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pkg/minikube/config/testdata/profile/.minikube/profiles/p4_invalid_file/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p4_invalid_file/config.json new file mode 100644 index 0000000000..9e2e347718 --- /dev/null +++ b/pkg/minikube/config/testdata/profile/.minikube/profiles/p4_invalid_file/config.json @@ -0,0 +1 @@ +invalid json file :) \ No newline at end of file diff --git a/pkg/minikube/config/testdata/profile/.minikube/profiles/p5_partial_config/config.json b/pkg/minikube/config/testdata/profile/.minikube/profiles/p5_partial_config/config.json new file mode 100644 index 0000000000..29f62c0149 --- /dev/null +++ b/pkg/minikube/config/testdata/profile/.minikube/profiles/p5_partial_config/config.json @@ -0,0 +1,47 @@ +{ + "MachineConfig": { + "KeepContext": false, + "MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso", + "Memory": 2000, + "CPUs": 2, + "DiskSize": 20000, + "ContainerRuntime": "docker", + "HyperkitVpnKitSock": "", + "HyperkitVSockPorts": [], + "XhyveDiskDriver": "ahci-hd", + "DockerEnv": null, + "InsecureRegistry": null, + "RegistryMirror": null, + "HostOnlyCIDR": "192.168.99.1/24", + "HypervVirtualSwitch": "", + "KVMNetwork": "default", + "KVMQemuURI": "qemu:///system", + "KVMGPU": false, + "KVMHidden": false, + "DockerOpt": null, + "DisableDriverMounts": false, + "NFSShare": [], + "NFSSharesRoot": "/nfsshares", + "UUID": "", + "NoVTXCheck": false, + "DNSProxy": false, + "HostDNSResolver": true + }, + "KubernetesConfig": { + "NodePort": 8443, + "NodeName": "minikube", + "APIServerName": "minikubeCA", + "APIServerNames": null, + "APIServerIPs": null, + "DNSDomain": "cluster.local", + "ContainerRuntime": "docker", + "CRISocket": "", + "NetworkPlugin": "", + "FeatureGates": "", + "ServiceCIDR": "10.96.0.0/12", + "ImageRepository": "", + "ExtraOptions": null, + "ShouldLoadCachedImages": true, + "EnableDefaultCNI": false + } +} \ No newline at end of file diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index 3f005e3516..1c61d75e06 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -92,10 +92,10 @@ var DefaultISOURL = fmt.Sprintf("https://storage.googleapis.com/%s/minikube-%s.i var DefaultISOSHAURL = DefaultISOURL + SHASuffix // DefaultKubernetesVersion is the default kubernetes version -var DefaultKubernetesVersion = "v1.16.0" +var DefaultKubernetesVersion = "v1.16.1" // NewestKubernetesVersion is the newest Kubernetes version to test against -var NewestKubernetesVersion = "v1.16.0" +var NewestKubernetesVersion = "v1.16.1" // OldestKubernetesVersion is the oldest Kubernetes version to test against var OldestKubernetesVersion = "v1.11.10" diff --git a/pkg/minikube/constants/constants_darwin.go b/pkg/minikube/constants/constants_darwin.go index 707f5f9925..29821c8d31 100644 --- a/pkg/minikube/constants/constants_darwin.go +++ b/pkg/minikube/constants/constants_darwin.go @@ -18,6 +18,7 @@ limitations under the License. package constants +// DefaultMountDir is the default mounting directory for Darwin var DefaultMountDir = "/Users" // SupportedVMDrivers is a list of supported drivers on Darwin. diff --git a/pkg/minikube/extract/extract.go b/pkg/minikube/extract/extract.go index 55a8969724..8453d53ea5 100644 --- a/pkg/minikube/extract/extract.go +++ b/pkg/minikube/extract/extract.go @@ -385,7 +385,7 @@ func checkKeyValueExpression(kvp *ast.KeyValueExpr, e *state) { // Ok now this is just a mess if help, ok := kvp.Value.(*ast.BinaryExpr); ok { - s := checkBinaryExpression(help, e) + s := checkBinaryExpression(help) if s != "" { e.translations[s] = "" } @@ -394,7 +394,7 @@ func checkKeyValueExpression(kvp *ast.KeyValueExpr, e *state) { } // checkBinaryExpression checks binary expressions, stuff of the form x + y, for strings and concats them -func checkBinaryExpression(b *ast.BinaryExpr, e *state) string { +func checkBinaryExpression(b *ast.BinaryExpr) string { // Check the left side var s string if l, ok := b.X.(*ast.BasicLit); ok { @@ -410,7 +410,7 @@ func checkBinaryExpression(b *ast.BinaryExpr, e *state) string { } if b1, ok := b.X.(*ast.BinaryExpr); ok { - if x := checkBinaryExpression(b1, e); x != "" { + if x := checkBinaryExpression(b1); x != "" { s += x } } @@ -429,7 +429,7 @@ func checkBinaryExpression(b *ast.BinaryExpr, e *state) string { } if b1, ok := b.Y.(*ast.BinaryExpr); ok { - if x := checkBinaryExpression(b1, e); x != "" { + if x := checkBinaryExpression(b1); x != "" { s += x } } diff --git a/pkg/minikube/tunnel/tunnel_manager.go b/pkg/minikube/tunnel/tunnel_manager.go index 69f9e972b1..4c3ed6f4d9 100644 --- a/pkg/minikube/tunnel/tunnel_manager.go +++ b/pkg/minikube/tunnel/tunnel_manager.go @@ -122,8 +122,8 @@ func (mgr *Manager) run(ctx context.Context, t controller, ready, check, done ch } } -func (mgr *Manager) cleanup(t controller) *Status { - return t.cleanup() +func (mgr *Manager) cleanup(t controller) { + t.cleanup() } // CleanupNotRunningTunnels cleans up tunnels that are not running diff --git a/site/content/en/docs/Reference/Commands/addons.md b/site/content/en/docs/Reference/Commands/addons.md index d15f38173b..a5fb310468 100644 --- a/site/content/en/docs/Reference/Commands/addons.md +++ b/site/content/en/docs/Reference/Commands/addons.md @@ -39,6 +39,12 @@ Enables the addon w/ADDON_NAME within minikube (example: minikube addons enable minikube addons enable ADDON_NAME [flags] ``` +or + +``` +minikube start --addons ADDON_NAME [flags] +``` + ## minikube addons list Lists all available minikube addons as well as their current statuses (enabled/disabled) diff --git a/site/content/en/docs/Reference/Commands/start.md b/site/content/en/docs/Reference/Commands/start.md index 62073d14e1..6e1c1b13df 100644 --- a/site/content/en/docs/Reference/Commands/start.md +++ b/site/content/en/docs/Reference/Commands/start.md @@ -16,6 +16,7 @@ minikube start [flags] ### Options ``` +--addons Enable addons. see `minikube addons list` for a list of valid addon names. --apiserver-ips ipSlice A set of apiserver IP Addresses which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default []) --apiserver-name string The apiserver name which is used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine (default "minikubeCA") --apiserver-names stringArray A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine diff --git a/site/content/en/docs/Tasks/addons.md b/site/content/en/docs/Tasks/addons.md index 0082b19f11..c454360cbc 100644 --- a/site/content/en/docs/Tasks/addons.md +++ b/site/content/en/docs/Tasks/addons.md @@ -55,6 +55,12 @@ Example output: minikube addons enable ``` +or + +```shell +minikube start --addons +``` + ## Interacting with an addon For addons that expose a browser endpoint, use: diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index f363de6ef3..2b22e8cad2 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -42,7 +42,7 @@ func TestAddons(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 40*time.Minute) defer CleanupWithLogs(t, profile, cancel) - args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "-v=1"}, StartArgs()...) + args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "-v=1", "--addons=ingress", "--addons=registry"}, StartArgs()...) rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { t.Fatalf("%s failed: %v", rr.Args, err) @@ -72,11 +72,6 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) { t.Skipf("skipping: ssh unsupported by none") } - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "ingress")) - if err != nil { - t.Fatalf("%s failed: %v", rr.Args, err) - } - client, err := kapi.Client(profile) if err != nil { t.Fatalf("kubernetes client: %v", client) @@ -89,7 +84,7 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) { t.Fatalf("wait: %v", err) } - rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ing.yaml"))) + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "replace", "--force", "-f", filepath.Join(*testdataDir, "nginx-ing.yaml"))) if err != nil { t.Errorf("%s failed: %v", rr.Args, err) } @@ -131,11 +126,6 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) { } func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) { - rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addons", "enable", "registry")) - if err != nil { - t.Fatalf("%s failed: %v", rr.Args, err) - } - client, err := kapi.Client(profile) if err != nil { t.Fatalf("kubernetes client: %v", client) @@ -155,7 +145,7 @@ func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) { } // Test from inside the cluster (no curl available on busybox) - rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "delete", "po", "-l", "run=registry-test", "--now")) + rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "delete", "po", "-l", "run=registry-test", "--now")) if err != nil { t.Logf("pre-cleanup %s failed: %v (not a problem)", rr.Args, err) } diff --git a/test/integration/start_stop_delete_test.go b/test/integration/start_stop_delete_test.go index bf575baeee..1ed1f6b676 100644 --- a/test/integration/start_stop_delete_test.go +++ b/test/integration/start_stop_delete_test.go @@ -139,6 +139,11 @@ func TestStartStop(t *testing.T) { if err != nil { t.Errorf("%s failed: %v", rr.Args, err) } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "delete", "--all")) + if err != nil { + t.Errorf("%s failed: %v", rr.Args, err) + } }) } }) diff --git a/translations/fr.json b/translations/fr.json index 90805f63d2..83c5a9ec0c 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -111,6 +111,7 @@ "Error getting host status": "", "Error getting machine logs": "", "Error getting machine status": "", + "Error getting profiles to delete": "", "Error getting service status": "", "Error getting service with namespace: {{.namespace}} and labels {{.labelName}}:{{.addonName}}: {{.error}}": "", "Error getting the host IP address to use from within the VM": "", @@ -504,6 +505,8 @@ "usage: minikube addons list": "", "usage: minikube addons open ADDON_NAME": "", "usage: minikube config unset PROPERTY_NAME": "", + "usage: minikube delete": "", + "usage: minikube delete --all": "", "usage: minikube profile [MINIKUBE_PROFILE_NAME]": "", "zsh completion failed": "", "{{.addonName}} was successfully enabled": "", @@ -516,4 +519,4 @@ "{{.prefix}}minikube {{.version}} on {{.platform}}": "{{.prefix}}minikube {{.version}} sur {{.platform}}", "{{.type}} is not yet a supported filesystem. We will try anyways!": "", "{{.url}} is not accessible: {{.error}}": "" -} \ No newline at end of file +} diff --git a/translations/zh-CN.json b/translations/zh-CN.json index 777e14862a..64141d7925 100644 --- a/translations/zh-CN.json +++ b/translations/zh-CN.json @@ -505,6 +505,8 @@ "usage: minikube addons list": "", "usage: minikube addons open ADDON_NAME": "", "usage: minikube config unset PROPERTY_NAME": "", + "usage: minikube delete": "", + "usage: minikube delete --all": "", "usage: minikube profile [MINIKUBE_PROFILE_NAME]": "", "zsh completion failed": "", "{{.addonName}} was successfully enabled": "", @@ -517,4 +519,4 @@ "{{.prefix}}minikube {{.version}} on {{.platform}}": "{{.platform}} 上的 {{.prefix}}minikube {{.version}}", "{{.type}} is not yet a supported filesystem. We will try anyways!": "", "{{.url}} is not accessible: {{.error}}": "" -} \ No newline at end of file +}