From 3db18fb824790c17a294b3a92dd147a174bf1dc9 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Mon, 21 Oct 2024 10:23:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20kcp:=20consider=20all=20machines?= =?UTF-8?q?=20for=20setting=20.status.version=20(#11304)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * kcp: consider all machines for setting .status.version * util: drop unused collections.HealthyAPIServer --- .../kubeadm/internal/controllers/status.go | 3 +-- util/collections/machine_filters.go | 11 ---------- util/collections/machine_filters_test.go | 20 ------------------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/controlplane/kubeadm/internal/controllers/status.go b/controlplane/kubeadm/internal/controllers/status.go index 7ebdbe6da49e..d24589047fb2 100644 --- a/controlplane/kubeadm/internal/controllers/status.go +++ b/controlplane/kubeadm/internal/controllers/status.go @@ -56,8 +56,7 @@ func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, contro return nil } - machinesWithHealthyAPIServer := controlPlane.Machines.Filter(collections.HealthyAPIServer()) - lowestVersion := machinesWithHealthyAPIServer.LowestVersion() + lowestVersion := controlPlane.Machines.LowestVersion() if lowestVersion != nil { controlPlane.KCP.Status.Version = lowestVersion } diff --git a/util/collections/machine_filters.go b/util/collections/machine_filters.go index 6c0c7813ad9a..bc44f5f16c0d 100644 --- a/util/collections/machine_filters.go +++ b/util/collections/machine_filters.go @@ -290,17 +290,6 @@ func WithVersion() Func { } } -// HealthyAPIServer returns a filter to find all machines that have a MachineAPIServerPodHealthyCondition -// set to true. -func HealthyAPIServer() Func { - return func(machine *clusterv1.Machine) bool { - if machine == nil { - return false - } - return conditions.IsTrue(machine, controlplanev1.MachineAPIServerPodHealthyCondition) - } -} - // HasNode returns a filter to find all machines that have a corresponding Kubernetes node. func HasNode() Func { return func(machine *clusterv1.Machine) bool { diff --git a/util/collections/machine_filters_test.go b/util/collections/machine_filters_test.go index d398f1f42532..bddae2b3dd34 100644 --- a/util/collections/machine_filters_test.go +++ b/util/collections/machine_filters_test.go @@ -378,26 +378,6 @@ func TestWithVersion(t *testing.T) { }) } -func TestHealthyAPIServer(t *testing.T) { - t.Run("nil machine returns false", func(t *testing.T) { - g := NewWithT(t) - g.Expect(collections.HealthyAPIServer()(nil)).To(BeFalse()) - }) - - t.Run("unhealthy machine returns false", func(t *testing.T) { - g := NewWithT(t) - machine := &clusterv1.Machine{} - g.Expect(collections.HealthyAPIServer()(machine)).To(BeFalse()) - }) - - t.Run("healthy machine returns true", func(t *testing.T) { - g := NewWithT(t) - machine := &clusterv1.Machine{} - conditions.Set(machine, conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition)) - g.Expect(collections.HealthyAPIServer()(machine)).To(BeTrue()) - }) -} - func TestGetFilteredMachinesForCluster(t *testing.T) { g := NewWithT(t)