Skip to content

Commit b4e843c

Browse files
committed
Replace hardcoded docker check with cni check
1 parent 0d07c72 commit b4e843c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

Diff for: test/integration/net_test.go

+20-5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/blang/semver/v4"
3232
"k8s.io/minikube/pkg/kapi"
3333
"k8s.io/minikube/pkg/minikube/config"
34+
"k8s.io/minikube/pkg/minikube/constants"
3435
"k8s.io/minikube/pkg/minikube/reason"
3536
"k8s.io/minikube/pkg/util"
3637
"k8s.io/minikube/pkg/util/retry"
@@ -53,8 +54,8 @@ func TestNetworkPlugins(t *testing.T) {
5354
podLabel string
5455
hairpin bool
5556
}{
56-
// for containerd and crio runtimes kindnet CNI is used by default and hairpin is enabled
57-
{"auto", []string{}, "", "", ContainerRuntime() != "docker"},
57+
// kindnet CNI is used by default and hairpin is enabled
58+
{"auto", []string{}, "", "", usingCNI()},
5859
{"kubenet", []string{"--network-plugin=kubenet"}, "kubenet", "", true},
5960
{"bridge", []string{"--cni=bridge"}, "cni", "", true},
6061
{"enable-default-cni", []string{"--enable-default-cni=true"}, "cni", "", true},
@@ -79,15 +80,14 @@ func TestNetworkPlugins(t *testing.T) {
7980
t.Skipf("flannel is not yet compatible with Docker driver: iptables v1.8.3 (legacy): Couldn't load target `CNI-x': No such file or directory")
8081
}
8182

82-
if ContainerRuntime() != "docker" && tc.name == "false" {
83+
if usingCNI() && tc.name == "false" {
8384
// CNI is required for current container runtime
8485
validateFalseCNI(ctx, t, profile)
8586
return
8687
}
8788

88-
if ContainerRuntime() != "docker" && tc.name == "kubenet" {
89+
if usingCNI() && tc.name == "kubenet" {
8990
// CNI is disabled when --network-plugin=kubenet option is passed. See cni.New(..) function
90-
// But for containerd/crio CNI has to be configured
9191
t.Skipf("Skipping the test as %s container runtimes requires CNI", ContainerRuntime())
9292
}
9393

@@ -207,6 +207,21 @@ func TestNetworkPlugins(t *testing.T) {
207207
})
208208
}
209209

210+
// usingCNI checks if not using dockershim
211+
func usingCNI() bool {
212+
if ContainerRuntime() != "docker" {
213+
return true
214+
}
215+
version, err := util.ParseKubernetesVersion(constants.DefaultKubernetesVersion)
216+
if err != nil {
217+
return false
218+
}
219+
if version.GTE(semver.MustParse("1.24.0-alpha.2")) {
220+
return true
221+
}
222+
return false
223+
}
224+
210225
// validateFalseCNI checks that minikube returns and error
211226
// if container runtime is "containerd" or "crio"
212227
// and --cni=false

0 commit comments

Comments
 (0)