Skip to content

Commit

Permalink
Merge pull request #142 from Kuadrant/improve-status-report
Browse files Browse the repository at this point in the history
improve deployment status report
  • Loading branch information
eguzki authored Jun 11, 2024
2 parents 8df92db + 1bc2191 commit 9187002
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions controllers/limitador_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -115,25 +116,35 @@ func (r *LimitadorReconciler) checkLimitadorAvailable(ctx context.Context, limit
Name: limitador.DeploymentName(limitadorObj),
}
err := r.Client().Get(ctx, dKey, deployment)
if err != nil && !apierrors.IsNotFound(err) {
if client.IgnoreNotFound(err) != nil {
return nil, err
}

if err != nil && apierrors.IsNotFound(err) {
tmp := err.Error()
return &tmp, nil
if apierrors.IsNotFound(err) {
return ptr.To(err.Error()), nil
}

availableCondition := helpers.FindDeploymentStatusCondition(deployment.Status.Conditions, "Available")
if deployment.Status.ObservedGeneration != deployment.Generation {
return ptr.To("Deployment still in progress"), nil
}

availableCondition := helpers.FindDeploymentStatusCondition(deployment.Status.Conditions, string(appsv1.DeploymentAvailable))
if availableCondition == nil {
tmp := "Available condition not found"
return &tmp, nil
return ptr.To("Available condition not found"), nil
}

if availableCondition.Status != corev1.ConditionTrue {
return &availableCondition.Message, nil
}

if deployment.Status.UnavailableReplicas != 0 {
return ptr.To("Deployment has unavailable replicas"), nil
}

if deployment.Status.ReadyReplicas != deployment.Status.Replicas {
return ptr.To("Deployment has replicas not ready yet"), nil
}

return nil, nil
}

Expand Down

0 comments on commit 9187002

Please sign in to comment.