Skip to content

Commit

Permalink
🐛 kcp: consider all machines for setting .status.version (#11304)
Browse files Browse the repository at this point in the history
* kcp: consider all machines for setting .status.version

* util: drop unused collections.HealthyAPIServer
  • Loading branch information
chrischdi authored Oct 21, 2024
1 parent 48d26cb commit 3db18fb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
3 changes: 1 addition & 2 deletions controlplane/kubeadm/internal/controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 0 additions & 11 deletions util/collections/machine_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 0 additions & 20 deletions util/collections/machine_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3db18fb

Please sign in to comment.