Skip to content

Commit 098333c

Browse files
committed
internal: add debugging logs for deployment completion check
The check includes many verification steps that only when all passed the function pass. Sometimes the check fails without extra details of what exactly was the step that failed. This commit adds debugging logs to provide these details. Signed-off-by: Shereen Haj <shajmakh@redhat.com>
1 parent d8100bf commit 098333c

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

internal/wait/deployment.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,25 @@ func (wt Waiter) ForDeploymentComplete(ctx context.Context, dp *appsv1.Deploymen
5151
}
5252

5353
func areDeploymentReplicasAvailable(newStatus *appsv1.DeploymentStatus, replicas int32) bool {
54-
return newStatus.UpdatedReplicas == replicas &&
55-
newStatus.Replicas == replicas &&
56-
newStatus.AvailableReplicas == replicas
54+
if newStatus.Replicas != replicas {
55+
klog.InfoS("newStatus.Replicas", "expected", replicas, "found", newStatus.Replicas)
56+
}
57+
if newStatus.UpdatedReplicas != replicas {
58+
klog.InfoS("newStatus.UpdatedReplicas", "expected", replicas, "found", newStatus.UpdatedReplicas)
59+
}
60+
if newStatus.AvailableReplicas != replicas {
61+
klog.InfoS("newStatus.AvailableReplicas", "expected", replicas, "found", newStatus.AvailableReplicas)
62+
}
63+
return true
5764
}
5865

5966
func IsDeploymentComplete(dp *appsv1.Deployment, newStatus *appsv1.DeploymentStatus) bool {
60-
return areDeploymentReplicasAvailable(newStatus, *(dp.Spec.Replicas)) &&
61-
newStatus.ObservedGeneration >= dp.Generation
67+
if newStatus.ObservedGeneration < dp.Generation {
68+
klog.InfoS("generation is older than expected to indicate the deployment is complete", "old", dp.Generation, "new", newStatus.ObservedGeneration)
69+
return false
70+
}
71+
72+
return areDeploymentReplicasAvailable(newStatus, *(dp.Spec.Replicas))
6273
}
6374

6475
func (wt Waiter) ForDeploymentReplicasCreation(ctx context.Context, dp *appsv1.Deployment, expectedReplicas int32) (*appsv1.Deployment, error) {

0 commit comments

Comments
 (0)