Skip to content

Commit

Permalink
Merge pull request #34 from kitagry/fix-controllers
Browse files Browse the repository at this point in the history
don't return both non-nil result and non-nil error
  • Loading branch information
kitagry authored Aug 21, 2024
2 parents fe72e0c + 5433875 commit 1ce774e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions controllers/berglassecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ func (r *BerglasSecretReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, client.IgnoreNotFound(err)
}

result := ctrl.Result{
RequeueAfter: getOrDefault(berglasSecret.Spec.RefreshInterval, metav1.Duration{Duration: defaultRefreshInterval}).Duration,
}
if err := r.reconcileSecret(ctx, req, &berglasSecret); err != nil {
logger.Error(err, "failed to reconcile secret")
setCondition(&berglasSecret.Status, batchv1alpha1.BerglasSecretCondition{
Expand All @@ -79,7 +76,7 @@ func (r *BerglasSecretReconciler) Reconcile(ctx context.Context, req ctrl.Reques
if stErr != nil {
logger.Error(err, "failed to update status")
}
return result, err
return ctrl.Result{}, err
}

setCondition(&berglasSecret.Status, batchv1alpha1.BerglasSecretCondition{
Expand All @@ -89,11 +86,13 @@ func (r *BerglasSecretReconciler) Reconcile(ctx context.Context, req ctrl.Reques
err := r.Status().Update(ctx, &berglasSecret)
if err != nil {
logger.Error(err, "failed to update status")
return result, err
return ctrl.Result{}, err
}

logger.Info("success to reconcile")
return result, nil
return ctrl.Result{
RequeueAfter: getOrDefault(berglasSecret.Spec.RefreshInterval, metav1.Duration{Duration: defaultRefreshInterval}).Duration,
}, nil
}

func (r *BerglasSecretReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
Expand Down

0 comments on commit 1ce774e

Please sign in to comment.