Skip to content

Commit

Permalink
Rename error to make revive linter happy
Browse files Browse the repository at this point in the history
Replacing the "github.com/pkg/errors" with "errors" reveal a lint issue
with the revive linter:

    InitialWaitTimeForDRPCPlacementRule should have name of the form ErrFoo (revive)

While fixing, remove pointless wrapping. errors.Is() is documented to
match any error in err's tree including err itself.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Dec 1, 2024
1 parent 97810ba commit e510dc3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/controller/drplacementcontrol_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const (
DoNotDeletePVCAnnotationVal = "true"
)

var InitialWaitTimeForDRPCPlacementRule = errors.New("Waiting for DRPC Placement to produces placement decision")
var ErrInitialWaitTimeForDRPCPlacementRule = errors.New("Waiting for DRPC Placement to produces placement decision")

Check failure on line 63 in internal/controller/drplacementcontrol_controller.go

View workflow job for this annotation

GitHub Actions / Golangci Lint (.)

ST1005: error strings should not be capitalized (stylecheck)

// ProgressCallback of function type
type ProgressCallback func(string, string)
Expand Down Expand Up @@ -222,17 +222,17 @@ func (r *DRPlacementControlReconciler) Reconcile(ctx context.Context, req ctrl.R
}

d, err := r.createDRPCInstance(ctx, drPolicy, drpc, placementObj, ramenConfig, logger)
if err != nil && !errors.Is(err, InitialWaitTimeForDRPCPlacementRule) {
if err != nil && !errors.Is(err, ErrInitialWaitTimeForDRPCPlacementRule) {
err2 := r.updateDRPCStatus(ctx, drpc, placementObj, logger)

return ctrl.Result{}, fmt.Errorf("failed to create DRPC instance (%w) and (%v)", err, err2)
}

if errors.Is(err, InitialWaitTimeForDRPCPlacementRule) {
if errors.Is(err, ErrInitialWaitTimeForDRPCPlacementRule) {
const initialWaitTime = 5

r.recordFailure(ctx, drpc, placementObj, "Waiting",
fmt.Sprintf("%v - wait time: %v", InitialWaitTimeForDRPCPlacementRule, initialWaitTime), logger)
fmt.Sprintf("%v - wait time: %v", ErrInitialWaitTimeForDRPCPlacementRule, initialWaitTime), logger)

return ctrl.Result{RequeueAfter: time.Second * initialWaitTime}, nil
}
Expand Down Expand Up @@ -791,7 +791,7 @@ func (r *DRPlacementControlReconciler) getDRPCPlacementRule(ctx context.Context,

// Make sure that we give time to the DRPC PlacementRule to run and produces decisions
if drpcPlRule != nil && len(drpcPlRule.Status.Decisions) == 0 {
return fmt.Errorf("%w", InitialWaitTimeForDRPCPlacementRule)
return ErrInitialWaitTimeForDRPCPlacementRule
}
} else {
log.Info("Preferred cluster is configured. Dynamic selection is disabled",
Expand Down

0 comments on commit e510dc3

Please sign in to comment.