Skip to content

Commit

Permalink
Merge pull request #462 from ASBishop/improvelogs
Browse files Browse the repository at this point in the history
Improve logs
  • Loading branch information
openshift-merge-bot[bot] authored Oct 31, 2024
2 parents 009e8c0 + 84ec098 commit fcec1d5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 264 deletions.
53 changes: 9 additions & 44 deletions controllers/cinder_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (r *CinderReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
Log.Error(err, fmt.Sprintf("could not fetch Cinder instance %s", instance.Name))
return ctrl.Result{}, err
}

Expand All @@ -147,6 +148,7 @@ func (r *CinderReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
Log,
)
if err != nil {
Log.Error(err, fmt.Sprintf("could not instantiate helper for instance %s", instance.Name))
return ctrl.Result{}, err
}

Expand Down Expand Up @@ -654,22 +656,6 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder
return ctrlResult, nil
}

// Handle service update
ctrlResult, err = r.reconcileUpdate(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

//
// normal reconcile tasks
//
Expand All @@ -686,7 +672,7 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
Log.Info(fmt.Sprintf("API CR for %s successfully %s", instance.Name, string(op)))
}

// Mirror values when the data in the StatefulSet is for the current generation
Expand Down Expand Up @@ -715,7 +701,7 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
Log.Info(fmt.Sprintf("Scheduler CR for %s successfully %s", instance.Name, string(op)))
}

// Mirror values when the data in the StatefulSet is for the current generation
Expand Down Expand Up @@ -747,7 +733,7 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
Log.Info(fmt.Sprintf("Backup CR for %s successfully %s", instance.Name, string(op)))
}

// Mirror values when the data in the StatefulSet is for the current generation
Expand Down Expand Up @@ -790,7 +776,7 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder
return ctrl.Result{}, err
}
if op != controllerutil.OperationResultNone {
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
Log.Info(fmt.Sprintf("Volume %s CR for %s successfully %s", name, instance.Name, string(op)))
}

// Mirror values when the data in the StatefulSet is for the current generation
Expand Down Expand Up @@ -864,30 +850,6 @@ func (r *CinderReconciler) reconcileNormal(ctx context.Context, instance *cinder
return ctrl.Result{}, nil
}

func (r *CinderReconciler) reconcileUpdate(ctx context.Context, instance *cinderv1beta1.Cinder) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' update", instance.Name))

// TODO: should have minor update tasks if required
// - delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' update successfully", instance.Name))
return ctrl.Result{}, nil
}

func (r *CinderReconciler) reconcileUpgrade(ctx context.Context, instance *cinderv1beta1.Cinder) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' upgrade", instance.Name))

// TODO: should have major version upgrade tasks
// -delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' upgrade successfully", instance.Name))
return ctrl.Result{}, nil
}

