From c042264a9d1dd5d584684e105aa1ab0e38d96f20 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Mon, 8 Jan 2024 22:40:28 -0500 Subject: [PATCH] Fix issues when verify generation readiness was merged CI, tests, and building failed after #10920 was merged. This change fixes the issues that were introduced. Signed-off-by: Matt Farina --- pkg/kube/ready.go | 7 ------- pkg/kube/ready_test.go | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/kube/ready.go b/pkg/kube/ready.go index f7de909f3..b2d26ba76 100644 --- a/pkg/kube/ready.go +++ b/pkg/kube/ready.go @@ -90,13 +90,6 @@ type ReadyChecker struct { // IsReady will fetch the latest state of the object from the server prior to // performing readiness checks, and it will return any error encountered. func (c *ReadyChecker) IsReady(ctx context.Context, v *resource.Info) (bool, error) { - var ( - // This defaults to true, otherwise we get to a point where - // things will always return false unless one of the objects - // that manages pods has been hit - ok = true - err error - ) switch value := AsVersioned(v).(type) { case *corev1.Pod: pod, err := c.client.CoreV1().Pods(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{}) diff --git a/pkg/kube/ready_test.go b/pkg/kube/ready_test.go index a4c1d076b..3b8c4b80a 100644 --- a/pkg/kube/ready_test.go +++ b/pkg/kube/ready_test.go @@ -283,7 +283,7 @@ func Test_ReadyChecker_statefulSetReady(t *testing.T) { { name: "statefulset is ready when current revision for current replicas does not match update revision for updated replicas when using partition !=0", args: args{ - sts: newStatefulSetWithUpdateRevision("foo", 3, 2, 3, 3, "foo-bbbbbbb"), + sts: newStatefulSetWithUpdateRevision("foo", 3, 2, 3, 3, "foo-bbbbbbb", true), }, want: true, }, @@ -463,6 +463,12 @@ func Test_ReadyChecker_volumeReady(t *testing.T) { } } +func newStatefulSetWithUpdateRevision(name string, replicas, partition, readyReplicas, updatedReplicas int, updateRevision string, generationInSync bool) *appsv1.StatefulSet { + ss := newStatefulSet(name, replicas, partition, readyReplicas, updatedReplicas, generationInSync) + ss.Status.UpdateRevision = updateRevision + return ss +} + func newDaemonSet(name string, maxUnavailable, numberReady, desiredNumberScheduled, updatedNumberScheduled int, generationInSync bool) *appsv1.DaemonSet { var generation, observedGeneration int64 = 1, 1 if !generationInSync {