Skip to content

Commit

Permalink
fix: datastore conditions to be available on etcd availability only (#80
Browse files Browse the repository at this point in the history
)

* fix: update conditions for datastore to be triggered only when etcd is enabled

* feat: datastore ready status
  • Loading branch information
waveywaves authored Nov 22, 2023
1 parent dbec452 commit 4dd75f9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/uffizzicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/uffizzi.com_uffizziclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions controllers/uffizzicluster/uffizzicluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 4dd75f9

Please sign in to comment.