Skip to content

Commit aaf40ad

Browse files
authored
Merge pull request kubernetes#92461 from Haleygo/001
update static check failed from pkg/volume/rbd
2 parents 3615291 + d6cf8d3 commit aaf40ad

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed

hack/.staticcheck_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pkg/controller/replicaset
55
pkg/controller/resourcequota
66
pkg/volume/azure_dd
77
pkg/volume/gcepd
8-
pkg/volume/rbd
98
pkg/volume/testing
109
test/e2e/autoscaling
1110
test/e2e_node

pkg/volume/rbd/attacher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ var _ volume.DeviceUnmounter = &rbdDetacher{}
207207
// This method is idempotent, callers are responsible for retrying on failure.
208208
func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
209209
if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
210-
return fmt.Errorf("Error checking if path exists: %v", pathErr)
210+
return fmt.Errorf("error checking if path exists: %v", pathErr)
211211
} else if !pathExists {
212212
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
213213
return nil

pkg/volume/rbd/rbd.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"k8s.io/apimachinery/pkg/util/uuid"
3838
clientset "k8s.io/client-go/kubernetes"
3939
"k8s.io/kubernetes/pkg/volume"
40-
"k8s.io/kubernetes/pkg/volume/util"
4140
volutil "k8s.io/kubernetes/pkg/volume/util"
4241
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
4342
)
@@ -199,7 +198,7 @@ func (plugin *rbdPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resource.
199198
}
200199

201200
func (plugin *rbdPlugin) NodeExpand(resizeOptions volume.NodeResizeOptions) (bool, error) {
202-
fsVolume, err := util.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec)
201+
fsVolume, err := volutil.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec)
203202
if err != nil {
204203
return false, fmt.Errorf("error checking VolumeMode: %v", err)
205204
}
@@ -268,11 +267,11 @@ func (plugin *rbdPlugin) createMounterFromVolumeSpecAndPod(spec *volume.Spec, po
268267
// if secret is provideded, retrieve it
269268
kubeClient := plugin.host.GetKubeClient()
270269
if kubeClient == nil {
271-
return nil, fmt.Errorf("Cannot get kube client")
270+
return nil, fmt.Errorf("cannot get kube client")
272271
}
273272
secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
274273
if err != nil {
275-
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err)
274+
err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err)
276275
return nil, err
277276
}
278277
for _, data := range secrets.Data {
@@ -301,11 +300,11 @@ func (plugin *rbdPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, _ volume.Vol
301300
// if secret is provideded, retrieve it
302301
kubeClient := plugin.host.GetKubeClient()
303302
if kubeClient == nil {
304-
return nil, fmt.Errorf("Cannot get kube client")
303+
return nil, fmt.Errorf("cannot get kube client")
305304
}
306305
secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
307306
if err != nil {
308-
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err)
307+
err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err)
309308
return nil, err
310309
}
311310
for _, data := range secrets.Data {
@@ -483,11 +482,11 @@ func (plugin *rbdPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _
483482
// if secret is provideded, retrieve it
484483
kubeClient := plugin.host.GetKubeClient()
485484
if kubeClient == nil {
486-
return nil, fmt.Errorf("Cannot get kube client")
485+
return nil, fmt.Errorf("cannot get kube client")
487486
}
488487
secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
489488
if err != nil {
490-
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err)
489+
err = fmt.Errorf("couldn't get secret %v/%v err: %v", secretNs, secretName, err)
491490
return nil, err
492491
}
493492
for _, data := range secrets.Data {
@@ -862,7 +861,7 @@ func (c *rbdUnmounter) TearDown() error {
862861
func (c *rbdUnmounter) TearDownAt(dir string) error {
863862
klog.V(4).Infof("rbd: attempting to teardown at %s", dir)
864863
if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
865-
return fmt.Errorf("Error checking if path exists: %v", pathErr)
864+
return fmt.Errorf("error checking if path exists: %v", pathErr)
866865
} else if !pathExists {
867866
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
868867
return nil
@@ -996,7 +995,7 @@ func getVolumeSourceMonitors(spec *volume.Spec) ([]string, error) {
996995
return spec.PersistentVolume.Spec.RBD.CephMonitors, nil
997996
}
998997

999-
return nil, fmt.Errorf("Spec does not reference a RBD volume type")
998+
return nil, fmt.Errorf("spec does not reference a RBD volume type")
1000999
}
10011000

10021001
func getVolumeSourceImage(spec *volume.Spec) (string, error) {
@@ -1007,7 +1006,7 @@ func getVolumeSourceImage(spec *volume.Spec) (string, error) {
10071006
return spec.PersistentVolume.Spec.RBD.RBDImage, nil
10081007
}
10091008

1010-
return "", fmt.Errorf("Spec does not reference a RBD volume type")
1009+
return "", fmt.Errorf("spec does not reference a RBD volume type")
10111010
}
10121011

10131012
func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
@@ -1018,7 +1017,7 @@ func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
10181017
return spec.PersistentVolume.Spec.RBD.FSType, nil
10191018
}
10201019

1021-
return "", fmt.Errorf("Spec does not reference a RBD volume type")
1020+
return "", fmt.Errorf("spec does not reference a RBD volume type")
10221021
}
10231022

10241023
func getVolumeSourcePool(spec *volume.Spec) (string, error) {
@@ -1029,7 +1028,7 @@ func getVolumeSourcePool(spec *volume.Spec) (string, error) {
10291028
return spec.PersistentVolume.Spec.RBD.RBDPool, nil
10301029
}
10311030

1032-
return "", fmt.Errorf("Spec does not reference a RBD volume type")
1031+
return "", fmt.Errorf("spec does not reference a RBD volume type")
10331032
}
10341033

10351034
func getVolumeSourceUser(spec *volume.Spec) (string, error) {
@@ -1040,7 +1039,7 @@ func getVolumeSourceUser(spec *volume.Spec) (string, error) {
10401039
return spec.PersistentVolume.Spec.RBD.RadosUser, nil
10411040
}
10421041

1043-
return "", fmt.Errorf("Spec does not reference a RBD volume type")
1042+
return "", fmt.Errorf("spec does not reference a RBD volume type")
10441043
}
10451044

10461045
func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
@@ -1051,7 +1050,7 @@ func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
10511050
return spec.PersistentVolume.Spec.RBD.Keyring, nil
10521051
}
10531052

