Skip to content

Commit 9a8f010

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 e192eb5 commit 9a8f010

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

internal/wait/deployment.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,28 @@ 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+
return false
57+
}
58+
if newStatus.UpdatedReplicas != replicas {
59+
klog.InfoS("newStatus.UpdatedReplicas", "expected", replicas, "found", newStatus.UpdatedReplicas)
60+
return false
61+
}
62+
if newStatus.AvailableReplicas != replicas {
63+
klog.InfoS("newStatus.AvailableReplicas", "expected", replicas, "found", newStatus.AvailableReplicas)
64+
return false
65+
}
66+
return true
5767
}
5868

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

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

0 commit comments

Comments
 (0)