Skip to content

Commit

Permalink
fix: don't set phase to available during host reconciliation (#918)
Browse files Browse the repository at this point in the history
* upgrade golangci-lint

Signed-off-by: Jaideep Rao <jaideep.r97@gmail.com>

* fix phase reconciliation during host reconciliation

Signed-off-by: Jaideep Rao <jaideep.r97@gmail.com>

* address review comment

Signed-off-by: Jaideep Rao <jaideep.r97@gmail.com>

* set phase to pending if ingress not found

Signed-off-by: Jaideep Rao <jaideep.r97@gmail.com>

---------

Signed-off-by: Jaideep Rao <jaideep.r97@gmail.com>
  • Loading branch information
jaideepr97 authored Jul 20, 2023
1 parent ba14854 commit 1caabde
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
5 changes: 1 addition & 4 deletions controllers/argocd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ func (r *ReconcileArgoCD) reconcileStatusNotifications(cr *argoprojv1a1.ArgoCD)
// reconcileStatusHost will ensure that the host status is updated for the given ArgoCD.
func (r *ReconcileArgoCD) reconcileStatusHost(cr *argoprojv1a1.ArgoCD) error {
cr.Status.Host = ""
cr.Status.Phase = "Available"

if (cr.Spec.Server.Route.Enabled || cr.Spec.Server.Ingress.Enabled) && IsRouteAPIAvailable() {
route := newRouteWithSuffix("server", cr)
Expand Down Expand Up @@ -365,7 +364,6 @@ func (r *ReconcileArgoCD) reconcileStatusHost(cr *argoprojv1a1.ArgoCD) error {
if len(route.Status.Ingress[0].Conditions) > 0 && route.Status.Ingress[0].Conditions[0].Type == routev1.RouteAdmitted {
if route.Status.Ingress[0].Conditions[0].Status == corev1.ConditionTrue {
cr.Status.Host = route.Status.Ingress[0].Host
cr.Status.Phase = "Available"
} else {
cr.Status.Host = ""
cr.Status.Phase = "Pending"
Expand All @@ -374,7 +372,6 @@ func (r *ReconcileArgoCD) reconcileStatusHost(cr *argoprojv1a1.ArgoCD) error {
// no conditions are available
if route.Status.Ingress[0].Host != "" {
cr.Status.Host = route.Status.Ingress[0].Host
cr.Status.Phase = "Available"
} else {
cr.Status.Host = "Unavailable"
cr.Status.Phase = "Pending"
Expand All @@ -386,6 +383,7 @@ func (r *ReconcileArgoCD) reconcileStatusHost(cr *argoprojv1a1.ArgoCD) error {
ingress := newIngressWithSuffix("server", cr)
if !argoutil.IsObjectFound(r.Client, cr.Namespace, ingress.Name, ingress) {
log.Info("argocd-server ingress requested but not found on cluster")
cr.Status.Phase = "Pending"
return nil
} else {
if !reflect.DeepEqual(ingress.Status.LoadBalancer, corev1.LoadBalancerStatus{}) && len(ingress.Status.LoadBalancer.Ingress) > 0 {
Expand All @@ -402,7 +400,6 @@ func (r *ReconcileArgoCD) reconcileStatusHost(cr *argoprojv1a1.ArgoCD) error {
}
hosts = strings.Join(s, ", ")
cr.Status.Host = hosts
cr.Status.Phase = "Available"
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions controllers/argocd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) {
expectedNil bool
expectedHost bool
host string
phase string
}{
{
name: "",
Expand All @@ -161,7 +160,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) {
ingressEnabled: false,
expectedNil: false,
host: "argocd",
phase: "Available",
},
{
name: "",
Expand All @@ -170,7 +168,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) {
ingressEnabled: true,
expectedNil: false,
host: "argocd, 12.0.0.5",
phase: "Available",
},
}
for _, test := range tests {
Expand Down Expand Up @@ -250,7 +247,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) {
assert.NoError(t, err)

assert.Equal(t, test.host, a.Status.Host)
assert.Equal(t, test.phase, a.Status.Phase)
})
}
}
Expand Down

0 comments on commit 1caabde

Please sign in to comment.