Skip to content

Commit cc22f61

Browse files
Merge pull request #417 from wking/waitForDeploymentRollout-lastError
Bug 1763293: pkg/operator/sync: Track lastError in waitForDeploymentRollout
2 parents 7459ad7 + a68bba5 commit cc22f61

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pkg/operator/sync.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,37 @@ func (optr *Operator) syncBaremetalControllers(config *OperatorConfig) error {
113113
}
114114

115115
func (optr *Operator) waitForDeploymentRollout(resource *appsv1.Deployment) error {
116-
return wait.Poll(deploymentRolloutPollInterval, deploymentRolloutTimeout, func() (bool, error) {
116+
var lastError error
117+
err := wait.Poll(deploymentRolloutPollInterval, deploymentRolloutTimeout, func() (bool, error) {
117118
d, err := optr.deployLister.Deployments(resource.Namespace).Get(resource.Name)
118119
if apierrors.IsNotFound(err) {
119120
return false, nil
120121
}
121122
if err != nil {
122123
// Do not return error here, as we could be updating the API Server itself, in which case we
123124
// want to continue waiting.
124-
glog.Errorf("Error getting Deployment %q during rollout: %v", resource.Name, err)
125+
lastError = fmt.Errorf("getting Deployment %s during rollout: %v", resource.Name, err)
126+
glog.Error(lastError)
125127
return false, nil
126128
}
127129

128130
if d.DeletionTimestamp != nil {
129-
return false, fmt.Errorf("deployment %q is being deleted", resource.Name)
131+
lastError = nil
132+
return false, fmt.Errorf("deployment %s is being deleted", resource.Name)
130133
}
131134

132135
if d.Generation <= d.Status.ObservedGeneration && d.Status.UpdatedReplicas == d.Status.Replicas && d.Status.UnavailableReplicas == 0 {
136+
lastError = nil
133137
return true, nil
134138
}
135-
glog.V(4).Infof("Deployment %q 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)
139+
lastError = fmt.Errorf("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)
140+
glog.V(4).Info(lastError)
136141
return false, nil
137142
})
143+
if lastError != nil {
144+
return lastError
145+
}
146+
return err
138147
}
139148

140149
func newDeployment(config *OperatorConfig, features map[string]bool) *appsv1.Deployment {

0 commit comments

Comments
 (0)