diff --git a/hack/.staticcheck_failures b/hack/.staticcheck_failures index e0eae6102a8..94549364320 100644 --- a/hack/.staticcheck_failures +++ b/hack/.staticcheck_failures @@ -5,7 +5,6 @@ pkg/controller/replicaset pkg/controller/resourcequota pkg/volume/azure_dd pkg/volume/gcepd -pkg/volume/rbd pkg/volume/testing test/e2e/autoscaling test/e2e_node diff --git a/pkg/volume/rbd/attacher.go b/pkg/volume/rbd/attacher.go index 20de5472022..3ed3f683bfb 100644 --- a/pkg/volume/rbd/attacher.go +++ b/pkg/volume/rbd/attacher.go @@ -207,7 +207,7 @@ var _ volume.DeviceUnmounter = &rbdDetacher{} // This method is idempotent, callers are responsible for retrying on failure. func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error { if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil { - return fmt.Errorf("Error checking if path exists: %v", pathErr) + return fmt.Errorf("error checking if path exists: %v", pathErr) } else if !pathExists { klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath) return nil diff --git a/pkg/volume/rbd/rbd.go b/pkg/volume/rbd/rbd.go index 5702f9d5b2d..2de06c714fd 100644 --- a/pkg/volume/rbd/rbd.go +++ b/pkg/volume/rbd/rbd.go @@ -37,7 +37,6 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" clientset "k8s.io/client-go/kubernetes" "k8s.io/kubernetes/pkg/volume" - "k8s.io/kubernetes/pkg/volume/util" volutil "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/pkg/volume/util/volumepathhandler" ) @@ -199,7 +198,7 @@ func (plugin *rbdPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resource. } func (plugin *rbdPlugin) NodeExpand(resizeOptions volume.NodeResizeOptions) (bool, error) { - fsVolume, err := util.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec) + fsVolume, err := volutil.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec) if err != nil { return false, fmt.Errorf("error checking VolumeMode: %v", err) } @@ -268,11 +267,11 @@ func (plugin *rbdPlugin) createMounterFromVolumeSpecAndPod(spec *volume.Spec, po // if secret is provideded, retrieve it kubeClient := plugin.host.GetKubeClient() if kubeClient == nil { - return nil, fmt.Errorf("Cannot get kube client") + return nil, fmt.Errorf("cannot get kube client") } secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{}) if err != nil { - err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err) + err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err) return nil, err } for _, data := range secrets.Data { @@ -301,11 +300,11 @@ func (plugin *rbdPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, _ volume.Vol // if secret is provideded, retrieve it kubeClient := plugin.host.GetKubeClient() if kubeClient == nil { - return nil, fmt.Errorf("Cannot get kube client") + return nil, fmt.Errorf("cannot get kube client") } secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{}) if err != nil { - err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err) + err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err) return nil, err } for _, data := range secrets.Data { @@ -483,11 +482,11 @@ func (plugin *rbdPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _ // if secret is provideded, retrieve it kubeClient := plugin.host.GetKubeClient() if kubeClient == nil { - return nil, fmt.Errorf("Cannot get kube client") + return nil, fmt.Errorf("cannot get kube client") } secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{}) if err != nil { - err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err) + err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err) return nil, err } for _, data := range secrets.Data { @@ -862,7 +861,7 @@ func (c *rbdUnmounter) TearDown() error { func (c *rbdUnmounter) TearDownAt(dir string) error { klog.V(4).Infof("rbd: attempting to teardown at %s", dir) if pathExists, pathErr := mount.PathExists(dir); pathErr != nil { - return fmt.Errorf("Error checking if path exists: %v", pathErr) + return fmt.Errorf("error checking if path exists: %v", pathErr) } else if !pathExists { klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) return nil @@ -996,7 +995,7 @@ func getVolumeSourceMonitors(spec *volume.Spec) ([]string, error) { return spec.PersistentVolume.Spec.RBD.CephMonitors, nil } - return nil, fmt.Errorf("Spec does not reference a RBD volume type") + return nil, fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeSourceImage(spec *volume.Spec) (string, error) { @@ -1007,7 +1006,7 @@ func getVolumeSourceImage(spec *volume.Spec) (string, error) { return spec.PersistentVolume.Spec.RBD.RBDImage, nil } - return "", fmt.Errorf("Spec does not reference a RBD volume type") + return "", fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeSourceFSType(spec *volume.Spec) (string, error) { @@ -1018,7 +1017,7 @@ func getVolumeSourceFSType(spec *volume.Spec) (string, error) { return spec.PersistentVolume.Spec.RBD.FSType, nil } - return "", fmt.Errorf("Spec does not reference a RBD volume type") + return "", fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeSourcePool(spec *volume.Spec) (string, error) { @@ -1029,7 +1028,7 @@ func getVolumeSourcePool(spec *volume.Spec) (string, error) { return spec.PersistentVolume.Spec.RBD.RBDPool, nil } - return "", fmt.Errorf("Spec does not reference a RBD volume type") + return "", fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeSourceUser(spec *volume.Spec) (string, error) { @@ -1040,7 +1039,7 @@ func getVolumeSourceUser(spec *volume.Spec) (string, error) { return spec.PersistentVolume.Spec.RBD.RadosUser, nil } - return "", fmt.Errorf("Spec does not reference a RBD volume type") + return "", fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) { @@ -1051,7 +1050,7 @@ func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) { return spec.PersistentVolume.Spec.RBD.Keyring, nil } - return "", fmt.Errorf("Spec does not reference a RBD volume type") + return "", fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) { @@ -1064,7 +1063,7 @@ func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) { return spec.ReadOnly, nil } - return false, fmt.Errorf("Spec does not reference a RBD volume type") + return false, fmt.Errorf("spec does not reference a RBD volume type") } func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, error) { @@ -1073,7 +1072,7 @@ func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, e if spec.PersistentVolume.Spec.RBD != nil { return spec.PersistentVolume.Spec.AccessModes, nil } - return nil, fmt.Errorf("Spec does not reference a RBD volume type") + return nil, fmt.Errorf("spec does not reference a RBD volume type") } return nil, nil @@ -1124,5 +1123,5 @@ func getSecretNameAndNamespace(spec *volume.Spec, defaultNamespace string) (stri } return "", "", nil } - return "", "", fmt.Errorf("Spec does not reference an RBD volume type") + return "", "", fmt.Errorf("spec does not reference an RBD volume type") } diff --git a/pkg/volume/rbd/rbd_test.go b/pkg/volume/rbd/rbd_test.go index 24ae634751c..de025284f17 100644 --- a/pkg/volume/rbd/rbd_test.go +++ b/pkg/volume/rbd/rbd_test.go @@ -86,8 +86,8 @@ func TestGetVolumeSpecFromGlobalMapPath(t *testing.T) { block := v1.PersistentVolumeBlock specMode := spec.PersistentVolume.Spec.VolumeMode - if &specMode == nil { - t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", &specMode, block) + if specMode == nil { + t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", specMode, block) } if *specMode != block { t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", *specMode, block) diff --git a/pkg/volume/rbd/rbd_util.go b/pkg/volume/rbd/rbd_util.go index 1db829b5095..4c001cb704b 100644 --- a/pkg/volume/rbd/rbd_util.go +++ b/pkg/volume/rbd/rbd_util.go @@ -373,7 +373,7 @@ func (util *rbdUtil) AttachDisk(b rbdMounter) (string, error) { globalPDPath := util.MakeGlobalPDName(*b.rbd) if pathExists, pathErr := mount.PathExists(globalPDPath); pathErr != nil { - return "", fmt.Errorf("Error checking if path exists: %v", pathErr) + return "", fmt.Errorf("error checking if path exists: %v", pathErr) } else if !pathExists { if err := os.MkdirAll(globalPDPath, 0750); err != nil { return "", err @@ -459,7 +459,7 @@ func (util *rbdUtil) AttachDisk(b rbdMounter) (string, error) { devicePath, mapped = waitForPath(b.Pool, b.Image, 10 /*maxRetries*/, false /*useNbdDriver*/) } if !mapped { - return "", fmt.Errorf("Could not map image %s/%s, Timeout after 10s", b.Pool, b.Image) + return "", fmt.Errorf("could not map image %s/%s, Timeout after 10s", b.Pool, b.Image) } } return devicePath, nil @@ -515,7 +515,7 @@ func (util *rbdUtil) DetachDisk(plugin *rbdPlugin, deviceMountPath string, devic func (util *rbdUtil) DetachBlockDisk(disk rbdDiskUnmapper, mapPath string) error { if pathExists, pathErr := mount.PathExists(mapPath); pathErr != nil { - return fmt.Errorf("Error checking if path exists: %v", pathErr) + return fmt.Errorf("error checking if path exists: %v", pathErr) } else if !pathExists { klog.Warningf("Warning: Unmap skipped because path does not exist: %v", mapPath) return nil @@ -803,7 +803,7 @@ func (util *rbdUtil) rbdStatus(b *rbdMounter) (bool, string, error) { func getRbdImageInfo(deviceMountPath string) (*rbdImageInfo, error) { deviceMountedPathSeps := strings.Split(filepath.Base(deviceMountPath), "-image-") if len(deviceMountedPathSeps) != 2 { - return nil, fmt.Errorf("Can't found devicePath for %s ", deviceMountPath) + return nil, fmt.Errorf("can't found devicePath for %s ", deviceMountPath) } return &rbdImageInfo{ pool: deviceMountedPathSeps[0],