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 <matt.farina@suse.com>
pull/12698/head
Matt Farina 11 months ago
parent b299359f66
commit c042264a9d
No known key found for this signature in database
GPG Key ID: 92C44A3D421FF7F9

@ -90,13 +90,6 @@ type ReadyChecker struct {
// IsReady will fetch the latest state of the object from the server prior to // IsReady will fetch the latest state of the object from the server prior to
// performing readiness checks, and it will return any error encountered. // performing readiness checks, and it will return any error encountered.
func (c *ReadyChecker) IsReady(ctx context.Context, v *resource.Info) (bool, error) { 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) { switch value := AsVersioned(v).(type) {
case *corev1.Pod: case *corev1.Pod:
pod, err := c.client.CoreV1().Pods(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{}) pod, err := c.client.CoreV1().Pods(v.Namespace).Get(ctx, v.Name, metav1.GetOptions{})

@ -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", name: "statefulset is ready when current revision for current replicas does not match update revision for updated replicas when using partition !=0",
args: args{ args: args{
sts: newStatefulSetWithUpdateRevision("foo", 3, 2, 3, 3, "foo-bbbbbbb"), sts: newStatefulSetWithUpdateRevision("foo", 3, 2, 3, 3, "foo-bbbbbbb", true),
}, },
want: 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 { func newDaemonSet(name string, maxUnavailable, numberReady, desiredNumberScheduled, updatedNumberScheduled int, generationInSync bool) *appsv1.DaemonSet {
var generation, observedGeneration int64 = 1, 1 var generation, observedGeneration int64 = 1, 1
if !generationInSync { if !generationInSync {

Loading…
Cancel
Save