From 84ec098bf85f718b5faa418b247affb60204ff35 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Tue, 19 Mar 2024 13:48:55 +0100 Subject: [PATCH] Remote useless reconciliation methods There are a number of placeholder reconciliation method that do nothing except logging messages of how the method has been entered and exited. This is useless code as well as clutter in the logs, so this patch removes them. Affected methods are: - reconcileInit - reconcileUpdate - reconcileUpgrade There are instances where reconcileInit is actually doing things, and in those cases methods were left untouched. --- controllers/cinder_controller.go | 40 --------------- controllers/cinderapi_controller.go | 40 --------------- controllers/cinderbackup_controller.go | 60 ----------------------- controllers/cinderscheduler_controller.go | 60 ----------------------- controllers/cindervolume_controller.go | 60 ----------------------- 5 files changed, 260 deletions(-) diff --git a/controllers/cinder_controller.go b/controllers/cinder_controller.go index a414636c..119da0c6 100644 --- a/controllers/cinder_controller.go +++ b/controllers/cinder_controller.go @@ -656,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 // @@ -866,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, diff --git a/controllers/cinderapi_controller.go b/controllers/cinderapi_controller.go index a6e54613..47790f7d 100644 --- a/controllers/cinderapi_controller.go +++ b/controllers/cinderapi_controller.go @@ -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 // @@ -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, diff --git a/controllers/cinderbackup_controller.go b/controllers/cinderbackup_controller.go index 6bca8055..39f06a56 100644 --- a/controllers/cinderbackup_controller.go +++ b/controllers/cinderbackup_controller.go @@ -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) @@ -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 // @@ -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, diff --git a/controllers/cinderscheduler_controller.go b/controllers/cinderscheduler_controller.go index ece04b0c..fbac5a06 100644 --- a/controllers/cinderscheduler_controller.go +++ b/controllers/cinderscheduler_controller.go @@ -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) @@ -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 // @@ -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, diff --git a/controllers/cindervolume_controller.go b/controllers/cindervolume_controller.go index aea0d30f..f00deedf 100644 --- a/controllers/cindervolume_controller.go +++ b/controllers/cindervolume_controller.go @@ -322,18 +322,6 @@ func (r *CinderVolumeReconciler) reconcileDelete(ctx context.Context, instance * return ctrl.Result{}, nil } -func (r *CinderVolumeReconciler) reconcileInit( - ctx context.Context, - instance *cinderv1beta1.CinderVolume, -) (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 *CinderVolumeReconciler) reconcileNormal(ctx context.Context, instance *cinderv1beta1.CinderVolume, helper *helper.Helper) (ctrl.Result, error) { Log := r.GetLogger(ctx) @@ -518,30 +506,6 @@ func (r *CinderVolumeReconciler) 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 // @@ -654,30 +618,6 @@ func (r *CinderVolumeReconciler) reconcileNormal(ctx context.Context, instance * return ctrl.Result{}, nil } -func (r *CinderVolumeReconciler) reconcileUpdate(ctx context.Context, instance *cinderv1beta1.CinderVolume) (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 *CinderVolumeReconciler) reconcileUpgrade(ctx context.Context, instance *cinderv1beta1.CinderVolume) (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 and check if it's using LVM func (r *CinderVolumeReconciler) generateServiceConfigs( ctx context.Context,