1054-
return "", fmt.Errorf("Spec does not reference a RBD volume type")
1053+
return "", fmt.Errorf("spec does not reference a RBD volume type")
10551054
}
10561055

10571056
func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
@@ -1064,7 +1063,7 @@ func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
10641063
return spec.ReadOnly, nil
10651064
}
10661065

1067-
return false, fmt.Errorf("Spec does not reference a RBD volume type")
1066+
return false, fmt.Errorf("spec does not reference a RBD volume type")
10681067
}
10691068

10701069
func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, error) {
@@ -1073,7 +1072,7 @@ func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, e
10731072
if spec.PersistentVolume.Spec.RBD != nil {
10741073
return spec.PersistentVolume.Spec.AccessModes, nil
10751074
}
1076-
return nil, fmt.Errorf("Spec does not reference a RBD volume type")
1075+
return nil, fmt.Errorf("spec does not reference a RBD volume type")
10771076
}
10781077

10791078
return nil, nil
@@ -1124,5 +1123,5 @@ func getSecretNameAndNamespace(spec *volume.Spec, defaultNamespace string) (stri
11241123
}
11251124
return "", "", nil
11261125
}
1127-
return "", "", fmt.Errorf("Spec does not reference an RBD volume type")
1126+
return "", "", fmt.Errorf("spec does not reference an RBD volume type")
11281127
}

pkg/volume/rbd/rbd_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func TestGetVolumeSpecFromGlobalMapPath(t *testing.T) {
8686

8787
block := v1.PersistentVolumeBlock
8888
specMode := spec.PersistentVolume.Spec.VolumeMode
89-
if &specMode == nil {
90-
t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", &specMode, block)
89+
if specMode == nil {
90+
t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", specMode, block)
9191
}
9292
if *specMode != block {
9393
t.Errorf("Invalid volumeMode from GlobalMapPath spec: %v - %v", *specMode, block)

pkg/volume/rbd/rbd_util.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ func (util *rbdUtil) AttachDisk(b rbdMounter) (string, error) {
373373

374374
globalPDPath := util.MakeGlobalPDName(*b.rbd)
375375
if pathExists, pathErr := mount.PathExists(globalPDPath); pathErr != nil {
376-
return "", fmt.Errorf("Error checking if path exists: %v", pathErr)
376+
return "", fmt.Errorf("error checking if path exists: %v", pathErr)
377377
} else if !pathExists {
378378
if err := os.MkdirAll(globalPDPath, 0750); err != nil {
379379
return "", err
@@ -459,7 +459,7 @@ func (util *rbdUtil) AttachDisk(b rbdMounter) (string, error) {
459459
devicePath, mapped = waitForPath(b.Pool, b.Image, 10 /*maxRetries*/, false /*useNbdDriver*/)
460460
}
461461
if !mapped {
462-
return "", fmt.Errorf("Could not map image %s/%s, Timeout after 10s", b.Pool, b.Image)
462+
return "", fmt.Errorf("could not map image %s/%s, Timeout after 10s", b.Pool, b.Image)
463463
}
464464
}
465465
return devicePath, nil
@@ -515,7 +515,7 @@ func (util *rbdUtil) DetachDisk(plugin *rbdPlugin, deviceMountPath string, devic
515515
func (util *rbdUtil) DetachBlockDisk(disk rbdDiskUnmapper, mapPath string) error {
516516

517517
if pathExists, pathErr := mount.PathExists(mapPath); pathErr != nil {
518-
return fmt.Errorf("Error checking if path exists: %v", pathErr)
518+
return fmt.Errorf("error checking if path exists: %v", pathErr)
519519
} else if !pathExists {
520520
klog.Warningf("Warning: Unmap skipped because path does not exist: %v", mapPath)
521521
return nil
@@ -803,7 +803,7 @@ func (util *rbdUtil) rbdStatus(b *rbdMounter) (bool, string, error) {
803803
func getRbdImageInfo(deviceMountPath string) (*rbdImageInfo, error) {
804804
deviceMountedPathSeps := strings.Split(filepath.Base(deviceMountPath), "-image-")
805805
if len(deviceMountedPathSeps) != 2 {
806-
return nil, fmt.Errorf("Can't found devicePath for %s ", deviceMountPath)
806+
return nil, fmt.Errorf("can't found devicePath for %s ", deviceMountPath)
807807
}
808808
return &rbdImageInfo{
809809
pool: deviceMountedPathSeps[0],

0 commit comments

Comments
 (0)