Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --extra-config when starting an existing cluster #9634

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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