Skip to content

Commit

Permalink
Add Failed condition status for other controllers
Browse files Browse the repository at this point in the history
Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com>
  • Loading branch information
Rizwana777 committed Feb 6, 2024
1 parent c326209 commit e13a9f7
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion controllers/argocd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ 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"
appsv1 "k8s.io/api/apps/v1"
)

// reconcileStatus will ensure that all of the Status properties are updated for the given ArgoCD.
Expand Down Expand Up @@ -105,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 @@ -134,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 @@ -145,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 Down Expand Up @@ -244,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 @@ -277,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 @@ -300,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 @@ -322,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 e13a9f7

Please sign in to comment.