// generateServiceConfigs - create Secret which hold scripts and service configuration
func (r *CinderReconciler) generateServiceConfigs(
ctx context.Context,
Expand Down Expand Up @@ -1253,6 +1215,8 @@ func (r *CinderReconciler) ensureDB(
h *helper.Helper,
instance *cinderv1beta1.Cinder,
) (*mariadbv1.Database, ctrl.Result, error) {
Log := r.GetLogger(ctx)

// ensure MariaDBAccount exists. This account record may be created by
// openstack-operator or the cloud operator up front without a specific
// MariaDBDatabase configured yet. Otherwise, a MariaDBAccount CR is
Expand Down Expand Up @@ -1320,6 +1284,7 @@ func (r *CinderReconciler) ensureDB(
return db, ctrlResult, err
}
if (ctrlResult != ctrl.Result{}) {
Log.Info(fmt.Sprintf("%s... requeueing", condition.DBReadyRunningMessage))
instance.Status.Conditions.Set(condition.FalseCondition(
condition.DBReadyCondition,
condition.RequestedReason,
Expand Down
40 changes: 0 additions & 40 deletions controllers/cinderapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,22 +821,6 @@ func (r *CinderAPIReconciler) reconcileNormal(ctx context.Context, instance *cin
return ctrlResult, nil
}

// Handle service update
ctrlResult, err = r.reconcileUpdate(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

//
// normal reconcile tasks
//
Expand Down Expand Up @@ -984,30 +968,6 @@ func (r *CinderAPIReconciler) reconcileNormal(ctx context.Context, instance *cin
return ctrl.Result{}, nil
}

func (r *CinderAPIReconciler) reconcileUpdate(ctx context.Context, instance *cinderv1beta1.CinderAPI) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' update", instance.Name))

// TODO: should have minor update tasks if required
// - delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' update successfully", instance.Name))
return ctrl.Result{}, nil
}

func (r *CinderAPIReconciler) reconcileUpgrade(ctx context.Context, instance *cinderv1beta1.CinderAPI) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' upgrade", instance.Name))

// TODO: should have major version upgrade tasks
// -delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' upgrade successfully", instance.Name))
return ctrl.Result{}, nil
}

// generateServiceConfigs - create Secret which holds the service configuration
func (r *CinderAPIReconciler) generateServiceConfigs(
ctx context.Context,
Expand Down
60 changes: 0 additions & 60 deletions controllers/cinderbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,6 @@ func (r *CinderBackupReconciler) reconcileDelete(ctx context.Context, instance *
return ctrl.Result{}, nil
}

func (r *CinderBackupReconciler) reconcileInit(
ctx context.Context,
instance *cinderv1beta1.CinderBackup,
) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' init", instance.Name))

Log.Info(fmt.Sprintf("Reconciled Service '%s' init successfully", instance.Name))
return ctrl.Result{}, nil
}

func (r *CinderBackupReconciler) reconcileNormal(ctx context.Context, instance *cinderv1beta1.CinderBackup, helper *helper.Helper) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Expand Down Expand Up @@ -516,30 +504,6 @@ func (r *CinderBackupReconciler) reconcileNormal(ctx context.Context, instance *
return ctrl.Result{}, err
}

// Handle service init
ctrlResult, err = r.reconcileInit(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service update
ctrlResult, err = r.reconcileUpdate(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

//
// normal reconcile tasks
//
Expand Down Expand Up @@ -652,30 +616,6 @@ func (r *CinderBackupReconciler) reconcileNormal(ctx context.Context, instance *
return ctrl.Result{}, nil
}

func (r *CinderBackupReconciler) reconcileUpdate(ctx context.Context, instance *cinderv1beta1.CinderBackup) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' update", instance.Name))

// TODO: should have minor update tasks if required
// - delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' update successfully", instance.Name))
return ctrl.Result{}, nil
}

func (r *CinderBackupReconciler) reconcileUpgrade(ctx context.Context, instance *cinderv1beta1.CinderBackup) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' upgrade", instance.Name))

// TODO: should have major version upgrade tasks
// -delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' upgrade successfully", instance.Name))
return ctrl.Result{}, nil
}

// generateServiceConfigs - create Secret which holds the service configuration
func (r *CinderBackupReconciler) generateServiceConfigs(
ctx context.Context,
Expand Down
60 changes: 0 additions & 60 deletions controllers/cinderscheduler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,6 @@ func (r *CinderSchedulerReconciler) reconcileDelete(ctx context.Context, instanc
return ctrl.Result{}, nil
}

func (r *CinderSchedulerReconciler) reconcileInit(
ctx context.Context,
instance *cinderv1beta1.CinderScheduler,
) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' init", instance.Name))

Log.Info(fmt.Sprintf("Reconciled Service '%s' init successfully", instance.Name))
return ctrl.Result{}, nil
}

func (r *CinderSchedulerReconciler) reconcileNormal(ctx context.Context, instance *cinderv1beta1.CinderScheduler, helper *helper.Helper) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Expand Down Expand Up @@ -515,30 +503,6 @@ func (r *CinderSchedulerReconciler) reconcileNormal(ctx context.Context, instanc
return ctrl.Result{}, err
}

// Handle service init
ctrlResult, err = r.reconcileInit(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service update
ctrlResult, err = r.reconcileUpdate(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

// Handle service upgrade
ctrlResult, err = r.reconcileUpgrade(ctx, instance)
if err != nil {
return ctrlResult, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

//
// normal reconcile tasks
//
Expand Down Expand Up @@ -651,30 +615,6 @@ func (r *CinderSchedulerReconciler) reconcileNormal(ctx context.Context, instanc
return ctrl.Result{}, nil
}

func (r *CinderSchedulerReconciler) reconcileUpdate(ctx context.Context, instance *cinderv1beta1.CinderScheduler) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' update", instance.Name))

// TODO: should have minor update tasks if required
// - delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' update successfully", instance.Name))
return ctrl.Result{}, nil
}

func (r *CinderSchedulerReconciler) reconcileUpgrade(ctx context.Context, instance *cinderv1beta1.CinderScheduler) (ctrl.Result, error) {
Log := r.GetLogger(ctx)

Log.Info(fmt.Sprintf("Reconciling Service '%s' upgrade", instance.Name))

// TODO: should have major version upgrade tasks
// -delete dbsync hash from status to rerun it?

Log.Info(fmt.Sprintf("Reconciled Service '%s' upgrade successfully", instance.Name))
return ctrl.Result{}, nil
}

// generateServiceConfigs - create Secret which holds the service configuration
func (r *CinderSchedulerReconciler) generateServiceConfigs(
ctx context.Context,
Expand Down
Loading

0 comments on commit fcec1d5

Please sign in to comment.