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

wip: Fix StartStopTest/group/containerd flake … #7969

Closed
wants to merge 4 commits into from
Closed
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
8 changes: 8 additions & 0 deletions cmd/minikube/cmd/config/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package config

import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/out"
)
Expand All @@ -33,6 +35,12 @@ var addonsDisableCmd = &cobra.Command{
}

addon := args[0]
profile := viper.GetString(config.ProfileName)

// check addon status before enabling/disabling it
if addons.AlreadySet(addon, profile, false) {
out.T(out.AddonEnable, "The '{{.addonName}}' addon is already disabled", out.V{"addonName": addon})
}
err := addons.SetAndSave(ClusterFlagValue(), addon, "false")
if err != nil {
exit.WithError("disable failed", err)
Expand Down
7 changes: 7 additions & 0 deletions cmd/minikube/cmd/config/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package config

import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/out"
)
Expand All @@ -32,6 +34,11 @@ var addonsEnableCmd = &cobra.Command{
exit.UsageT("usage: minikube addons enable ADDON_NAME")
}
addon := args[0]
profile := viper.GetString(config.ProfileName)
// check addon status before enabling/disabling it
if addons.AlreadySet(addon, profile, true) {
out.T(out.AddonEnable, "The '{{.addonName}}' addon is already enabled", out.V{"addonName": addon})
}
err := addons.SetAndSave(ClusterFlagValue(), addon, "true")
if err != nil {
exit.WithError("enable failed", err)
Expand Down
23 changes: 11 additions & 12 deletions pkg/addons/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ func enableOrDisableAddon(cc *config.ClusterConfig, name string, val string) err
}
addon := assets.Addons[name]

// check addon status before enabling/disabling it
if isAddonAlreadySet(cc, addon, enable) {
glog.Warningf("addon %s should already be in state %v", name, val)
if !enable {
return nil
}
}

// to match both ingress and ingress-dns adons
if strings.HasPrefix(name, "ingress") && enable && driver.IsKIC(cc.Driver) && runtime.GOOS != "linux" {
exit.UsageT(`Due to {{.driver_name}} networking limitations on {{.os_name}}, {{.addon_name}} addon is not supported for this driver.
Expand Down Expand Up @@ -199,16 +191,23 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri
return enableOrDisableAddonInternal(cc, addon, cmd, data, enable)
}

func isAddonAlreadySet(cc *config.ClusterConfig, addon *assets.Addon, enable bool) bool {
enabled := addon.IsEnabled(cc)
// AlreadySet returns true if the addons is already set
func AlreadySet(addon, profile string, enable bool) bool {
a := assets.Addons[addon]
if a == nil {
return false
}
cc, err := config.Load(profile)
if err != nil {
return false
}
enabled := a.IsEnabled(cc)
if enabled && enable {
return true
}

if !enabled && !enable {
return true
}

return false
}

Expand Down
16 changes: 6 additions & 10 deletions test/integration/start_stop_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ func TestStartStop(t *testing.T) {
}},
{"containerd", constants.DefaultKubernetesVersion, []string{
"--container-runtime=containerd",
"--docker-opt",
"containerd=/var/run/containerd/containerd.sock",
"--apiserver-port=8444",
"--network-plugin=cni",
"--enable-default-cni",
"--extra-config=kubeadm.pod-network-cidr=10.244.0.0/16",
}},
{"crio", "v1.15.7", []string{
"--container-runtime=crio",
Expand Down Expand Up @@ -134,13 +135,8 @@ func TestStartStop(t *testing.T) {

if strings.Contains(tc.name, "cni") {
t.Logf("WARNING: cni mode requires additional setup before pods can schedule :(")
} else {
if _, err := PodWait(ctx, t, profile, "default", "integration-test=busybox", Minutes(7)); err != nil {
t.Fatalf("failed waiting for pod 'busybox' post-stop-start: %v", err)
}
if _, err := PodWait(ctx, t, profile, "kubernetes-dashboard", "k8s-app=kubernetes-dashboard", Minutes(9)); err != nil {
t.Fatalf("failed waiting for 'addon dashboard' pod post-stop-start: %v", err)
}
} else if _, err := PodWait(ctx, t, profile, "kubernetes-dashboard", "k8s-app=kubernetes-dashboard", Minutes(9)); err != nil {
t.Fatalf("failed waiting for 'addon dashboard' pod post-stop-start: %v", err)
}

got := Status(ctx, t, Target(), profile, "Host")
Expand Down Expand Up @@ -179,7 +175,7 @@ func testPodScheduling(ctx context.Context, t *testing.T, profile string) {
t.Helper()

// schedule a pod to assert persistence
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "create", "-f", filepath.Join(*testdataDir, "busybox.yaml")))
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "apply", "-f", filepath.Join(*testdataDir, "busybox.yaml")))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
Expand Down