Skip to content

Commit 6be118f

Browse files
Merge pull request #9634 from dekkers/saving-extra-config
Fix --extra-config when starting an existing cluster
2 parents 21db1ad + 1490562 commit 6be118f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Diff for: cmd/minikube/cmd/start_flags.go

+4
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
613613
cc.KubernetesConfig.ImageRepository = viper.GetString(imageRepository)
614614
}
615615

616+
if cmd.Flags().Changed("extra-config") {
617+
cc.KubernetesConfig.ExtraOptions = config.ExtraOptions
618+
}
619+
616620
if cmd.Flags().Changed(enableDefaultCNI) && !cmd.Flags().Changed(cniFlag) {
617621
if viper.GetBool(enableDefaultCNI) {
618622
klog.Errorf("Found deprecated --enable-default-cni flag, setting --cni=bridge")

Diff for: test/integration/functional_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func TestFunctional(t *testing.T) {
8888
{"CacheCmd", validateCacheCmd}, // Caches images needed for subsequent tests because of proxy
8989
{"MinikubeKubectlCmd", validateMinikubeKubectl}, // Make sure `minikube kubectl` works
9090
{"MinikubeKubectlCmdDirectly", validateMinikubeKubectlDirectCall},
91+
{"ExtraConfig", validateExtraConfig}, // Ensure extra cmdline config change is saved
9192
}
9293
for _, tc := range tests {
9394
tc := tc
@@ -336,6 +337,32 @@ func validateMinikubeKubectlDirectCall(ctx context.Context, t *testing.T, profil
336337

337338
}
338339

340+
func validateExtraConfig(ctx context.Context, t *testing.T, profile string) {
341+
defer PostMortemLogs(t, profile)
342+
343+
start := time.Now()
344+
// The tests before this already created a profile, starting minikube with different --extra-config cmdline option.
345+
startArgs := []string{"start", "-p", profile, "--extra-config=apiserver.enable-admission-plugins=NamespaceAutoProvision"}
346+
c := exec.CommandContext(ctx, Target(), startArgs...)
347+
rr, err := Run(t, c)
348+
if err != nil {
349+
t.Errorf("failed to restart minikube. args %q: %v", rr.Command(), err)
350+
}
351+
t.Logf("restart took %s for %q cluster.", time.Since(start), profile)
352+
353+
afterCfg, err := config.LoadProfile(profile)
354+
if err != nil {
355+
t.Errorf("error reading cluster config after soft start: %v", err)
356+
}
357+
358+
expectedExtraOptions := "apiserver.enable-admission-plugins=NamespaceAutoProvision"
359+
360+
if !strings.Contains(afterCfg.Config.KubernetesConfig.ExtraOptions.String(), expectedExtraOptions) {
361+
t.Errorf("expected ExtraOptions to contain %s but got %s", expectedExtraOptions, afterCfg.Config.KubernetesConfig.ExtraOptions.String())
362+
}
363+
364+
}
365+
339366
// validateComponentHealth asserts that all Kubernetes components are healthy
340367
func validateComponentHealth(ctx context.Context, t *testing.T, profile string) {
341368
defer PostMortemLogs(t, profile)

0 commit comments

Comments
 (0)