Skip to content

Commit 2590f6c

Browse files
authored
Merge pull request kubernetes#89435 from humblec/correct
Clean some code paths and correct static errors
2 parents 9f7aaf4 + 31b837b commit 2590f6c

File tree

8 files changed

+43
-42
lines changed

8 files changed

+43
-42
lines changed

pkg/volume/azure_dd/attacher.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ func (a *azureDiskAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error
202202
return makeGlobalPDPath(a.plugin.host, volumeSource.DataDiskURI, isManagedDisk)
203203
}
204204

205-
func (attacher *azureDiskAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string) error {
206-
mounter := attacher.plugin.host.GetMounter(azureDataDiskPluginName)
205+
func (a *azureDiskAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string) error {
206+
mounter := a.plugin.host.GetMounter(azureDataDiskPluginName)
207207
notMnt, err := mounter.IsLikelyNotMountPoint(deviceMountPath)
208208

209209
if err != nil {
@@ -242,7 +242,7 @@ func (attacher *azureDiskAttacher) MountDevice(spec *volume.Spec, devicePath str
242242

243243
options := []string{}
244244
if notMnt {
245-
diskMounter := util.NewSafeFormatAndMountFromHost(azureDataDiskPluginName, attacher.plugin.host)
245+
diskMounter := util.NewSafeFormatAndMountFromHost(azureDataDiskPluginName, a.plugin.host)
246246
mountOptions := util.MountOptionFromSpec(spec, options...)
247247
if runtime.GOOS == "windows" {
248248
// only parse devicePath on Windows node
@@ -284,8 +284,8 @@ func (d *azureDiskDetacher) Detach(diskURI string, nodeName types.NodeName) erro
284284
}
285285

286286
// UnmountDevice unmounts the volume on the node
287-
func (detacher *azureDiskDetacher) UnmountDevice(deviceMountPath string) error {
288-
err := mount.CleanupMountPoint(deviceMountPath, detacher.plugin.host.GetMounter(detacher.plugin.GetPluginName()), false)
287+
func (d *azureDiskDetacher) UnmountDevice(deviceMountPath string) error {
288+
err := mount.CleanupMountPoint(deviceMountPath, d.plugin.host.GetMounter(d.plugin.GetPluginName()), false)
289289
if err == nil {
290290
klog.V(2).Infof("azureDisk - Device %s was unmounted", deviceMountPath)
291291
} else {

pkg/volume/azure_dd/azure_common.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
7373
}
7474

7575
// creates a unique path for disks (even if they share the same *.vhd name)
76-
func makeGlobalPDPath(host volume.VolumeHost, diskUri string, isManaged bool) (string, error) {
77-
diskUri = libstrings.ToLower(diskUri) // always lower uri because users may enter it in caps.
76+
func makeGlobalPDPath(host volume.VolumeHost, diskURI string, isManaged bool) (string, error) {
77+
diskURI = libstrings.ToLower(diskURI) // always lower uri because users may enter it in caps.
7878
uniqueDiskNameTemplate := "%s%s"
79-
hashedDiskUri := azure.MakeCRC32(diskUri)
79+
hashedDiskURI := azure.MakeCRC32(diskURI)
8080
prefix := "b"
8181
if isManaged {
8282
prefix = "m"
8383
}
84-
// "{m for managed b for blob}{hashed diskUri or DiskId depending on disk kind }"
85-
diskName := fmt.Sprintf(uniqueDiskNameTemplate, prefix, hashedDiskUri)
84+
// "{m for managed b for blob}{hashed diskURI or DiskId depending on disk kind }"
85+
diskName := fmt.Sprintf(uniqueDiskNameTemplate, prefix, hashedDiskURI)
8686
pdPath := filepath.Join(host.GetPluginDir(azureDataDiskPluginName), util.MountsInGlobalPDPath, diskName)
8787

8888
return pdPath, nil

pkg/volume/azure_dd/azure_common_linux.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ func getDiskLinkByDevName(io ioHandler, devLinkPath, devName string) (string, er
7373
}
7474

7575
func scsiHostRescan(io ioHandler, exec utilexec.Interface) {
76-
scsi_path := "/sys/class/scsi_host/"
77-
if dirs, err := io.ReadDir(scsi_path); err == nil {
76+
scsiPath := "/sys/class/scsi_host/"
77+
if dirs, err := io.ReadDir(scsiPath); err == nil {
7878
for _, f := range dirs {
79-
name := scsi_path + f.Name() + "/scan"
79+
name := scsiPath + f.Name() + "/scan"
8080
data := []byte("- - -")
8181
if err = io.WriteFile(name, data, 0666); err != nil {
8282
klog.Warningf("failed to rescan scsi host %s", name)
8383
}
8484
}
8585
} else {
86-
klog.Warningf("failed to read %s, err %v", scsi_path, err)
86+
klog.Warningf("failed to read %s, err %v", scsiPath, err)
8787
}
8888
}
8989

@@ -95,8 +95,8 @@ func findDiskByLun(lun int, io ioHandler, exec utilexec.Interface) (string, erro
9595
// finds a device mounted to "current" node
9696
func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (string, error) {
9797
var err error
98-
sys_path := "/sys/bus/scsi/devices"
99-
if dirs, err := io.ReadDir(sys_path); err == nil {
98+
sysPath := "/sys/bus/scsi/devices"
99+
if dirs, err := io.ReadDir(sysPath); err == nil {
100100
for _, f := range dirs {
101101
name := f.Name()
102102
// look for path like /sys/bus/scsi/devices/3:0:0:1
@@ -128,7 +128,7 @@ func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (st
128128
if lun == l {
129129
// find the matching LUN
130130
// read vendor and model to ensure it is a VHD disk
131-
vendorPath := filepath.Join(sys_path, name, "vendor")
131+
vendorPath := filepath.Join(sysPath, name, "vendor")
132132
vendorBytes, err := io.ReadFile(vendorPath)
133133
if err != nil {
134134
klog.Errorf("failed to read device vendor, err: %v", err)
@@ -140,7 +140,7 @@ func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (st
140140
continue
141141
}
142142

143-
modelPath := filepath.Join(sys_path, name, "model")
143+
modelPath := filepath.Join(sysPath, name, "model")
144144
modelBytes, err := io.ReadFile(modelPath)
145145
if err != nil {
146146
klog.Errorf("failed to read device model, err: %v", err)
@@ -153,7 +153,7 @@ func findDiskByLunWithConstraint(lun int, io ioHandler, azureDisks []string) (st
153153
}
154154

155155
// find a disk, validate name
156-
dir := filepath.Join(sys_path, name, "block")
156+
dir := filepath.Join(sysPath, name, "block")
157157
if dev, err := io.ReadDir(dir); err == nil {
158158
found := false
159159
devName := dev[0].Name()

pkg/volume/azure_dd/azure_dd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"k8s.io/legacy-cloud-providers/azure"
3737
)
3838

39-
// interface exposed by the cloud provider implementing Disk functionality
39+
// DiskController interface exposed by the cloud provider implementing Disk functionality
4040
type DiskController interface {
4141
CreateBlobDisk(dataDiskName string, storageAccountType storage.SkuName, sizeGB int) (string, error)
4242
DeleteBlobDisk(diskUri string) error

pkg/volume/csi/fake/fake_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import (
3131
)
3232

3333
const (
34-
// NodePublishTimeout_VolumeID is volume id that will result in NodePublish operation to timeout
34+
// NodePublishTimeOut_VolumeID is volume id that will result in NodePublish operation to timeout
3535
NodePublishTimeOut_VolumeID = "node-publish-timeout"
36+
3637
// NodeStageTimeOut_VolumeID is a volume id that will result in NodeStage operation to timeout
3738
NodeStageTimeOut_VolumeID = "node-stage-timeout"
3839
)

pkg/volume/git_repo/git_repo_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type expectedCommand struct {
7070
}
7171

7272
func TestPlugin(t *testing.T) {
73-
gitUrl := "https://github.com/kubernetes/kubernetes.git"
73+
gitURL := "https://github.com/kubernetes/kubernetes.git"
7474
revision := "2a30ce65c5ab586b98916d83385c5983edd353a1"
7575

7676
scenarios := []struct {
@@ -85,15 +85,15 @@ func TestPlugin(t *testing.T) {
8585
Name: "vol1",
8686
VolumeSource: v1.VolumeSource{
8787
GitRepo: &v1.GitRepoVolumeSource{
88-
Repository: gitUrl,
88+
Repository: gitURL,
8989
Revision: revision,
9090
Directory: "target_dir",
9191
},
9292
},
9393
},
9494
expecteds: []expectedCommand{
9595
{
96-
cmd: []string{"git", "clone", "--", gitUrl, "target_dir"},
96+
cmd: []string{"git", "clone", "--", gitURL, "target_dir"},
9797
dir: "",
9898
},
9999
{
@@ -113,14 +113,14 @@ func TestPlugin(t *testing.T) {
113113
Name: "vol1",
114114
VolumeSource: v1.VolumeSource{
115115
GitRepo: &v1.GitRepoVolumeSource{
116-
Repository: gitUrl,
116+
Repository: gitURL,
117117
Directory: "target_dir",
118118
},
119119
},
120120
},
121121
expecteds: []expectedCommand{
122122
{
123-
cmd: []string{"git", "clone", "--", gitUrl, "target_dir"},
123+
cmd: []string{"git", "clone", "--", gitURL, "target_dir"},
124124
dir: "",
125125
},
126126
},
@@ -132,13 +132,13 @@ func TestPlugin(t *testing.T) {
132132
Name: "vol1",
133133
VolumeSource: v1.VolumeSource{
134134
GitRepo: &v1.GitRepoVolumeSource{
135-
Repository: gitUrl,
135+
Repository: gitURL,
136136
},
137137
},
138138
},
139139
expecteds: []expectedCommand{
140140
{
141-
cmd: []string{"git", "clone", "--", gitUrl},
141+
cmd: []string{"git", "clone", "--", gitURL},
142142
dir: "",
143143
},
144144
},
@@ -150,15 +150,15 @@ func TestPlugin(t *testing.T) {
150150
Name: "vol1",
151151
VolumeSource: v1.VolumeSource{
152152
GitRepo: &v1.GitRepoVolumeSource{
153-
Repository: gitUrl,
153+
Repository: gitURL,
154154
Revision: revision,
155155
Directory: "",
156156
},
157157
},
158158
},
159159
expecteds: []expectedCommand{
160160
{
161-
cmd: []string{"git", "clone", "--", gitUrl},
161+
cmd: []string{"git", "clone", "--", gitURL},
162162
dir: "",
163163
},
164164
{
@@ -178,15 +178,15 @@ func TestPlugin(t *testing.T) {
178178
Name: "vol1",
179179
VolumeSource: v1.VolumeSource{
180180
GitRepo: &v1.GitRepoVolumeSource{
181-
Repository: gitUrl,
181+
Repository: gitURL,
182182
Revision: revision,
183183
Directory: ".",
184184
},
185185
},
186186
},
187187
expecteds: []expectedCommand{
188188
{
189-
cmd: []string{"git", "clone", "--", gitUrl, "."},
189+
cmd: []string{"git", "clone", "--", gitURL, "."},
190190
dir: "",
191191
},
192192
{
@@ -206,15 +206,15 @@ func TestPlugin(t *testing.T) {
206206
Name: "vol1",
207207
VolumeSource: v1.VolumeSource{
208208
GitRepo: &v1.GitRepoVolumeSource{
209-
Repository: gitUrl,
209+
Repository: gitURL,
210210
Revision: revision,
211211
Directory: "./.",
212212
},
213213
},
214214
},
215215
expecteds: []expectedCommand{
216216
{
217-
cmd: []string{"git", "clone", "--", gitUrl, "./."},
217+
cmd: []string{"git", "clone", "--", gitURL, "./."},
218218
dir: "",
219219
},
220220
{
@@ -246,7 +246,7 @@ func TestPlugin(t *testing.T) {
246246
Name: "vol1",
247247
VolumeSource: v1.VolumeSource{
248248
GitRepo: &v1.GitRepoVolumeSource{
249-
Repository: gitUrl,
249+
Repository: gitURL,
250250
Revision: "--bar",
251251
},
252252
},
@@ -259,7 +259,7 @@ func TestPlugin(t *testing.T) {
259259
Name: "vol1",
260260
VolumeSource: v1.VolumeSource{
261261
GitRepo: &v1.GitRepoVolumeSource{
262-
Repository: gitUrl,
262+
Repository: gitURL,
263263
Directory: "-b",
264264
},
265265
},
@@ -330,11 +330,11 @@ func doTestPlugin(scenario struct {
330330
allErrs = append(allErrs,
331331
fmt.Errorf("SetUp() failed, volume path not created: %s", path))
332332
return allErrs
333-
} else {
334-
allErrs = append(allErrs,
335-
fmt.Errorf("SetUp() failed: %v", err))
336-
return allErrs
337333
}
334+
allErrs = append(allErrs,
335+
fmt.Errorf("SetUp() failed: %v", err))
336+
return allErrs
337+
338338
}
339339

340340
// gitRepo volume should create its own empty wrapper path

pkg/volume/iscsi/iscsi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
3939
)
4040

41-
// This is the primary entrypoint for volume plugins.
41+
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
4242
func ProbeVolumePlugins() []volume.VolumePlugin {
4343
return []volume.VolumePlugin{&iscsiPlugin{}}
4444
}

pkg/volume/util/fs/fs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"k8s.io/kubernetes/pkg/volume/util/fsquota"
3131
)
3232

33-
// FSInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
33+
// FsInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
3434
// for the filesystem that path resides upon.
3535
func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
3636
statfs := &unix.Statfs_t{}

0 commit comments

Comments
 (0)