Skip to content

Commit

Permalink
Changed SetDatabaseNotReady and SetObjStoreNotReady to be more versatile
Browse files Browse the repository at this point in the history
Signed-off-by: hbelmiro <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro committed May 23, 2024
1 parent 081fca6 commit f5ae58c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
21 changes: 15 additions & 6 deletions controllers/dspastatus/dspa_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

type DSPAStatus interface {
SetDatabaseReady()
SetDatabaseNotReady(err error)
SetDatabaseNotReady(err error, reason string)

SetObjStoreReady()
SetObjStoreNotReady(err error)
SetObjStoreNotReady(err error, reason string)

SetApiServerStatus(apiServerReady metav1.Condition)

Expand Down Expand Up @@ -49,8 +49,12 @@ type dspaStatus struct {
scheduledWorkflowReady *metav1.Condition
}

func (s *dspaStatus) SetDatabaseNotReady(err error) {
condition := BuildFalseCondition(config.DatabaseAvailable, config.FailingToDeploy, err.Error())
func (s *dspaStatus) SetDatabaseNotReady(err error, reason string) {
message := ""
if err != nil {
message = err.Error()
}
condition := BuildFalseCondition(config.DatabaseAvailable, reason, message)
s.databaseAvailable = &condition
}

Expand All @@ -64,8 +68,13 @@ func (s *dspaStatus) SetObjStoreReady() {
s.objStoreAvailable = &condition
}

func (s *dspaStatus) SetObjStoreNotReady(err error) {
condition := BuildFalseCondition(config.ObjectStoreAvailable, config.FailingToDeploy, err.Error())
func (s *dspaStatus) SetObjStoreNotReady(err error, reason string) {
message := ""
if err != nil {
message = err.Error()
}

condition := BuildFalseCondition(config.ObjectStoreAvailable, reason, message)
s.objStoreAvailable = &condition
}

Expand Down
8 changes: 4 additions & 4 deletions controllers/dspipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.

err = r.ReconcileDatabase(ctx, dspa, params)
if err != nil {
dspaStatus.SetDatabaseNotReady(err)
dspaStatus.SetDatabaseNotReady(err, config.FailingToDeploy)
return ctrl.Result{}, err
} else {
dspaStatus.SetDatabaseReady()
}

err = r.ReconcileStorage(ctx, dspa, params)
if err != nil {
dspaStatus.SetObjStoreNotReady(err)
dspaStatus.SetObjStoreNotReady(err, config.FailingToDeploy)
return ctrl.Result{}, err
} else {
dspaStatus.SetObjStoreReady()
Expand All @@ -249,14 +249,14 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
dbAvailable, err := r.isDatabaseAccessible(dspa, params)

if err != nil {
dspaStatus.SetDatabaseNotReady(err)
dspaStatus.SetDatabaseNotReady(err, config.FailingToDeploy)
} else {
dspaStatus.SetDatabaseReady()
}

objStoreAvailable, err := r.isObjectStorageAccessible(ctx, dspa, params)
if err != nil {
dspaStatus.SetObjStoreNotReady(err)
dspaStatus.SetObjStoreNotReady(err, config.FailingToDeploy)
} else {
dspaStatus.SetObjStoreReady()
}
Expand Down

0 comments on commit f5ae58c

Please sign in to comment.