Skip to content

Commit

Permalink
Improve log message on deployment reconciliation (#48)
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Oct 23, 2023
1 parent 33e3744 commit 1c6f35e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,23 @@ func reconcileNs(cfg config.Config) error {
}

func waitForDeployment(ns, deployment string, maxWaitTimeout time.Duration) error {
return wait.PollUntilContextTimeout(context.TODO(), time.Second, maxWaitTimeout, true, func(ctx context.Context) (bool, error) {
var errMsg string
log.Infof("Waiting for replicas from deployment %s in ns %s to be ready", deployment, ns)
err := wait.PollUntilContextTimeout(context.TODO(), time.Second, maxWaitTimeout, true, func(ctx context.Context) (bool, error) {
dep, err := clientSet.AppsV1().Deployments(ns).Get(context.TODO(), deployment, metav1.GetOptions{})
if err != nil {
return false, err
}
if *dep.Spec.Replicas != dep.Status.ReadyReplicas || *dep.Spec.Replicas != dep.Status.AvailableReplicas {
log.Debugf("Waiting for replicas from deployment %s in ns %s to be ready", deployment, ns)
errMsg = fmt.Sprintf("%d/%d replicas ready", dep.Status.AvailableReplicas, *dep.Spec.Replicas)
log.Debug(errMsg)
return false, nil
}
log.Debugf("%d replicas from deployment %s ready", dep.Status.UpdatedReplicas, deployment)
return true, nil
})
if err != nil && errMsg != "" {
log.Error(errMsg)
}
return err
}

0 comments on commit 1c6f35e

Please sign in to comment.