From 9982e0fbc0c3b7f0b1c1a020955e4d331f09e752 Mon Sep 17 00:00:00 2001 From: upodroid Date: Wed, 25 Oct 2023 15:45:49 +0100 Subject: [PATCH] enable test handler for containerd runtime --- k8s/crds/kops.k8s.io_clusters.yaml | 4 ++++ k8s/crds/kops.k8s.io_instancegroups.yaml | 4 ++++ nodeup/pkg/model/containerd.go | 3 +++ pkg/apis/kops/containerdconfig.go | 2 ++ pkg/apis/kops/v1alpha2/containerdconfig.go | 2 ++ pkg/apis/kops/v1alpha2/zz_generated.conversion.go | 2 ++ pkg/apis/kops/v1alpha3/containerdconfig.go | 2 ++ pkg/apis/kops/v1alpha3/zz_generated.conversion.go | 2 ++ tests/e2e/kubetest2-kops/deployer/up.go | 1 + tests/e2e/scenarios/build/run-test.sh | 3 ++- 10 files changed, 24 insertions(+), 1 deletion(-) diff --git a/k8s/crds/kops.k8s.io_clusters.yaml b/k8s/crds/kops.k8s.io_clusters.yaml index 9ff1824b2fc27..298af818a755f 100644 --- a/k8s/crds/kops.k8s.io_clusters.yaml +++ b/k8s/crds/kops.k8s.io_clusters.yaml @@ -921,6 +921,10 @@ spec: description: State directory for execution state files (default "/run/containerd"). type: string + testHandlerEnabled: + description: TestHandlerEnabled enables a runtime called test-handler, + specific to k/k e2e tests + type: boolean version: description: Version used to pick the containerd package. type: string diff --git a/k8s/crds/kops.k8s.io_instancegroups.yaml b/k8s/crds/kops.k8s.io_instancegroups.yaml index 71cf265eeffa3..a67ca9366185b 100644 --- a/k8s/crds/kops.k8s.io_instancegroups.yaml +++ b/k8s/crds/kops.k8s.io_instancegroups.yaml @@ -225,6 +225,10 @@ spec: description: State directory for execution state files (default "/run/containerd"). type: string + testHandlerEnabled: + description: TestHandlerEnabled enables a runtime called test-handler, + specific to k/k e2e tests + type: boolean version: description: Version used to pick the containerd package. type: string diff --git a/nodeup/pkg/model/containerd.go b/nodeup/pkg/model/containerd.go index 88f496587ebba..92424d1d6a7bc 100644 --- a/nodeup/pkg/model/containerd.go +++ b/nodeup/pkg/model/containerd.go @@ -492,6 +492,9 @@ func (b *ContainerdBuilder) buildContainerdConfig() (string, error) { if containerd.SeLinuxEnabled { config.SetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "enable_selinux"}, true) } + if containerd.TestHandlerEnabled { + config.SetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", "test-handler", "runtime_type"}, "io.containerd.runc.v2") + } if b.NodeupConfig.KubeletConfig.PodInfraContainerImage != "" { config.SetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "sandbox_image"}, b.NodeupConfig.KubeletConfig.PodInfraContainerImage) } diff --git a/pkg/apis/kops/containerdconfig.go b/pkg/apis/kops/containerdconfig.go index 3084321d13ecf..e7e9f8f556a50 100644 --- a/pkg/apis/kops/containerdconfig.go +++ b/pkg/apis/kops/containerdconfig.go @@ -51,6 +51,8 @@ type ContainerdConfig struct { SeLinuxEnabled bool `json:"selinuxEnabled,omitempty"` // NRI configures the Node Resource Interface. NRI *NRIConfig `json:"nri,omitempty"` + // TestHandlerEnabled enables a runtime called test-handler, specific to k/k e2e tests + TestHandlerEnabled bool `json:"testHandlerEnabled,omitempty"` } type NRIConfig struct { diff --git a/pkg/apis/kops/v1alpha2/containerdconfig.go b/pkg/apis/kops/v1alpha2/containerdconfig.go index 884c154bfd2f4..6064dbc50de5d 100644 --- a/pkg/apis/kops/v1alpha2/containerdconfig.go +++ b/pkg/apis/kops/v1alpha2/containerdconfig.go @@ -46,6 +46,8 @@ type ContainerdConfig struct { SeLinuxEnabled bool `json:"selinuxEnabled,omitempty"` // NRI configures the Node Resource Interface. NRI *NRIConfig `json:"nri,omitempty"` + // TestHandlerEnabled enables a runtime called test-handler, specific to k/k e2e tests + TestHandlerEnabled bool `json:"testHandlerEnabled,omitempty"` } type NRIConfig struct { diff --git a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go index 876799c9fd19a..bec270dace4ea 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go @@ -3198,6 +3198,7 @@ func autoConvert_v1alpha2_ContainerdConfig_To_kops_ContainerdConfig(in *Containe } else { out.NRI = nil } + out.TestHandlerEnabled = in.TestHandlerEnabled return nil } @@ -3252,6 +3253,7 @@ func autoConvert_kops_ContainerdConfig_To_v1alpha2_ContainerdConfig(in *kops.Con } else { out.NRI = nil } + out.TestHandlerEnabled = in.TestHandlerEnabled return nil } diff --git a/pkg/apis/kops/v1alpha3/containerdconfig.go b/pkg/apis/kops/v1alpha3/containerdconfig.go index 32a370e465651..a22450df59eba 100644 --- a/pkg/apis/kops/v1alpha3/containerdconfig.go +++ b/pkg/apis/kops/v1alpha3/containerdconfig.go @@ -46,6 +46,8 @@ type ContainerdConfig struct { SeLinuxEnabled bool `json:"selinuxEnabled,omitempty"` // NRI configures the Node Resource Interface. NRI *NRIConfig `json:"nri,omitempty"` + // TestHandlerEnabled enables a runtime called test-handler, specific to k/k e2e tests + TestHandlerEnabled bool `json:"testHandlerEnabled,omitempty"` } type NRIConfig struct { diff --git a/pkg/apis/kops/v1alpha3/zz_generated.conversion.go b/pkg/apis/kops/v1alpha3/zz_generated.conversion.go index 023e70f9690c4..782dc938ff97c 100644 --- a/pkg/apis/kops/v1alpha3/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha3/zz_generated.conversion.go @@ -3443,6 +3443,7 @@ func autoConvert_v1alpha3_ContainerdConfig_To_kops_ContainerdConfig(in *Containe } else { out.NRI = nil } + out.TestHandlerEnabled = in.TestHandlerEnabled return nil } @@ -3497,6 +3498,7 @@ func autoConvert_kops_ContainerdConfig_To_v1alpha3_ContainerdConfig(in *kops.Con } else { out.NRI = nil } + out.TestHandlerEnabled = in.TestHandlerEnabled return nil } diff --git a/tests/e2e/kubetest2-kops/deployer/up.go b/tests/e2e/kubetest2-kops/deployer/up.go index 604060e4d7a04..4903484f2bc70 100644 --- a/tests/e2e/kubetest2-kops/deployer/up.go +++ b/tests/e2e/kubetest2-kops/deployer/up.go @@ -118,6 +118,7 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e "--kubernetes-version", d.KubernetesVersion, "--ssh-public-key", d.SSHPublicKeyPath, "--set", "cluster.spec.nodePortAccess=0.0.0.0/0", + "--set", "spec.containerd.testHandlerEnabled=true", } if yes { args = append(args, "--yes") diff --git a/tests/e2e/scenarios/build/run-test.sh b/tests/e2e/scenarios/build/run-test.sh index a0cf291fa3cd6..8bf38bd18a845 100755 --- a/tests/e2e/scenarios/build/run-test.sh +++ b/tests/e2e/scenarios/build/run-test.sh @@ -23,10 +23,11 @@ make test-e2e-install cd "${GOPATH}"/src/k8s.io/kubernetes +# this job assumes pull-kops-e2e-k8s-aws-calico is always ran on presubmits kubetest2 kops -v=6 \ --up --down --build --build-kubernetes=true --target-build-arch=linux/amd64 \ --cloud-provider=gce --admin-access=0.0.0.0/0 \ - --kops-version-marker=https://storage.googleapis.com/kops-ci/bin/latest-ci.txt \ + --kops-version-marker=https://storage.googleapis.com/k8s-staging-kops/pulls/pull-kops-e2e-k8s-aws-calico/pull-"${PULL_PULL_SHA}"/latest-ci.txt \ --create-args "--networking=kubenet --set=spec.nodeProblemDetector.enabled=true" \ --test=kops \ -- \