From 4dd75f9455f553d8f73ee8d01e52e5c539df4932 Mon Sep 17 00:00:00 2001 From: Vibhav Bobade Date: Wed, 22 Nov 2023 18:35:13 +0530 Subject: [PATCH] fix: datastore conditions to be available on etcd availability only (#80) * fix: update conditions for datastore to be triggered only when etcd is enabled * feat: datastore ready status --- api/v1alpha1/uffizzicluster_types.go | 1 + ...ers.uffizzi.com_customresourcedefinition.yaml | 3 +++ .../crd/bases/uffizzi.com_uffizziclusters.yaml | 3 +++ .../uffizzicluster/uffizzicluster_controller.go | 16 ++++++++++++---- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/uffizzicluster_types.go b/api/v1alpha1/uffizzicluster_types.go index a858aee3..3ab7a6ee 100644 --- a/api/v1alpha1/uffizzicluster_types.go +++ b/api/v1alpha1/uffizzicluster_types.go @@ -184,6 +184,7 @@ type UffizziClusterDistro struct { //+kubebuilder:resource:shortName=uc;ucluster //+kubebuilder:subresource:status //+kubebuilder:printcolumn:name="APIReady",type=string,JSONPath=`.status.conditions[?(@.type=='APIReady')].status` +//+kubebuilder:printcolumn:name="DataStoreReady",type=string,JSONPath=`.status.conditions[?(@.type=='DataStoreReady')].status` //+kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Ready')].status` //+kubebuilder:printcolumn:name="Sleep",type=string,JSONPath=`.status.conditions[?(@.type=='Sleep')].status` //+kubebuilder:printcolumn:name="Host",type=string,JSONPath=`.status.host` diff --git a/chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml b/chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml index eb3f1ccf..8832a205 100644 --- a/chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml +++ b/chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml @@ -22,6 +22,9 @@ spec: - jsonPath: .status.conditions[?(@.type=='APIReady')].status name: APIReady type: string + - jsonPath: .status.conditions[?(@.type=='DataStoreReady')].status + name: DataStoreReady + type: string - jsonPath: .status.conditions[?(@.type=='Ready')].status name: Ready type: string diff --git a/config/crd/bases/uffizzi.com_uffizziclusters.yaml b/config/crd/bases/uffizzi.com_uffizziclusters.yaml index 67e73835..0df7493c 100644 --- a/config/crd/bases/uffizzi.com_uffizziclusters.yaml +++ b/config/crd/bases/uffizzi.com_uffizziclusters.yaml @@ -22,6 +22,9 @@ spec: - jsonPath: .status.conditions[?(@.type=='APIReady')].status name: APIReady type: string + - jsonPath: .status.conditions[?(@.type=='DataStoreReady')].status + name: DataStoreReady + type: string - jsonPath: .status.conditions[?(@.type=='Ready')].status name: Ready type: string diff --git a/controllers/uffizzicluster/uffizzicluster_controller.go b/controllers/uffizzicluster/uffizzicluster_controller.go index 037acb5d..65c222f5 100644 --- a/controllers/uffizzicluster/uffizzicluster_controller.go +++ b/controllers/uffizzicluster/uffizzicluster_controller.go @@ -328,7 +328,11 @@ func (r *UffizziClusterReconciler) reconcileSleepState(ctx context.Context, uClu if err = r.waitForStatefulSetToScale(ctx, 0, ucStatefulSet); err == nil { setCondition(uCluster, APINotReady()) } - if err = r.waitForStatefulSetToScale(ctx, 0, etcdStatefulSet); err == nil { + if uCluster.Spec.ExternalDatastore == constants.ETCD { + if err = r.waitForStatefulSetToScale(ctx, 0, etcdStatefulSet); err == nil { + setCondition(uCluster, DataStoreNotReady()) + } + } else { setCondition(uCluster, DataStoreNotReady()) } if err != nil { @@ -354,11 +358,15 @@ func (r *UffizziClusterReconciler) reconcileSleepState(ctx context.Context, uClu // if the above runs successfully, then set the status to awake setCondition(uCluster, Awoken(lastAwakeTime)) var err error - if err = r.waitForStatefulSetToScale(ctx, 1, etcdStatefulSet); err == nil { - setCondition(uCluster, APIReady()) + if uCluster.Spec.ExternalDatastore == constants.ETCD { + if err = r.waitForStatefulSetToScale(ctx, 1, etcdStatefulSet); err == nil { + setCondition(uCluster, DataStoreReady()) + } + } else { + setCondition(uCluster, DataStoreReady()) } if err = r.waitForStatefulSetToScale(ctx, 1, ucStatefulSet); err == nil { - setCondition(uCluster, DataStoreReady()) + setCondition(uCluster, APIReady()) } if err != nil { return err