Skip to content

Commit 4dd75f9

Browse files
authored
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
1 parent dbec452 commit 4dd75f9

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

api/v1alpha1/uffizzicluster_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ type UffizziClusterDistro struct {
184184
//+kubebuilder:resource:shortName=uc;ucluster
185185
//+kubebuilder:subresource:status
186186
//+kubebuilder:printcolumn:name="APIReady",type=string,JSONPath=`.status.conditions[?(@.type=='APIReady')].status`
187+
//+kubebuilder:printcolumn:name="DataStoreReady",type=string,JSONPath=`.status.conditions[?(@.type=='DataStoreReady')].status`
187188
//+kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Ready')].status`
188189
//+kubebuilder:printcolumn:name="Sleep",type=string,JSONPath=`.status.conditions[?(@.type=='Sleep')].status`
189190
//+kubebuilder:printcolumn:name="Host",type=string,JSONPath=`.status.host`

chart/templates/uffizziclusters.uffizzi.com_customresourcedefinition.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ spec:
2222
- jsonPath: .status.conditions[?(@.type=='APIReady')].status
2323
name: APIReady
2424
type: string
25+
- jsonPath: .status.conditions[?(@.type=='DataStoreReady')].status
26+
name: DataStoreReady
27+
type: string
2528
- jsonPath: .status.conditions[?(@.type=='Ready')].status
2629
name: Ready
2730
type: string

config/crd/bases/uffizzi.com_uffizziclusters.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ spec:
2222
- jsonPath: .status.conditions[?(@.type=='APIReady')].status
2323
name: APIReady
2424
type: string
25+
- jsonPath: .status.conditions[?(@.type=='DataStoreReady')].status
26+
name: DataStoreReady
27+
type: string
2528
- jsonPath: .status.conditions[?(@.type=='Ready')].status
2629
name: Ready
2730
type: string

controllers/uffizzicluster/uffizzicluster_controller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,11 @@ func (r *UffizziClusterReconciler) reconcileSleepState(ctx context.Context, uClu
328328
if err = r.waitForStatefulSetToScale(ctx, 0, ucStatefulSet); err == nil {
329329
setCondition(uCluster, APINotReady())
330330
}
331-
if err = r.waitForStatefulSetToScale(ctx, 0, etcdStatefulSet); err == nil {
331+
if uCluster.Spec.ExternalDatastore == constants.ETCD {
332+
if err = r.waitForStatefulSetToScale(ctx, 0, etcdStatefulSet); err == nil {
333+
setCondition(uCluster, DataStoreNotReady())
334+
}
335+
} else {
332336
setCondition(uCluster, DataStoreNotReady())
333337
}
334338
if err != nil {
@@ -354,11 +358,15 @@ func (r *UffizziClusterReconciler) reconcileSleepState(ctx context.Context, uClu
354358
// if the above runs successfully, then set the status to awake
355359
setCondition(uCluster, Awoken(lastAwakeTime))
356360
var err error
357-
if err = r.waitForStatefulSetToScale(ctx, 1, etcdStatefulSet); err == nil {
358-
setCondition(uCluster, APIReady())
361+
if uCluster.Spec.ExternalDatastore == constants.ETCD {
362+
if err = r.waitForStatefulSetToScale(ctx, 1, etcdStatefulSet); err == nil {
363+
setCondition(uCluster, DataStoreReady())
364+
}
365+
} else {
366+
setCondition(uCluster, DataStoreReady())
359367
}
360368
if err = r.waitForStatefulSetToScale(ctx, 1, ucStatefulSet); err == nil {
361-
setCondition(uCluster, DataStoreReady())
369+
setCondition(uCluster, APIReady())
362370
}
363371
if err != nil {
364372
return err

0 commit comments

Comments
 (0)