Repository: kubernetes-sigs/cluster-api
Pull request #5074 (2021-08-10 18:39:19)

🌱 Update Controller Runtime v0.9.6 / envtest Kubernetes 1.22.0
Signed-off-by: Vince Prignano <vincepri@vmware.com>

<!-- please add a icon to the title of this PR (see https://sigs.k8s.io/cluster-api/VERSIONING.md), and delete this line and similar ones -->
<!-- the icon will be either ⚠️ (:warning:, major or breaking changes), ✨ (:sparkles:, feature additions), 🐛 (:bug:, patch and bugfixes), 📖 (:book:, documentation or proposals), or 🌱 (:seedling:, minor or other) -->

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #



Patch:
diff --git a/Makefile b/Makefile
index 8747427ed..d9322f695 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ export GO111MODULE=on
 #
 # Kubebuilder.
 #
-export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.21.2
+export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.22.0
 export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?= 60s
 export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?= 60s
 
diff --git a/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook.go b/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook.go
index 70f77406f..d3a05af5c 100644
--- a/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook.go
+++ b/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook.go
@@ -23,7 +23,6 @@ import (
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/apimachinery/pkg/util/validation/field"
-	"sigs.k8s.io/cluster-api/feature"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/webhook"
 )
@@ -51,15 +50,6 @@ var _ webhook.Validator = &KubeadmControlPlaneTemplate{}
 
 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
 func (r *KubeadmControlPlaneTemplate) ValidateCreate() error {
-	// NOTE: KubeadmControlPlaneTemplate is behind ClusterTopology feature gate flag; the web hook
-	// must prevent creating new objects in case the feature flag is disabled.
-	if !feature.Gates.Enabled(feature.ClusterTopology) {
-		return field.Forbidden(
-			field.NewPath("spec"),
-			"can be set only if the ClusterTopology feature flag is enabled",
-		)
-	}
-
 	spec := r.Spec.Template.Spec
 	allErrs := validateKubeadmControlPlaneSpec(spec, r.Namespace, field.NewPath("spec", "template", "spec"))
 	allErrs = append(allErrs, validateEtcd(&spec, nil)...)
diff --git a/go.mod b/go.mod
index b27575588..43777e294 100644
--- a/go.mod
+++ b/go.mod
@@ -40,6 +40,6 @@ require (
 	k8s.io/klog/v2 v2.9.0
 	k8s.io/kubectl v0.21.2
 	k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471
-	sigs.k8s.io/controller-runtime v0.9.5
+	sigs.k8s.io/controller-runtime v0.9.6
 	sigs.k8s.io/yaml v1.2.0
 )
diff --git a/go.sum b/go.sum
index f089bb12b..c085a50de 100644
--- a/go.sum
+++ b/go.sum
@@ -1099,8 +1099,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.19/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
-sigs.k8s.io/controller-runtime v0.9.5 h1:WThcFE6cqctTn2jCZprLICO6BaKZfhsT37uAapTNfxc=
-sigs.k8s.io/controller-runtime v0.9.5/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA=
+sigs.k8s.io/controller-runtime v0.9.6 h1:EevVMlgUj4fC1NVM4+DB3iPkWkmGRNarA66neqv9Qew=
+sigs.k8s.io/controller-runtime v0.9.6/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA=
 sigs.k8s.io/kustomize/api v0.8.8/go.mod h1:He1zoK0nk43Pc6NlV085xDXDXTNprtcyKZVm3swsdNY=
 sigs.k8s.io/kustomize/cmd/config v0.9.10/go.mod h1:Mrby0WnRH7hA6OwOYnYpfpiY0WJIMgYrEDfwOeFdMK0=
 sigs.k8s.io/kustomize/kustomize/v4 v4.1.2/go.mod h1:PxBvo4WGYlCLeRPL+ziT64wBXqbgfcalOS/SXa/tcyo=


Test patch:
diff --git a/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook_test.go b/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook_test.go
deleted file mode 100644
index 72acb9da2..000000000
--- a/controlplane/kubeadm/api/v1alpha4/kubeadmcontrolplanetemplate_webhook_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-Copyright 2021 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1alpha4
-
-import (
-	"testing"
-
-	. "github.com/onsi/gomega"
-	corev1 "k8s.io/api/core/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	utilfeature "k8s.io/component-base/featuregate/testing"
-	"k8s.io/utils/pointer"
-	"sigs.k8s.io/cluster-api/feature"
-)
-
-func TestKubeadmControlPlaneTemplateValidationFeatureGateEnabled(t *testing.T) {
-	defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
-
-	t.Run("create kubeadmcontrolplanetemplate should pass if gate enabled and valid kubeadmcontrolplanetemplate", func(t *testing.T) {
-		testnamespace := "test"
-		g := NewWithT(t)
-		kcpTemplate := &KubeadmControlPlaneTemplate{
-			ObjectMeta: metav1.ObjectMeta{
-				Name:      "kubeadmcontrolplanetemplate-test",
-				Namespace: testnamespace,
-			},
-			Spec: KubeadmControlPlaneTemplateSpec{
-				Template: KubeadmControlPlaneTemplateResource{
-					Spec: KubeadmControlPlaneSpec{
-						Replicas: pointer.Int32Ptr(3),
-						Version:  "v1.20.2",
-						MachineTemplate: KubeadmControlPlaneMachineTemplate{
-							InfrastructureRef: corev1.ObjectReference{
-								Name:       "machine-infra",
-								Namespace:  testnamespace,
-								Kind:       "TestMachineTemplate",
-								APIVersion: "test/v1alpha4",
-							},
-						},
-					},
-				},
-			},
-		}
-		g.Expect(kcpTemplate.ValidateCreate()).To(Succeed())
-	})
-}
-
-func TestKubeadmControlPlaneTemplateValidationFeatureGateDisabled(t *testing.T) {
-	// NOTE: ClusterTopology feature flag is disabled by default, thus preventing to create KubeadmControlPlaneTemplate.
-	t.Run("create kubeadmcontrolplanetemplate should not pass if gate disabled and valid kubeadmcontrolplanetemplate", func(t *testing.T) {
-		testnamespace := "test"
-		g := NewWithT(t)
-		kcpTemplate := &KubeadmControlPlaneTemplate{
-			ObjectMeta: metav1.ObjectMeta{
-				Name:      "kubeadmcontrolplanetemplate-test",
-				Namespace: testnamespace,
-			},
-			Spec: KubeadmControlPlaneTemplateSpec{
-				Template: KubeadmControlPlaneTemplateResource{
-					Spec: KubeadmControlPlaneSpec{
-						Replicas: pointer.Int32Ptr(2),
-						Version:  "1.20.2",
-						MachineTemplate: KubeadmControlPlaneMachineTemplate{
-							InfrastructureRef: corev1.ObjectReference{
-								Name:       "machine-infra",
-								Namespace:  testnamespace,
-								Kind:       "TestMachineTemplate",
-								APIVersion: "test/v1alpha4",
-							},
-						},
-					},
-				},
-			},
-		}
-		g.Expect(kcpTemplate.ValidateCreate()).NotTo(Succeed())
-	})
-}
diff --git a/test/go.mod b/test/go.mod
index c1850a8d5..a0cb67fff 100644
--- a/test/go.mod
+++ b/test/go.mod
@@ -24,7 +24,7 @@ require (
 	k8s.io/klog/v2 v2.9.0
 	k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471
 	sigs.k8s.io/cluster-api v0.0.0-00010101000000-000000000000
-	sigs.k8s.io/controller-runtime v0.9.5
+	sigs.k8s.io/controller-runtime v0.9.6
 	sigs.k8s.io/kind v0.11.1
 	sigs.k8s.io/yaml v1.2.0
 )
diff --git a/test/go.sum b/test/go.sum
index 1c870f5d0..1adef6ead 100644
--- a/test/go.sum
+++ b/test/go.sum
@@ -1419,8 +1419,8 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
 sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.19/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
-sigs.k8s.io/controller-runtime v0.9.5 h1:WThcFE6cqctTn2jCZprLICO6BaKZfhsT37uAapTNfxc=
-sigs.k8s.io/controller-runtime v0.9.5/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA=
+sigs.k8s.io/controller-runtime v0.9.6 h1:EevVMlgUj4fC1NVM4+DB3iPkWkmGRNarA66neqv9Qew=
+sigs.k8s.io/controller-runtime v0.9.6/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA=
 sigs.k8s.io/kind v0.11.1 h1:pVzOkhUwMBrCB0Q/WllQDO3v14Y+o2V0tFgjTqIUjwA=
 sigs.k8s.io/kind v0.11.1/go.mod h1:fRpgVhtqAWrtLB9ED7zQahUimpUXuG/iHT88xYqEGIA=
 sigs.k8s.io/kustomize/api v0.8.8/go.mod h1:He1zoK0nk43Pc6NlV085xDXDXTNprtcyKZVm3swsdNY=