Skip to content

Commit

Permalink
Merge pull request #9634 from dekkers/saving-extra-config
Browse files Browse the repository at this point in the history
Fix --extra-config when starting an existing cluster
  • Loading branch information
sharifelgamal authored Dec 9, 2020
2 parents 21db1ad + 1490562 commit 6be118f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
cc.KubernetesConfig.ImageRepository = viper.GetString(imageRepository)
}

if cmd.Flags().Changed("extra-config") {
cc.KubernetesConfig.ExtraOptions = config.ExtraOptions
}

if cmd.Flags().Changed(enableDefaultCNI) && !cmd.Flags().Changed(cniFlag) {
if viper.GetBool(enableDefaultCNI) {
klog.Errorf("Found deprecated --enable-default-cni flag, setting --cni=bridge")
Expand Down
27 changes: 27 additions & 0 deletions test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func TestFunctional(t *testing.T) {
{"CacheCmd", validateCacheCmd}, // Caches images needed for subsequent tests because of proxy
{"MinikubeKubectlCmd", validateMinikubeKubectl}, // Make sure `minikube kubectl` works
{"MinikubeKubectlCmdDirectly", validateMinikubeKubectlDirectCall},
{"ExtraConfig", validateExtraConfig}, // Ensure extra cmdline config change is saved
}
for _, tc := range tests {
tc := tc
Expand Down Expand Up @@ -336,6 +337,32 @@ func validateMinikubeKubectlDirectCall(ctx context.Context, t *testing.T, profil

}

func validateExtraConfig(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

start := time.Now()
// The tests before this already created a profile, starting minikube with different --extra-config cmdline option.
startArgs := []string{"start", "-p", profile, "--extra-config=apiserver.enable-admission-plugins=NamespaceAutoProvision"}
c := exec.CommandContext(ctx, Target(), startArgs...)
rr, err := Run(t, c)
if err != nil {
t.Errorf("failed to restart minikube. args %q: %v", rr.Command(), err)
}
t.Logf("restart took %s for %q cluster.", time.Since(start), profile)

afterCfg, err := config.LoadProfile(profile)
if err != nil {
t.Errorf("error reading cluster config after soft start: %v", err)
}

expectedExtraOptions := "apiserver.enable-admission-plugins=NamespaceAutoProvision"

if !strings.Contains(afterCfg.Config.KubernetesConfig.ExtraOptions.String(), expectedExtraOptions) {
t.Errorf("expected ExtraOptions to contain %s but got %s", expectedExtraOptions, afterCfg.Config.KubernetesConfig.ExtraOptions.String())
}

}

// validateComponentHealth asserts that all Kubernetes components are healthy
func validateComponentHealth(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
Expand Down

0 comments on commit 6be118f

Please sign in to comment.