diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 9143bb8639..9b58c1b0f5 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -367,8 +367,12 @@ func runStart(cmd *cobra.Command, args []string) { bootstrapCluster(bs, cr, mRunner, mc, preExists, isUpgrade) configureMounts() - // enable addons - addons.Start(viper.GetString(config.MachineProfile), addonList) + // enable addons, both old and new! + existingAddons := map[string]bool{} + if existing != nil && existing.Addons != nil { + existingAddons = existing.Addons + } + addons.Start(viper.GetString(config.MachineProfile), existingAddons, addonList) if err = cacheAndLoadImagesInConfig(); err != nil { out.T(out.FailureType, "Unable to load cached images from config file.") diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index 06cf51d7dc..4fffa7e7ff 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -19,6 +19,7 @@ package addons import ( "fmt" "path" + "sort" "strconv" "strings" "time" @@ -68,8 +69,7 @@ func Set(name, value, profile string) error { return errors.Wrap(err, "running callbacks") } - glog.Infof("Writing new config for %q ...", profile) - // Write the value + glog.Infof("Writing out %q config to set %s=%v...", profile, name, value) return config.Write(profile, c) } @@ -263,33 +263,42 @@ func enableOrDisableStorageClasses(name, val, profile string) error { } // Start enables the default addons for a profile, plus any additional -func Start(profile string, additional []string) { +func Start(profile string, toEnable map[string]bool, additional []string) { start := time.Now() - glog.Infof("enableAddons") + glog.Infof("enableAddons start: toEnable=%v, additional=%s", toEnable, additional) defer func() { glog.Infof("enableAddons completed in %s", time.Since(start)) }() - toEnable := []string{} - // Apply addons that are enabled by default + // Get the default values of any addons not saved to our config for name, a := range assets.Addons { - enabled, err := a.IsEnabled(profile) + defaultVal, err := a.IsEnabled(profile) if err != nil { glog.Errorf("is-enabled failed for %q: %v", a.Name(), err) continue } - if enabled { - toEnable = append(toEnable, name) + + _, exists := toEnable[name] + if !exists { + toEnable[name] = defaultVal } } - toEnable = append(toEnable, additional...) - if len(toEnable) == 0 { - return + // Apply new addons + for _, name := range additional { + toEnable[name] = true } - out.T(out.AddonEnable, "Enabling addons: {{.addons}}", out.V{"addons": strings.Join(toEnable, ", ")}) - for _, a := range toEnable { + toEnableList := []string{} + for k, v := range toEnable { + if v { + toEnableList = append(toEnableList, k) + } + } + sort.Strings(toEnableList) + + out.T(out.AddonEnable, "Enabling addons: {{.addons}}", out.V{"addons": strings.Join(toEnableList, ", ")}) + for _, a := range toEnableList { err := Set(a, "true", profile) if err != nil { // Intentionally non-fatal