From 92eccbbbb7a54e6344f3b067510db95cbd7995d6 Mon Sep 17 00:00:00 2001 From: Jaideep Rao Date: Fri, 26 May 2023 14:40:02 -0400 Subject: [PATCH] fix phase reconciliation during host reconciliation Signed-off-by: Jaideep Rao --- api/v1alpha1/argocd_types.go | 34 +++++++++++++++--------------- api/v1alpha1/argocdexport_types.go | 32 ++++++++++++++-------------- api/v1alpha1/groupversion_info.go | 4 ++-- controllers/argocd/status.go | 3 --- controllers/argocd/status_test.go | 4 ---- 5 files changed, 35 insertions(+), 42 deletions(-) diff --git a/api/v1alpha1/argocd_types.go b/api/v1alpha1/argocd_types.go index fa1c2fa91..8e257ddbe 100644 --- a/api/v1alpha1/argocd_types.go +++ b/api/v1alpha1/argocd_types.go @@ -39,22 +39,22 @@ func init() { // ArgoCD is the Schema for the argocds API // +k8s:openapi-gen=true // +kubebuilder:subresource:status -//+operator-sdk:csv:customresourcedefinitions:resources={{ArgoCD,v1alpha1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ArgoCDExport,v1alpha1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{CronJob,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Deployment,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Ingress,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Job,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{PersistentVolumeClaim,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Prometheus,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ReplicaSet,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Route,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Secret,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Service,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ServiceMonitor,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{StatefulSet,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ArgoCD,v1alpha1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ArgoCDExport,v1alpha1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{CronJob,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Deployment,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Ingress,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Job,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{PersistentVolumeClaim,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Prometheus,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ReplicaSet,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Route,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Secret,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Service,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ServiceMonitor,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{StatefulSet,v1,""}} type ArgoCD struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -637,7 +637,7 @@ type ArgoCDMonitoringSpec struct { Enabled bool `json:"enabled"` } -//ArgoCDNodePlacementSpec is used to specify NodeSelector and Tolerations for Argo CD workloads +// ArgoCDNodePlacementSpec is used to specify NodeSelector and Tolerations for Argo CD workloads type ArgoCDNodePlacementSpec struct { // NodeSelector is a field of PodSpec, it is a map of key value pairs used for node selection NodeSelector map[string]string `json:"nodeSelector,omitempty"` diff --git a/api/v1alpha1/argocdexport_types.go b/api/v1alpha1/argocdexport_types.go index eb7e12481..f9e0e222c 100644 --- a/api/v1alpha1/argocdexport_types.go +++ b/api/v1alpha1/argocdexport_types.go @@ -30,22 +30,22 @@ import ( // +k8s:openapi-gen=true // +kubebuilder:subresource:status // +kubebuilder:resource:path=argocdexports,scope=Namespaced -//+operator-sdk:csv:customresourcedefinitions:resources={{ArgoCD,v1alpha1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ArgoCDExport,v1alpha1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{CronJob,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Deployment,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Ingress,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Job,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{PersistentVolumeClaim,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Prometheus,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ReplicaSet,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Route,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Secret,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{Service,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{ServiceMonitor,v1,""}} -//+operator-sdk:csv:customresourcedefinitions:resources={{StatefulSet,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ArgoCD,v1alpha1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ArgoCDExport,v1alpha1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{CronJob,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Deployment,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Ingress,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Job,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{PersistentVolumeClaim,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Prometheus,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ReplicaSet,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Route,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Secret,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{Service,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{ServiceMonitor,v1,""}} +// +operator-sdk:csv:customresourcedefinitions:resources={{StatefulSet,v1,""}} type ArgoCDExport struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/groupversion_info.go index 529170a0a..54238ded5 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/groupversion_info.go @@ -15,8 +15,8 @@ limitations under the License. */ // Package v1alpha1 contains API Schema definitions for the argoproj.io v1alpha1 API group -//+kubebuilder:object:generate=true -//+groupName=argoproj.io +// +kubebuilder:object:generate=true +// +groupName=argoproj.io package v1alpha1 import ( diff --git a/controllers/argocd/status.go b/controllers/argocd/status.go index 0f6a9a564..2d15a7cf5 100644 --- a/controllers/argocd/status.go +++ b/controllers/argocd/status.go @@ -277,7 +277,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) @@ -314,7 +313,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" @@ -323,7 +321,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" diff --git a/controllers/argocd/status_test.go b/controllers/argocd/status_test.go index 8586280bb..731280f1e 100644 --- a/controllers/argocd/status_test.go +++ b/controllers/argocd/status_test.go @@ -113,7 +113,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) { expectedNil bool expectedHost bool host string - phase string }{ { name: "", @@ -122,7 +121,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) { ingressEnabled: false, expectedNil: false, host: "argocd", - phase: "Available", }, { name: "", @@ -131,7 +129,6 @@ func TestReconcileArgoCD_reconcileStatusHost(t *testing.T) { ingressEnabled: true, expectedNil: false, host: "argocd, 12.0.0.5", - phase: "Available", }, } for _, test := range tests { @@ -211,7 +208,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) }) } }