Skip to content

Commit 7bcd6cd

Browse files
Change from fmt.Errorf() to errors.New() for non-constant format string
1 parent 15205f8 commit 7bcd6cd

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ package common_controller
1919
import (
2020
"context"
2121
"crypto/sha256"
22+
"errors"
2223
"fmt"
2324
"time"
2425

2526
v1 "k8s.io/api/core/v1"
26-
"k8s.io/apimachinery/pkg/api/errors"
2727
apierrs "k8s.io/apimachinery/pkg/api/errors"
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/apimachinery/pkg/labels"
@@ -249,7 +249,7 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshot(ctx context.Context
249249

250250
err = ctrl.syncGroupSnapshot(ctx, groupSnapshot)
251251
if err != nil {
252-
if errors.IsConflict(err) {
252+
if apierrs.IsConflict(err) {
253253
// Version conflict error happens quite often and the controller
254254
// recovers from it easily.
255255
klog.V(3).Infof("could not sync group snapshot %q: %+v", utils.GroupSnapshotKey(groupSnapshot), err)
@@ -776,7 +776,7 @@ func (ctrl *csiSnapshotCommonController) getPreprovisionedGroupSnapshotContentFr
776776
klog.V(4).Infof("sync group snapshot[%s]: VolumeGroupSnapshotContent %s is bound to another group snapshot %v", utils.GroupSnapshotKey(groupSnapshot), contentName, ref)
777777
msg := fmt.Sprintf("VolumeGroupSnapshotContent [%s] is bound to a different group snapshot", contentName)
778778
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotContentMisbound", msg)
779-
return nil, fmt.Errorf(msg)
779+
return nil, errors.New(msg)
780780
}
781781
return groupSnapshotContent, nil
782782
}
@@ -968,7 +968,7 @@ func (ctrl *csiSnapshotCommonController) getDynamicallyProvisionedGroupContentFr
968968
klog.V(4).Infof("sync group snapshot[%s]: VolumeGroupSnapshotContent %s is bound to another group snapshot %v", utils.GroupSnapshotKey(groupSnapshot), contentName, ref)
969969
msg := fmt.Sprintf("VolumeGroupSnapshotContent [%s] is bound to a different group snapshot", contentName)
970970
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotContentMisbound", msg)
971-
return nil, fmt.Errorf(msg)
971+
return nil, errors.New(msg)
972972
}
973973
return groupSnapshotContent, nil
974974
}
@@ -1513,7 +1513,7 @@ func (ctrl *csiSnapshotCommonController) processGroupSnapshotWithDeletionTimesta
15131513
utils.GroupSnapshotKey(groupSnapshot), err)
15141514
klog.Error(msg)
15151515
ctrl.eventRecorder.Event(groupSnapshot, v1.EventTypeWarning, "SnapshotDeleteError", msg)
1516-
return fmt.Errorf(msg)
1516+
return errors.New(msg)
15171517
}
15181518
}
15191519

pkg/common-controller/snapshot_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package common_controller
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"slices"
2324
"strings"
@@ -299,7 +300,7 @@ func (ctrl *csiSnapshotCommonController) checkandRemoveSnapshotFinalizersAndChec
299300
msg := fmt.Sprintf("deletion of the individual volume snapshot %s is not allowed as it belongs to group snapshot %s. Deleting the group snapshot will trigger the deletion of all the individual volume snapshots that are part of the group.", utils.SnapshotKey(snapshot), utils.GroupSnapshotKey(groupSnapshot))
300301
klog.Error(msg)
301302
ctrl.eventRecorder.Event(snapshot, v1.EventTypeWarning, "SnapshotDeletePending", msg)
302-
return fmt.Errorf(msg)
303+
return errors.New(msg)
303304
}
304305
if !apierrs.IsNotFound(err) {
305306
klog.Errorf("failed to delete snapshot %s: %v", utils.SnapshotKey(snapshot), err)
@@ -645,7 +646,7 @@ func (ctrl *csiSnapshotCommonController) getPreprovisionedContentFromStore(snaps
645646
klog.V(4).Infof("sync snapshot[%s]: VolumeSnapshotContent %s is bound to another snapshot %v", utils.SnapshotKey(snapshot), contentName, ref)
646647
msg := fmt.Sprintf("VolumeSnapshotContent [%s] is bound to a different snapshot", contentName)
647648
ctrl.updateSnapshotErrorStatusWithEvent(snapshot, true, v1.EventTypeWarning, "SnapshotContentMisbound", msg)
648-
return nil, fmt.Errorf(msg)
649+
return nil, errors.New(msg)
649650
}
650651
return content, nil
651652
}
@@ -691,7 +692,7 @@ func (ctrl *csiSnapshotCommonController) getDynamicallyProvisionedContentFromSto
691692
klog.V(4).Infof("sync snapshot[%s]: VolumeSnapshotContent %s is bound to another snapshot %v", utils.SnapshotKey(snapshot), contentName, ref)
692693
msg := fmt.Sprintf("VolumeSnapshotContent [%s] is bound to a different snapshot", contentName)
693694
ctrl.updateSnapshotErrorStatusWithEvent(snapshot, true, v1.EventTypeWarning, "SnapshotContentMisbound", msg)
694-
return nil, fmt.Errorf(msg)
695+
return nil, errors.New(msg)
695696
}
696697
return content, nil
697698
}

0 commit comments

Comments
 (0)