Skip to content

Commit

Permalink
Add Failed status field for all ArgoCD Controllers (#1164)
Browse files Browse the repository at this point in the history
* Add Failed condition status for all controllers
---------

Signed-off-by: Rizwana777 <[email protected]>
  • Loading branch information
Rizwana777 authored Feb 12, 2024
1 parent 2962e00 commit 20dd48b
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions controllers/argocd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"k8s.io/apimachinery/pkg/labels"
"sigs.k8s.io/controller-runtime/pkg/client"

appsv1 "k8s.io/api/apps/v1"

argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/controllers/argoutil"
)
Expand Down Expand Up @@ -104,6 +106,14 @@ func (r *ReconcileArgoCD) reconcileStatusDex(cr *argoproj.ArgoCD) error {
if deploy.Spec.Replicas != nil {
if deploy.Status.ReadyReplicas == *deploy.Spec.Replicas {
status = "Running"
} else if deploy.Status.Conditions != nil {
for _, condition := range deploy.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}
}
Expand Down Expand Up @@ -133,6 +143,14 @@ func (r *ReconcileArgoCD) reconcileStatusKeycloak(cr *argoproj.ArgoCD) error {

if dc.Status.ReadyReplicas == dc.Spec.Replicas {
status = "Running"
} else if dc.Status.Conditions != nil {
for _, condition := range dc.Status.Conditions {
if condition.Type == oappsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}

Expand All @@ -144,7 +162,16 @@ func (r *ReconcileArgoCD) reconcileStatusKeycloak(cr *argoproj.ArgoCD) error {
if d.Spec.Replicas != nil {
if d.Status.ReadyReplicas == *d.Spec.Replicas {
status = "Running"
} else if d.Status.Conditions != nil {
for _, condition := range d.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}

}
}
}
Expand All @@ -168,6 +195,14 @@ func (r *ReconcileArgoCD) reconcileStatusApplicationSetController(cr *argoproj.A
if deploy.Spec.Replicas != nil {
if deploy.Status.ReadyReplicas == *deploy.Spec.Replicas {
status = "Running"
} else if deploy.Status.Conditions != nil {
for _, condition := range deploy.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}
}
Expand Down Expand Up @@ -235,6 +270,14 @@ func (r *ReconcileArgoCD) reconcileStatusRedis(cr *argoproj.ArgoCD) error {
if deploy.Spec.Replicas != nil {
if deploy.Status.ReadyReplicas == *deploy.Spec.Replicas {
status = "Running"
} else if deploy.Status.Conditions != nil {
for _, condition := range deploy.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}
}
Expand Down Expand Up @@ -268,6 +311,14 @@ func (r *ReconcileArgoCD) reconcileStatusRepo(cr *argoproj.ArgoCD) error {
if deploy.Spec.Replicas != nil {
if deploy.Status.ReadyReplicas == *deploy.Spec.Replicas {
status = "Running"
} else if deploy.Status.Conditions != nil {
for _, condition := range deploy.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}
}
Expand All @@ -291,6 +342,14 @@ func (r *ReconcileArgoCD) reconcileStatusServer(cr *argoproj.ArgoCD) error {
if deploy.Spec.Replicas != nil {
if deploy.Status.ReadyReplicas == *deploy.Spec.Replicas {
status = "Running"
} else if deploy.Status.Conditions != nil {
for _, condition := range deploy.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}
}
Expand All @@ -313,6 +372,14 @@ func (r *ReconcileArgoCD) reconcileStatusNotifications(cr *argoproj.ArgoCD) erro
if deploy.Spec.Replicas != nil {
if deploy.Status.ReadyReplicas == *deploy.Spec.Replicas {
status = "Running"
} else if deploy.Status.Conditions != nil {
for _, condition := range deploy.Status.Conditions {
if condition.Type == appsv1.DeploymentReplicaFailure && condition.Status == corev1.ConditionTrue {
// Deployment has failed
status = "Failed"
break
}
}
}
}
}
Expand Down

0 comments on commit 20dd48b

Please sign in to comment.