Skip to content

Commit

Permalink
[k8s]: Remove unnecessary time parsing in reconcile functions (#1831)
Browse files Browse the repository at this point in the history
Removes unnecessary `time.ParseDuration("1m")` from `Reconcile`
functions in controllers package and replaces it by using standard
constant `time.Minute` from `time` package.

Signed-off-by: Pavel Mokeev <[email protected]>
Co-authored-by: Pavel Mokeev <[email protected]>
  • Loading branch information
pmokeev and Pavel Mokeev authored Mar 18, 2024
1 parent 9c68c50 commit 9d55f4e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions k8s/controllers/k8s/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
}

// reconcile every minute
duration, _ := time.ParseDuration("1m")
return ctrl.Result{RequeueAfter: duration}, nil
return ctrl.Result{RequeueAfter: time.Minute}, nil
}

// UpdateStatus updates the status of the Backup.Running
Expand Down
3 changes: 1 addition & 2 deletions k8s/controllers/k8s/csidriver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ func (r *CSIDriverReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
logger.Error(err, "Failed to update the status", "CSIDriver", csiDriver)
}
// reconcile every minute
duration, _ := time.ParseDuration("1m")
return ctrl.Result{RequeueAfter: duration}, nil
return ctrl.Result{RequeueAfter: time.Minute}, nil
}

func (r *CSIDriverReconciler) UpdateStatus(ctx context.Context, csiDriver *k8sv1alpha1.CSIDriver) error {
Expand Down
3 changes: 1 addition & 2 deletions k8s/controllers/k8s/operation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ func (r *OperationReconciler) Reconcile(
}

// reconcile every minute
duration, _ := time.ParseDuration("1m")
return ctrl.Result{RequeueAfter: duration}, nil
return ctrl.Result{RequeueAfter: time.Minute}, nil
}

// UpdateStatus updates the status of the localobject
Expand Down
3 changes: 1 addition & 2 deletions k8s/controllers/k8s/recover_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ func (r *RecoverReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}

// reconcile every minute
duration, _ := time.ParseDuration("1m")
return ctrl.Result{RequeueAfter: duration}, nil
return ctrl.Result{RequeueAfter: time.Minute}, nil
}

// UpdateStateStatus updates the state status of the Recover.
Expand Down
3 changes: 1 addition & 2 deletions k8s/controllers/k8s/sidecar_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ func (r *SidecarReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
}

// reconcile every minute
duration, _ := time.ParseDuration("1m")
return ctrl.Result{RequeueAfter: duration}, nil
return ctrl.Result{RequeueAfter: time.Minute}, nil
}

// UpdateStatus updates the status of the Sidecar.
Expand Down
3 changes: 1 addition & 2 deletions k8s/controllers/k8s/vineyardd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ func (r *VineyarddReconciler) Reconcile(
}

// reconcile every minute
duration, _ := time.ParseDuration("1m")
return ctrl.Result{RequeueAfter: duration}, nil
return ctrl.Result{RequeueAfter: time.Minute}, nil
}

// UpdateStatus updates the status of the Vineyardd.
Expand Down

0 comments on commit 9d55f4e

Please sign in to comment.