From 6867e521ba6c9f32f8c981487a52fc0f12ec6428 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Mon, 9 Sep 2024 11:15:30 +0000 Subject: [PATCH] fix: golint errors Signed-off-by: Derek Su --- app/daemon.go | 2 +- app/get_proc_arg.go | 2 +- controller/engine_controller.go | 2 +- controller/kubernetes_pod_controller.go | 2 +- controller/monitor/snapshot_monitor.go | 2 +- controller/node_controller.go | 2 +- controller/system_backup_controller.go | 4 +- controller/system_restore_controller_test.go | 2 +- controller/system_rollout_controller.go | 2 +- csi/controller_server.go | 12 ++-- csi/node_server.go | 30 +++++----- engineapi/backups.go | 2 +- engineapi/engine.go | 4 +- engineapi/enginesim.go | 63 ++++++++++---------- scheduler/replica_scheduler.go | 2 +- types/setting.go | 2 +- 16 files changed, 68 insertions(+), 67 deletions(-) diff --git a/app/daemon.go b/app/daemon.go index beadbe9762..c0289db1de 100644 --- a/app/daemon.go +++ b/app/daemon.go @@ -279,7 +279,7 @@ func startManager(c *cli.Context) error { debugHandler := http.DefaultServeMux logger.Infof("Debug Server listening on %s", debugAddress) if err := http.ListenAndServe(debugAddress, debugHandler); err != nil && !errors.Is(err, http.ErrServerClosed) { - logger.Errorf(fmt.Sprintf("ListenAndServe: %s", err)) + logger.WithError(err).Error("Failed to start debug server") } }() diff --git a/app/get_proc_arg.go b/app/get_proc_arg.go index 94980028d6..2727e0e505 100644 --- a/app/get_proc_arg.go +++ b/app/get_proc_arg.go @@ -218,7 +218,7 @@ func getPodLogAsString(kubeClient *clientset.Clientset, namespace, name string) return "", nil } else if !strings.HasPrefix(strLogs[0], "Proc found") { // unexpected result - return "", fmt.Errorf(string(logs)) + return "", fmt.Errorf("%s", string(logs)) } logrus.Info(strLogs[0]) return strLogs[1], nil diff --git a/controller/engine_controller.go b/controller/engine_controller.go index 1d8c62881b..3cfc0e3690 100644 --- a/controller/engine_controller.go +++ b/controller/engine_controller.go @@ -2092,7 +2092,7 @@ func (ec *EngineController) waitForV2EngineRebuild(e *longhorn.Engine, replicaNa continue } if rebuildingStatus.State == engineapi.ProcessStateError || rebuildingStatus.Error != "" { - return fmt.Errorf(rebuildingStatus.Error) + return errors.New(rebuildingStatus.Error) } if rebuildingStatus.State == engineapi.ProcessStateComplete { return nil diff --git a/controller/kubernetes_pod_controller.go b/controller/kubernetes_pod_controller.go index cc91d5cd96..b9e2ce3d3d 100644 --- a/controller/kubernetes_pod_controller.go +++ b/controller/kubernetes_pod_controller.go @@ -669,7 +669,7 @@ func isCSIPluginPod(obj interface{}) bool { } } - if pod.OwnerReferences != nil && len(pod.OwnerReferences) > 0 { + if len(pod.OwnerReferences) > 0 { for _, ownerRef := range pod.OwnerReferences { if ownerRef.Kind != types.KubernetesKindDaemonSet { continue diff --git a/controller/monitor/snapshot_monitor.go b/controller/monitor/snapshot_monitor.go index 883734ff2e..3be8dd678f 100644 --- a/controller/monitor/snapshot_monitor.go +++ b/controller/monitor/snapshot_monitor.go @@ -463,7 +463,7 @@ func (m *SnapshotMonitor) syncHashStatusFromEngineReplicas(engine *longhorn.Engi } if status.State == string(engineapi.ProcessStateInProgress) { - return fmt.Errorf(string(engineapi.ProcessStateInProgress)) + return errors.New(string(engineapi.ProcessStateInProgress)) } } diff --git a/controller/node_controller.go b/controller/node_controller.go index ff33d3eab1..3b62c4e493 100644 --- a/controller/node_controller.go +++ b/controller/node_controller.go @@ -1728,7 +1728,7 @@ func (nc *NodeController) syncBackingImageEvictionRequested(node *longhorn.Node) logMessage = "Requesting backing image copy eviction" } - backingImageLog.Infof(logMessage) + backingImageLog.Infof("%s", logMessage) if _, err := nc.ds.UpdateBackingImage(backingImageToSync.BackingImage); err != nil { backingImageLog.Warnf("Failed to %s, will enqueue then resync the node", strings.ToLower(logMessage)) nc.enqueueNodeRateLimited(node) diff --git a/controller/system_backup_controller.go b/controller/system_backup_controller.go index 29fe08d9e3..3b6245088f 100644 --- a/controller/system_backup_controller.go +++ b/controller/system_backup_controller.go @@ -814,7 +814,7 @@ func (c *SystemBackupController) WaitForVolumeBackupToComplete(backups map[strin case longhorn.BackupStateCompleted: delete(backups, name) case longhorn.BackupStateError: - return errors.Wrapf(fmt.Errorf(backup.Status.Error), "failed creating Volume backup %v", name) + return errors.Wrapf(fmt.Errorf("%s", backup.Status.Error), "failed creating Volume backup %v", name) } } @@ -926,7 +926,7 @@ func (c *SystemBackupController) WaitForBackingImageBackupToComplete(backupBacki case longhorn.BackupStateCompleted: delete(backupBackingImages, name) case longhorn.BackupStateError: - log.Warnf(errors.Wrapf(fmt.Errorf(backupBackingImage.Status.Error), "Failed to create BackingImage backup %v", name).Error()) + log.Warnf("Failed to create BackingImage backup %v: %v", name, backupBackingImage.Status.Error) return } } diff --git a/controller/system_restore_controller_test.go b/controller/system_restore_controller_test.go index c5ddde1c14..87f233ba02 100644 --- a/controller/system_restore_controller_test.go +++ b/controller/system_restore_controller_test.go @@ -947,7 +947,7 @@ type FakeSystemBackupTargetClient struct { func (c *FakeSystemBackupTargetClient) UploadSystemBackup(name, localFile, longhornVersion, longhornGitCommit, managerImage, engineImage string) (string, error) { switch name { case TestSystemBackupNameUploadFailed, TestSystemRestoreNameUploadFailed: - return "", fmt.Errorf(name) + return "", fmt.Errorf("%v", name) case TestSystemBackupNameUploadExceedTimeout, TestSystemRestoreNameUploadExceedTimeout: time.Sleep(datastore.SystemBackupTimeout * 2) } diff --git a/controller/system_rollout_controller.go b/controller/system_rollout_controller.go index 47f99728bf..9e41c68ac6 100644 --- a/controller/system_rollout_controller.go +++ b/controller/system_rollout_controller.go @@ -346,7 +346,7 @@ func (c *SystemRolloutController) recordErrorState(record *systemRolloutRecord, fmt.Sprintf("%v: %v", record.message, err), ) - log.WithError(fmt.Errorf(err)).Error(record.message) + log.WithError(fmt.Errorf("%v", err)).Error(record.message) c.eventRecorder.Event(systemRestore, corev1.EventTypeWarning, constant.EventReasonFailed, util.CapitalizeFirstLetter(record.message)) c.cacheErrors.Reset() diff --git a/csi/controller_server.go b/csi/controller_server.go index a383d0be75..b58f7fd3e8 100644 --- a/csi/controller_server.go +++ b/csi/controller_server.go @@ -158,7 +158,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol // check size of source and requested srcVolSizeBytes, err := strconv.ParseInt(longhornSrcVol.Size, 10, 64) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if reqVolSizeBytes != srcVolSizeBytes { return nil, status.Errorf(codes.OutOfRange, "failed to clone volume: the requested size (%v bytes) is different than the source volume size (%v bytes)", reqVolSizeBytes, srcVolSizeBytes) @@ -1082,7 +1082,7 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi existVol, err := cs.apiClient.Volume.ById(volumeID) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if existVol == nil { return nil, status.Errorf(codes.NotFound, "volume %s missing", volumeID) @@ -1095,7 +1095,7 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi } existingSize, err := strconv.ParseInt(existVol.Size, 10, 64) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } isOnlineExpansion := existVol.State == string(longhorn.VolumeStateAttached) @@ -1106,9 +1106,9 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi // TODO: This manual error code parsing should be refactored once Longhorn API implements error code response // https://github.com/longhorn/longhorn/issues/1875 if matched, _ := regexp.MatchString("failed to schedule .* more bytes to disk", err.Error()); matched { - return nil, status.Errorf(codes.OutOfRange, err.Error()) + return nil, status.Errorf(codes.OutOfRange, "%v", err) } - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } // kubernetes doesn't support volume shrinking and the csi spec specifies to return true @@ -1135,7 +1135,7 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi volumeSize, err := strconv.ParseInt(existVol.Size, 10, 64) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if !isOnlineExpansion { diff --git a/csi/node_server.go b/csi/node_server.go index c71ae6c0dd..cb9baeeebf 100644 --- a/csi/node_server.go +++ b/csi/node_server.go @@ -182,7 +182,7 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis _, err := os.Stat(devicePath) if err != nil { if !os.IsNotExist(err) { - return nil, status.Errorf(codes.Internal, errors.Wrapf(err, "failed to stat device %s", devicePath).Error()) + return nil, status.Errorf(codes.Internal, "failed to stat device %s: %v", devicePath, err) } } @@ -234,7 +234,7 @@ func (ns *NodeServer) nodeStageSharedVolume(volumeID, shareEndpoint, targetPath isMnt, err := ensureMountPoint(targetPath, mounter) if err != nil { - return status.Errorf(codes.Internal, errors.Wrapf(err, "failed to prepare mount point for shared volume %v", volumeID).Error()) + return status.Errorf(codes.Internal, "failed to prepare mount point for shared volume %v: %v", volumeID, err) } if isMnt { return nil @@ -242,7 +242,7 @@ func (ns *NodeServer) nodeStageSharedVolume(volumeID, shareEndpoint, targetPath uri, err := url.Parse(shareEndpoint) if err != nil { - return status.Errorf(codes.InvalidArgument, errors.Wrapf(err, "invalid share endpoint %v for volume %v", shareEndpoint, volumeID).Error()) + return status.Errorf(codes.InvalidArgument, "invalid share endpoint %v for volume %v: %v", shareEndpoint, volumeID, err) } // share endpoint is of the form nfs://server/export @@ -302,7 +302,7 @@ func (ns *NodeServer) nodeStageMountVolume(volumeID, devicePath, stagingTargetPa isMnt, err := ensureMountPoint(stagingTargetPath, mounter) if err != nil { - return status.Errorf(codes.Internal, errors.Wrapf(err, "failed to prepare mount point %v for volume %v", stagingTargetPath, volumeID).Error()) + return status.Errorf(codes.Internal, "failed to prepare mount point %v for volume %v: %v", stagingTargetPath, volumeID, err) } if isMnt { return nil @@ -327,20 +327,20 @@ func (ns *NodeServer) nodePublishBlockVolume(volumeID, devicePath, targetPath st // we ensure the parent directory exists and is valid if _, err := ensureDirectory(filepath.Dir(targetPath)); err != nil { - return status.Errorf(codes.Internal, errors.Wrapf(err, "failed to prepare mount point for block device %v", devicePath).Error()) + return status.Errorf(codes.Internal, "failed to prepare mount point for block device %v: %v", devicePath, err) } // create file where we can bind mount the device to if err := makeFile(targetPath); err != nil { - return status.Errorf(codes.Internal, errors.Wrapf(err, "failed to create file %v", targetPath).Error()) + return status.Errorf(codes.Internal, "failed to create file %v: %v", targetPath, err) } log.Infof("Bind mounting device %v at %v", devicePath, targetPath) if err := mounter.Mount(devicePath, targetPath, "", []string{"bind"}); err != nil { if removeErr := os.Remove(targetPath); removeErr != nil { - return status.Errorf(codes.Internal, errors.Wrapf(removeErr, "failed to remove mount target %q", targetPath).Error()) + return status.Errorf(codes.Internal, "failed to remove mount target %q: %v", targetPath, removeErr) } - return status.Errorf(codes.Internal, errors.Wrapf(err, "failed to bind mount %q at %q", devicePath, targetPath).Error()) + return status.Errorf(codes.Internal, "failed to bind mount %q at %q: %v", devicePath, targetPath, err) } return nil } @@ -361,7 +361,7 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu } if err := unmountAndCleanupMountPoint(targetPath, mount.New("")); err != nil { - return nil, status.Errorf(codes.Internal, errors.Wrapf(err, "failed to cleanup volume %s mount point %v", volumeID, targetPath).Error()) + return nil, status.Errorf(codes.Internal, "failed to cleanup volume %s mount point %v: %v", volumeID, targetPath, err) } log.Infof("Volume %s unmounted from path %s", volumeID, targetPath) @@ -454,7 +454,7 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol devicePath := volume.Controllers[0].Endpoint diskFormat, err := getDiskFormat(devicePath) if err != nil { - return nil, status.Errorf(codes.Internal, errors.Wrapf(err, "failed to evaluate device filesystem %v format", devicePath).Error()) + return nil, status.Errorf(codes.Internal, "failed to evaluate device filesystem %v format: %v", devicePath, err) } log.Infof("Volume %v device %v contains filesystem of format %v", volumeID, devicePath, diskFormat) @@ -644,13 +644,13 @@ func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVo if errors.Is(err, unix.ENOENT) { return nil, status.Errorf(codes.NotFound, "volume %v is not mounted on path %v", volumeID, volumePath) } - return nil, status.Errorf(codes.Internal, errors.Wrapf(err, "failed to check volume mode for volume path %v", volumePath).Error()) + return nil, status.Errorf(codes.Internal, "failed to check volume mode for volume path %v: %v", volumePath, err) } if isBlockVolume { volCapacity, err := strconv.ParseInt(existVol.Size, 10, 64) if err != nil { - return nil, status.Errorf(codes.Internal, errors.Wrapf(err, "failed to convert volume size %v for volume %v", existVol.Size, volumeID).Error()) + return nil, status.Errorf(codes.Internal, "failed to convert volume size %v for volume %v: %v", existVol.Size, volumeID, err) } return &csi.NodeGetVolumeStatsResponse{ Usage: []*csi.VolumeUsage{ @@ -669,7 +669,7 @@ func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVo if errors.Is(err, unix.ENOENT) { return nil, status.Errorf(codes.NotFound, "volume %v is not mounted on path %v", volumeID, volumePath) } - return nil, status.Errorf(codes.Internal, errors.Wrapf(err, "failed to retrieve capacity statistics for volume path %v for volume %v", volumePath, volumeID).Error()) + return nil, status.Errorf(codes.Internal, "failed to retrieve capacity statistics for volume path %v for volume %v: %v", volumePath, volumeID, err) } return &csi.NodeGetVolumeStatsResponse{ @@ -718,7 +718,7 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV volume, err := ns.apiClient.Volume.ById(volumeID) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if volume == nil { return nil, status.Errorf(codes.NotFound, "volume %s missing", volumeID) @@ -768,7 +768,7 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV // blindly resize the encrypto device if err := crypto.ResizeEncryptoDevice(volumeID, passphrase); err != nil { - return "", status.Errorf(codes.InvalidArgument, errors.Wrapf(err, "failed to resize crypto device %v for volume %v node expansion", devicePath, volumeID).Error()) + return "", status.Errorf(codes.InvalidArgument, "failed to resize crypto device %v for volume %v node expansion: %v", devicePath, volumeID, err) } return devicePath, nil diff --git a/engineapi/backups.go b/engineapi/backups.go index 21ae9132df..9e004f55b6 100644 --- a/engineapi/backups.go +++ b/engineapi/backups.go @@ -475,5 +475,5 @@ func (e *EngineBinary) BackupRestoreStatus(*longhorn.Engine) (map[string]*longho // CleanupBackupMountPoints calls engine binary // TODO: Deprecated, replaced by gRPC proxy, just to match the interface func (e *EngineBinary) CleanupBackupMountPoints() error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } diff --git a/engineapi/engine.go b/engineapi/engine.go index 7769ccf828..eedd19933f 100644 --- a/engineapi/engine.go +++ b/engineapi/engine.go @@ -353,11 +353,11 @@ func (e *EngineBinary) ReplicaModeUpdate(engine *longhorn.Engine, url, mode stri } func (e *EngineBinary) MetricsGet(*longhorn.Engine) (*Metrics, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineBinary) RemountReadOnlyVolume(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } // addFlags always adds required flags to args. In addition, if the engine version is high enough, it adds additional diff --git a/engineapi/enginesim.go b/engineapi/enginesim.go index ddc9114d96..18f6a3f223 100644 --- a/engineapi/enginesim.go +++ b/engineapi/enginesim.go @@ -4,6 +4,7 @@ import ( "fmt" "sync" + "github.com/pkg/errors" "github.com/sirupsen/logrus" etypes "github.com/longhorn/longhorn-engine/pkg/types" @@ -104,11 +105,11 @@ func (e *EngineSimulator) IsGRPC() bool { } func (e *EngineSimulator) Start(*longhorn.InstanceManager, logrus.FieldLogger, *datastore.DataStore) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) Stop(*longhorn.InstanceManager) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) ReplicaList(*longhorn.Engine) (map[string]*Replica, error) { @@ -166,120 +167,120 @@ func (e *EngineSimulator) SimulateStopReplica(addr string) error { func (e *EngineSimulator) SnapshotCreate(engine *longhorn.Engine, name string, labels map[string]string, freezeFilesystem bool) (string, error) { - return "", fmt.Errorf(ErrNotImplement) + return "", errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotList(engine *longhorn.Engine) (map[string]*longhorn.SnapshotInfo, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotGet(engine *longhorn.Engine, name string) (*longhorn.SnapshotInfo, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotDelete(engine *longhorn.Engine, name string) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotRevert(engine *longhorn.Engine, name string) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotPurge(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotPurgeStatus(*longhorn.Engine) (map[string]*longhorn.PurgeStatus, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotBackup(engine *longhorn.Engine, snapshotName, backupName, backupTarget, backingImageName, backingImageChecksum, compressionMethod string, concurrentLimit int, storageClassName string, labels, credential, parameters map[string]string) (string, string, error) { - return "", "", fmt.Errorf(ErrNotImplement) + return "", "", errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotBackupStatus(engine *longhorn.Engine, backupName, replicaAddress, replicaName string) (*longhorn.EngineBackupStatus, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) VersionGet(engine *longhorn.Engine, clientOnly bool) (*EngineVersion, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeGet(*longhorn.Engine) (*Volume, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeExpand(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) BackupRestore(engine *longhorn.Engine, backupTarget, backupName, backupVolume, lastRestored string, credential map[string]string, concurrentLimit int) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotClone(engine *longhorn.Engine, snapshotName, fromEngineAddress, fromVolumeName, fromEngineName string, fileSyncHTTPClientTimeout, grpcTimeoutSeconds int64) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) BackupRestoreStatus(*longhorn.Engine) (map[string]*longhorn.RestoreStatus, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotCloneStatus(*longhorn.Engine) (map[string]*longhorn.SnapshotCloneStatus, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) ReplicaRebuildStatus(*longhorn.Engine) (map[string]*longhorn.RebuildStatus, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeFrontendStart(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeFrontendShutdown(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeUnmapMarkSnapChainRemovedSet(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeSnapshotMaxCountSet(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) VolumeSnapshotMaxSizeSet(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) ReplicaRebuildVerify(engine *longhorn.Engine, replicaName, url string) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotHash(engine *longhorn.Engine, snapshotName string, rehash bool) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) SnapshotHashStatus(engine *longhorn.Engine, snapshotName string) (map[string]*longhorn.HashStatus, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) ReplicaModeUpdate(engine *longhorn.Engine, url, mode string) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) MetricsGet(*longhorn.Engine) (*Metrics, error) { - return nil, fmt.Errorf(ErrNotImplement) + return nil, errors.New(ErrNotImplement) } func (e *EngineSimulator) CleanupBackupMountPoints() error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } func (e *EngineSimulator) RemountReadOnlyVolume(*longhorn.Engine) error { - return fmt.Errorf(ErrNotImplement) + return errors.New(ErrNotImplement) } diff --git a/scheduler/replica_scheduler.go b/scheduler/replica_scheduler.go index 7ad9403377..37241d90c2 100644 --- a/scheduler/replica_scheduler.go +++ b/scheduler/replica_scheduler.go @@ -667,7 +667,7 @@ func (rcs *ReplicaScheduler) RequireNewReplica(replicas map[string]*longhorn.Rep timeUntilNext, timeOfNext, err := rcs.timeToReplacementReplica(volume) if err != nil { msg := "Failed to get time until replica replacement, will directly replenish a new replica" - logrus.WithError(err).Errorf(msg) + logrus.WithError(err).Errorf("%s", msg) } if timeUntilNext > 0 { // Adding another second to the checkBackDuration to avoid clock skew. diff --git a/types/setting.go b/types/setting.go index 01156cf281..223be343b0 100644 --- a/types/setting.go +++ b/types/setting.go @@ -1808,7 +1808,7 @@ func validateString(sName SettingName, definition SettingDefinition, value strin } // multi-choices - if definition.Choices != nil && len(definition.Choices) > 0 { + if len(definition.Choices) > 0 { if !isValidChoice(definition.Choices, value) { return fmt.Errorf("value %v is not a valid choice, available choices %v", value, definition.Choices) }