Skip to content

Commit ec2bd8c

Browse files
committed
Log DeploymentConditions reason and message when Deployment is failing
Displays the Deployment Condition reason and message when the Deployment is not progressing or there is a Replica failure.
1 parent bf81bf0 commit ec2bd8c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/resourcebuilder/apps.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"fmt"
66

7+
"strings"
8+
79
"k8s.io/klog"
810

911
"github.com/openshift/cluster-version-operator/lib"
@@ -74,7 +76,28 @@ func waitForDeploymentCompletion(ctx context.Context, client appsclientv1.Deploy
7476
if d.Generation <= d.Status.ObservedGeneration && d.Status.UpdatedReplicas == d.Status.Replicas && d.Status.UnavailableReplicas == 0 {
7577
return true, nil
7678
}
77-
klog.V(4).Infof("Deployment %s is not ready. status: (replicas: %d, updated: %d, ready: %d, unavailable: %d)", d.Name, d.Status.Replicas, d.Status.UpdatedReplicas, d.Status.ReadyReplicas, d.Status.UnavailableReplicas)
79+
80+
deploymentConditions := make([]string, 0, len(d.Status.Conditions))
81+
for _, dc := range d.Status.Conditions {
82+
switch dc.Type {
83+
case appsv1.DeploymentProgressing, appsv1.DeploymentAvailable:
84+
if dc.Status == "False" {
85+
deploymentConditions = append(deploymentConditions, fmt.Sprintf(", reason: %s, message: %s", dc.Reason, dc.Message))
86+
}
87+
case appsv1.DeploymentReplicaFailure:
88+
if dc.Status == "True" {
89+
deploymentConditions = append(deploymentConditions, fmt.Sprintf(", reason: %s, message: %s", dc.Reason, dc.Message))
90+
}
91+
}
92+
}
93+
94+
klog.V(4).Infof("Deployment %s is not ready. status: (replicas: %d, updated: %d, ready: %d, unavailable: %d%s)",
95+
d.Name,
96+
d.Status.Replicas,
97+
d.Status.UpdatedReplicas,
98+
d.Status.ReadyReplicas,
99+
d.Status.UnavailableReplicas,
100+
strings.Join(deploymentConditions, ""))
78101
return false, nil
79102
}, ctx.Done())
80103
}

0 commit comments

Comments
 (0)