Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
296ea67c
Unverified
Commit
296ea67c
authored
Oct 14, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69556 from leakingtapan/golint-fix-volume-fc-flock
Fix golint issues for pkg/volume/{fc,flocker} packages
parents
3478e944
065e4543
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
68 deletions
+64
-68
.golint_failures
hack/.golint_failures
+0
-2
attacher.go
pkg/volume/fc/attacher.go
+2
-2
fc.go
pkg/volume/fc/fc.go
+5
-5
fc_test.go
pkg/volume/fc/fc_test.go
+4
-4
fc_util.go
pkg/volume/fc/fc_util.go
+30
-32
flocker.go
pkg/volume/flocker/flocker.go
+17
-17
flocker_util.go
pkg/volume/flocker/flocker_util.go
+3
-3
flocker_util_test.go
pkg/volume/flocker/flocker_util_test.go
+1
-1
flocker_volume.go
pkg/volume/flocker/flocker_volume.go
+2
-2
No files found.
hack/.golint_failures
View file @
296ea67c
...
@@ -411,8 +411,6 @@ pkg/volume/cephfs
...
@@ -411,8 +411,6 @@ pkg/volume/cephfs
pkg/volume/configmap
pkg/volume/configmap
pkg/volume/csi/fake
pkg/volume/csi/fake
pkg/volume/empty_dir
pkg/volume/empty_dir
pkg/volume/fc
pkg/volume/flocker
pkg/volume/git_repo
pkg/volume/git_repo
pkg/volume/host_path
pkg/volume/host_path
pkg/volume/iscsi
pkg/volume/iscsi
...
...
pkg/volume/fc/attacher.go
View file @
296ea67c
...
@@ -49,7 +49,7 @@ var _ volume.DeviceMountableVolumePlugin = &fcPlugin{}
...
@@ -49,7 +49,7 @@ var _ volume.DeviceMountableVolumePlugin = &fcPlugin{}
func
(
plugin
*
fcPlugin
)
NewAttacher
()
(
volume
.
Attacher
,
error
)
{
func
(
plugin
*
fcPlugin
)
NewAttacher
()
(
volume
.
Attacher
,
error
)
{
return
&
fcAttacher
{
return
&
fcAttacher
{
host
:
plugin
.
host
,
host
:
plugin
.
host
,
manager
:
&
FC
Util
{},
manager
:
&
fc
Util
{},
},
nil
},
nil
}
}
...
@@ -142,7 +142,7 @@ var _ volume.DeviceUnmounter = &fcDetacher{}
...
@@ -142,7 +142,7 @@ var _ volume.DeviceUnmounter = &fcDetacher{}
func
(
plugin
*
fcPlugin
)
NewDetacher
()
(
volume
.
Detacher
,
error
)
{
func
(
plugin
*
fcPlugin
)
NewDetacher
()
(
volume
.
Detacher
,
error
)
{
return
&
fcDetacher
{
return
&
fcDetacher
{
mounter
:
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
mounter
:
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
manager
:
&
FC
Util
{},
manager
:
&
fc
Util
{},
},
nil
},
nil
}
}
...
...
pkg/volume/fc/fc.go
View file @
296ea67c
...
@@ -35,7 +35,7 @@ import (
...
@@ -35,7 +35,7 @@ import (
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
)
//
Thi
s is the primary entrypoint for volume plugins.
//
ProbeVolumePlugin
s is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
fcPlugin
{
nil
}}
return
[]
volume
.
VolumePlugin
{
&
fcPlugin
{
nil
}}
}
}
...
@@ -106,7 +106,7 @@ func (plugin *fcPlugin) GetAccessModes() []v1.PersistentVolumeAccessMode {
...
@@ -106,7 +106,7 @@ func (plugin *fcPlugin) GetAccessModes() []v1.PersistentVolumeAccessMode {
func
(
plugin
*
fcPlugin
)
NewMounter
(
spec
*
volume
.
Spec
,
pod
*
v1
.
Pod
,
_
volume
.
VolumeOptions
)
(
volume
.
Mounter
,
error
)
{
func
(
plugin
*
fcPlugin
)
NewMounter
(
spec
*
volume
.
Spec
,
pod
*
v1
.
Pod
,
_
volume
.
VolumeOptions
)
(
volume
.
Mounter
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
plugin
.
newMounterInternal
(
spec
,
pod
.
UID
,
&
FC
Util
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
()))
return
plugin
.
newMounterInternal
(
spec
,
pod
.
UID
,
&
fc
Util
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
()))
}
}
func
(
plugin
*
fcPlugin
)
newMounterInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
,
exec
mount
.
Exec
)
(
volume
.
Mounter
,
error
)
{
func
(
plugin
*
fcPlugin
)
newMounterInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
,
exec
mount
.
Exec
)
(
volume
.
Mounter
,
error
)
{
...
@@ -166,7 +166,7 @@ func (plugin *fcPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _ v
...
@@ -166,7 +166,7 @@ func (plugin *fcPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _ v
if
pod
!=
nil
{
if
pod
!=
nil
{
uid
=
pod
.
UID
uid
=
pod
.
UID
}
}
return
plugin
.
newBlockVolumeMapperInternal
(
spec
,
uid
,
&
FC
Util
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
()))
return
plugin
.
newBlockVolumeMapperInternal
(
spec
,
uid
,
&
fc
Util
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
()))
}
}
func
(
plugin
*
fcPlugin
)
newBlockVolumeMapperInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
,
exec
mount
.
Exec
)
(
volume
.
BlockVolumeMapper
,
error
)
{
func
(
plugin
*
fcPlugin
)
newBlockVolumeMapperInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
,
exec
mount
.
Exec
)
(
volume
.
BlockVolumeMapper
,
error
)
{
...
@@ -198,7 +198,7 @@ func (plugin *fcPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID t
...
@@ -198,7 +198,7 @@ func (plugin *fcPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID t
func
(
plugin
*
fcPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
func
(
plugin
*
fcPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
plugin
.
newUnmounterInternal
(
volName
,
podUID
,
&
FC
Util
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
return
plugin
.
newUnmounterInternal
(
volName
,
podUID
,
&
fc
Util
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
}
}
func
(
plugin
*
fcPlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
func
(
plugin
*
fcPlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
...
@@ -216,7 +216,7 @@ func (plugin *fcPlugin) newUnmounterInternal(volName string, podUID types.UID, m
...
@@ -216,7 +216,7 @@ func (plugin *fcPlugin) newUnmounterInternal(volName string, podUID types.UID, m
}
}
func
(
plugin
*
fcPlugin
)
NewBlockVolumeUnmapper
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
BlockVolumeUnmapper
,
error
)
{
func
(
plugin
*
fcPlugin
)
NewBlockVolumeUnmapper
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
BlockVolumeUnmapper
,
error
)
{
return
plugin
.
newUnmapperInternal
(
volName
,
podUID
,
&
FC
Util
{})
return
plugin
.
newUnmapperInternal
(
volName
,
podUID
,
&
fc
Util
{})
}
}
func
(
plugin
*
fcPlugin
)
newUnmapperInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
)
(
volume
.
BlockVolumeUnmapper
,
error
)
{
func
(
plugin
*
fcPlugin
)
newUnmapperInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
)
(
volume
.
BlockVolumeUnmapper
,
error
)
{
...
...
pkg/volume/fc/fc_test.go
View file @
296ea67c
...
@@ -96,7 +96,7 @@ type fakeDiskManager struct {
...
@@ -96,7 +96,7 @@ type fakeDiskManager struct {
detachCalled
bool
detachCalled
bool
}
}
func
N
ewFakeDiskManager
()
*
fakeDiskManager
{
func
n
ewFakeDiskManager
()
*
fakeDiskManager
{
return
&
fakeDiskManager
{
return
&
fakeDiskManager
{
tmpDir
:
utiltesting
.
MkTmpdirOrDie
(
"fc_test"
),
tmpDir
:
utiltesting
.
MkTmpdirOrDie
(
"fc_test"
),
}
}
...
@@ -161,7 +161,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
...
@@ -161,7 +161,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
t
.
Errorf
(
"Can't find the plugin by name"
)
}
}
fakeManager
:=
N
ewFakeDiskManager
()
fakeManager
:=
n
ewFakeDiskManager
()
defer
fakeManager
.
Cleanup
()
defer
fakeManager
.
Cleanup
()
fakeMounter
:=
&
mount
.
FakeMounter
{}
fakeMounter
:=
&
mount
.
FakeMounter
{}
fakeExec
:=
mount
.
NewFakeExec
(
nil
)
fakeExec
:=
mount
.
NewFakeExec
(
nil
)
...
@@ -190,7 +190,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
...
@@ -190,7 +190,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
}
}
}
}
fakeManager2
:=
N
ewFakeDiskManager
()
fakeManager2
:=
n
ewFakeDiskManager
()
defer
fakeManager2
.
Cleanup
()
defer
fakeManager2
.
Cleanup
()
unmounter
,
err
:=
plug
.
(
*
fcPlugin
)
.
newUnmounterInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
fakeManager2
,
fakeMounter
)
unmounter
,
err
:=
plug
.
(
*
fcPlugin
)
.
newUnmounterInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
fakeManager2
,
fakeMounter
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -224,7 +224,7 @@ func doTestPluginNilMounter(t *testing.T, spec *volume.Spec) {
...
@@ -224,7 +224,7 @@ func doTestPluginNilMounter(t *testing.T, spec *volume.Spec) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
t
.
Errorf
(
"Can't find the plugin by name"
)
}
}
fakeManager
:=
N
ewFakeDiskManager
()
fakeManager
:=
n
ewFakeDiskManager
()
defer
fakeManager
.
Cleanup
()
defer
fakeManager
.
Cleanup
()
fakeMounter
:=
&
mount
.
FakeMounter
{}
fakeMounter
:=
&
mount
.
FakeMounter
{}
fakeExec
:=
mount
.
NewFakeExec
(
nil
)
fakeExec
:=
mount
.
NewFakeExec
(
nil
)
...
...
pkg/volume/fc/fc_util.go
View file @
296ea67c
...
@@ -61,13 +61,13 @@ func (handler *osIOHandler) WriteFile(filename string, data []byte, perm os.File
...
@@ -61,13 +61,13 @@ func (handler *osIOHandler) WriteFile(filename string, data []byte, perm os.File
// given a wwn and lun, find the device and associated devicemapper parent
// given a wwn and lun, find the device and associated devicemapper parent
func
findDisk
(
wwn
,
lun
string
,
io
ioHandler
,
deviceUtil
volumeutil
.
DeviceUtil
)
(
string
,
string
)
{
func
findDisk
(
wwn
,
lun
string
,
io
ioHandler
,
deviceUtil
volumeutil
.
DeviceUtil
)
(
string
,
string
)
{
fc
_p
ath
:=
"-fc-0x"
+
wwn
+
"-lun-"
+
lun
fc
P
ath
:=
"-fc-0x"
+
wwn
+
"-lun-"
+
lun
dev
_p
ath
:=
byPath
dev
P
ath
:=
byPath
if
dirs
,
err
:=
io
.
ReadDir
(
dev
_p
ath
);
err
==
nil
{
if
dirs
,
err
:=
io
.
ReadDir
(
dev
P
ath
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
for
_
,
f
:=
range
dirs
{
name
:=
f
.
Name
()
name
:=
f
.
Name
()
if
strings
.
Contains
(
name
,
fc
_p
ath
)
{
if
strings
.
Contains
(
name
,
fc
P
ath
)
{
if
disk
,
err1
:=
io
.
EvalSymlinks
(
dev
_p
ath
+
name
);
err1
==
nil
{
if
disk
,
err1
:=
io
.
EvalSymlinks
(
dev
P
ath
+
name
);
err1
==
nil
{
dm
:=
deviceUtil
.
FindMultipathDeviceForDevice
(
disk
)
dm
:=
deviceUtil
.
FindMultipathDeviceForDevice
(
disk
)
glog
.
Infof
(
"fc: find disk: %v, dm: %v"
,
disk
,
dm
)
glog
.
Infof
(
"fc: find disk: %v, dm: %v"
,
disk
,
dm
)
return
disk
,
dm
return
disk
,
dm
...
@@ -89,15 +89,15 @@ func findDiskWWIDs(wwid string, io ioHandler, deviceUtil volumeutil.DeviceUtil)
...
@@ -89,15 +89,15 @@ func findDiskWWIDs(wwid string, io ioHandler, deviceUtil volumeutil.DeviceUtil)
// The wwid could contain white space and it will be replaced
// The wwid could contain white space and it will be replaced
// underscore when wwid is exposed under /dev/by-id.
// underscore when wwid is exposed under /dev/by-id.
fc
_p
ath
:=
"scsi-"
+
wwid
fc
P
ath
:=
"scsi-"
+
wwid
dev
_id
:=
byID
dev
ID
:=
byID
if
dirs
,
err
:=
io
.
ReadDir
(
dev
_id
);
err
==
nil
{
if
dirs
,
err
:=
io
.
ReadDir
(
dev
ID
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
for
_
,
f
:=
range
dirs
{
name
:=
f
.
Name
()
name
:=
f
.
Name
()
if
name
==
fc
_p
ath
{
if
name
==
fc
P
ath
{
disk
,
err
:=
io
.
EvalSymlinks
(
dev
_id
+
name
)
disk
,
err
:=
io
.
EvalSymlinks
(
dev
ID
+
name
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
2
)
.
Infof
(
"fc: failed to find a corresponding disk from symlink[%s], error %v"
,
dev
_id
+
name
,
err
)
glog
.
V
(
2
)
.
Infof
(
"fc: failed to find a corresponding disk from symlink[%s], error %v"
,
dev
ID
+
name
,
err
)
return
""
,
""
return
""
,
""
}
}
dm
:=
deviceUtil
.
FindMultipathDeviceForDevice
(
disk
)
dm
:=
deviceUtil
.
FindMultipathDeviceForDevice
(
disk
)
...
@@ -106,7 +106,7 @@ func findDiskWWIDs(wwid string, io ioHandler, deviceUtil volumeutil.DeviceUtil)
...
@@ -106,7 +106,7 @@ func findDiskWWIDs(wwid string, io ioHandler, deviceUtil volumeutil.DeviceUtil)
}
}
}
}
}
}
glog
.
V
(
2
)
.
Infof
(
"fc: failed to find a disk [%s]"
,
dev
_id
+
fc_p
ath
)
glog
.
V
(
2
)
.
Infof
(
"fc: failed to find a disk [%s]"
,
dev
ID
+
fcP
ath
)
return
""
,
""
return
""
,
""
}
}
...
@@ -120,10 +120,10 @@ func removeFromScsiSubsystem(deviceName string, io ioHandler) {
...
@@ -120,10 +120,10 @@ func removeFromScsiSubsystem(deviceName string, io ioHandler) {
// rescan scsi bus
// rescan scsi bus
func
scsiHostRescan
(
io
ioHandler
)
{
func
scsiHostRescan
(
io
ioHandler
)
{
scsi
_p
ath
:=
"/sys/class/scsi_host/"
scsi
P
ath
:=
"/sys/class/scsi_host/"
if
dirs
,
err
:=
io
.
ReadDir
(
scsi
_p
ath
);
err
==
nil
{
if
dirs
,
err
:=
io
.
ReadDir
(
scsi
P
ath
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
for
_
,
f
:=
range
dirs
{
name
:=
scsi
_p
ath
+
f
.
Name
()
+
"/scan"
name
:=
scsi
P
ath
+
f
.
Name
()
+
"/scan"
data
:=
[]
byte
(
"- - -"
)
data
:=
[]
byte
(
"- - -"
)
io
.
WriteFile
(
name
,
data
,
0666
)
io
.
WriteFile
(
name
,
data
,
0666
)
}
}
...
@@ -134,33 +134,31 @@ func scsiHostRescan(io ioHandler) {
...
@@ -134,33 +134,31 @@ func scsiHostRescan(io ioHandler) {
func
makePDNameInternal
(
host
volume
.
VolumeHost
,
wwns
[]
string
,
lun
string
,
wwids
[]
string
)
string
{
func
makePDNameInternal
(
host
volume
.
VolumeHost
,
wwns
[]
string
,
lun
string
,
wwids
[]
string
)
string
{
if
len
(
wwns
)
!=
0
{
if
len
(
wwns
)
!=
0
{
return
path
.
Join
(
host
.
GetPluginDir
(
fcPluginName
),
wwns
[
0
]
+
"-lun-"
+
lun
)
return
path
.
Join
(
host
.
GetPluginDir
(
fcPluginName
),
wwns
[
0
]
+
"-lun-"
+
lun
)
}
else
{
return
path
.
Join
(
host
.
GetPluginDir
(
fcPluginName
),
wwids
[
0
])
}
}
return
path
.
Join
(
host
.
GetPluginDir
(
fcPluginName
),
wwids
[
0
])
}
}
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/fc/volumeDevices/target-lun-0
// make a directory like /var/lib/kubelet/plugins/kubernetes.io/fc/volumeDevices/target-lun-0
func
makeVDPDNameInternal
(
host
volume
.
VolumeHost
,
wwns
[]
string
,
lun
string
,
wwids
[]
string
)
string
{
func
makeVDPDNameInternal
(
host
volume
.
VolumeHost
,
wwns
[]
string
,
lun
string
,
wwids
[]
string
)
string
{
if
len
(
wwns
)
!=
0
{
if
len
(
wwns
)
!=
0
{
return
path
.
Join
(
host
.
GetVolumeDevicePluginDir
(
fcPluginName
),
wwns
[
0
]
+
"-lun-"
+
lun
)
return
path
.
Join
(
host
.
GetVolumeDevicePluginDir
(
fcPluginName
),
wwns
[
0
]
+
"-lun-"
+
lun
)
}
else
{
return
path
.
Join
(
host
.
GetVolumeDevicePluginDir
(
fcPluginName
),
wwids
[
0
])
}
}
return
path
.
Join
(
host
.
GetVolumeDevicePluginDir
(
fcPluginName
),
wwids
[
0
])
}
}
type
FC
Util
struct
{}
type
fc
Util
struct
{}
func
(
util
*
FC
Util
)
MakeGlobalPDName
(
fc
fcDisk
)
string
{
func
(
util
*
fc
Util
)
MakeGlobalPDName
(
fc
fcDisk
)
string
{
return
makePDNameInternal
(
fc
.
plugin
.
host
,
fc
.
wwns
,
fc
.
lun
,
fc
.
wwids
)
return
makePDNameInternal
(
fc
.
plugin
.
host
,
fc
.
wwns
,
fc
.
lun
,
fc
.
wwids
)
}
}
// Global volume device plugin dir
// Global volume device plugin dir
func
(
util
*
FC
Util
)
MakeGlobalVDPDName
(
fc
fcDisk
)
string
{
func
(
util
*
fc
Util
)
MakeGlobalVDPDName
(
fc
fcDisk
)
string
{
return
makeVDPDNameInternal
(
fc
.
plugin
.
host
,
fc
.
wwns
,
fc
.
lun
,
fc
.
wwids
)
return
makeVDPDNameInternal
(
fc
.
plugin
.
host
,
fc
.
wwns
,
fc
.
lun
,
fc
.
wwids
)
}
}
func
searchDisk
(
b
fcDiskMounter
)
(
string
,
error
)
{
func
searchDisk
(
b
fcDiskMounter
)
(
string
,
error
)
{
var
diskI
d
s
[]
string
var
diskI
D
s
[]
string
var
disk
string
var
disk
string
var
dm
string
var
dm
string
io
:=
b
.
io
io
:=
b
.
io
...
@@ -169,9 +167,9 @@ func searchDisk(b fcDiskMounter) (string, error) {
...
@@ -169,9 +167,9 @@ func searchDisk(b fcDiskMounter) (string, error) {
lun
:=
b
.
lun
lun
:=
b
.
lun
if
len
(
wwns
)
!=
0
{
if
len
(
wwns
)
!=
0
{
diskI
d
s
=
wwns
diskI
D
s
=
wwns
}
else
{
}
else
{
diskI
d
s
=
wwids
diskI
D
s
=
wwids
}
}
rescaned
:=
false
rescaned
:=
false
...
@@ -179,11 +177,11 @@ func searchDisk(b fcDiskMounter) (string, error) {
...
@@ -179,11 +177,11 @@ func searchDisk(b fcDiskMounter) (string, error) {
// first phase, search existing device path, if a multipath dm is found, exit loop
// first phase, search existing device path, if a multipath dm is found, exit loop
// otherwise, in second phase, rescan scsi bus and search again, return with any findings
// otherwise, in second phase, rescan scsi bus and search again, return with any findings
for
true
{
for
true
{
for
_
,
diskI
d
:=
range
diskId
s
{
for
_
,
diskI
D
:=
range
diskID
s
{
if
len
(
wwns
)
!=
0
{
if
len
(
wwns
)
!=
0
{
disk
,
dm
=
findDisk
(
diskI
d
,
lun
,
io
,
b
.
deviceUtil
)
disk
,
dm
=
findDisk
(
diskI
D
,
lun
,
io
,
b
.
deviceUtil
)
}
else
{
}
else
{
disk
,
dm
=
findDiskWWIDs
(
diskI
d
,
io
,
b
.
deviceUtil
)
disk
,
dm
=
findDiskWWIDs
(
diskI
D
,
io
,
b
.
deviceUtil
)
}
}
// if multipath device is found, break
// if multipath device is found, break
if
dm
!=
""
{
if
dm
!=
""
{
...
@@ -211,7 +209,7 @@ func searchDisk(b fcDiskMounter) (string, error) {
...
@@ -211,7 +209,7 @@ func searchDisk(b fcDiskMounter) (string, error) {
return
disk
,
nil
return
disk
,
nil
}
}
func
(
util
*
FC
Util
)
AttachDisk
(
b
fcDiskMounter
)
(
string
,
error
)
{
func
(
util
*
fc
Util
)
AttachDisk
(
b
fcDiskMounter
)
(
string
,
error
)
{
devicePath
,
err
:=
searchDisk
(
b
)
devicePath
,
err
:=
searchDisk
(
b
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
...
@@ -250,7 +248,7 @@ func (util *FCUtil) AttachDisk(b fcDiskMounter) (string, error) {
...
@@ -250,7 +248,7 @@ func (util *FCUtil) AttachDisk(b fcDiskMounter) (string, error) {
}
}
// DetachDisk removes scsi device file such as /dev/sdX from the node.
// DetachDisk removes scsi device file such as /dev/sdX from the node.
func
(
util
*
FC
Util
)
DetachDisk
(
c
fcDiskUnmounter
,
devicePath
string
)
error
{
func
(
util
*
fc
Util
)
DetachDisk
(
c
fcDiskUnmounter
,
devicePath
string
)
error
{
var
devices
[]
string
var
devices
[]
string
// devicePath might be like /dev/mapper/mpathX. Find destination.
// devicePath might be like /dev/mapper/mpathX. Find destination.
dstPath
,
err
:=
c
.
io
.
EvalSymlinks
(
devicePath
)
dstPath
,
err
:=
c
.
io
.
EvalSymlinks
(
devicePath
)
...
@@ -281,7 +279,7 @@ func (util *FCUtil) DetachDisk(c fcDiskUnmounter, devicePath string) error {
...
@@ -281,7 +279,7 @@ func (util *FCUtil) DetachDisk(c fcDiskUnmounter, devicePath string) error {
}
}
// detachFCDisk removes scsi device file such as /dev/sdX from the node.
// detachFCDisk removes scsi device file such as /dev/sdX from the node.
func
(
util
*
FC
Util
)
detachFCDisk
(
io
ioHandler
,
devicePath
string
)
error
{
func
(
util
*
fc
Util
)
detachFCDisk
(
io
ioHandler
,
devicePath
string
)
error
{
// Remove scsi device from the node.
// Remove scsi device from the node.
if
!
strings
.
HasPrefix
(
devicePath
,
"/dev/"
)
{
if
!
strings
.
HasPrefix
(
devicePath
,
"/dev/"
)
{
return
fmt
.
Errorf
(
"fc detach disk: invalid device name: %s"
,
devicePath
)
return
fmt
.
Errorf
(
"fc detach disk: invalid device name: %s"
,
devicePath
)
...
@@ -294,7 +292,7 @@ func (util *FCUtil) detachFCDisk(io ioHandler, devicePath string) error {
...
@@ -294,7 +292,7 @@ func (util *FCUtil) detachFCDisk(io ioHandler, devicePath string) error {
// DetachBlockFCDisk detaches a volume from kubelet node, removes scsi device file
// DetachBlockFCDisk detaches a volume from kubelet node, removes scsi device file
// such as /dev/sdX from the node, and then removes loopback for the scsi device.
// such as /dev/sdX from the node, and then removes loopback for the scsi device.
func
(
util
*
FC
Util
)
DetachBlockFCDisk
(
c
fcDiskUnmapper
,
mapPath
,
devicePath
string
)
error
{
func
(
util
*
fc
Util
)
DetachBlockFCDisk
(
c
fcDiskUnmapper
,
mapPath
,
devicePath
string
)
error
{
// Check if devicePath is valid
// Check if devicePath is valid
if
len
(
devicePath
)
!=
0
{
if
len
(
devicePath
)
!=
0
{
if
pathExists
,
pathErr
:=
checkPathExists
(
devicePath
);
!
pathExists
||
pathErr
!=
nil
{
if
pathExists
,
pathErr
:=
checkPathExists
(
devicePath
);
!
pathExists
||
pathErr
!=
nil
{
...
...
pkg/volume/flocker/flocker.go
View file @
296ea67c
...
@@ -34,7 +34,7 @@ import (
...
@@ -34,7 +34,7 @@ import (
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util"
)
)
//
Thi
s is the primary entrypoint for volume plugins.
//
ProbeVolumePlugin
s is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
flockerPlugin
{
nil
}}
return
[]
volume
.
VolumePlugin
{
&
flockerPlugin
{
nil
}}
}
}
...
@@ -116,11 +116,11 @@ func (p *flockerPlugin) SupportsMountOption() bool {
...
@@ -116,11 +116,11 @@ func (p *flockerPlugin) SupportsMountOption() bool {
return
false
return
false
}
}
func
(
p
lugin
*
flockerPlugin
)
SupportsBulkVolumeVerification
()
bool
{
func
(
p
*
flockerPlugin
)
SupportsBulkVolumeVerification
()
bool
{
return
false
return
false
}
}
func
(
p
lugin
*
flockerPlugin
)
GetAccessModes
()
[]
v1
.
PersistentVolumeAccessMode
{
func
(
p
*
flockerPlugin
)
GetAccessModes
()
[]
v1
.
PersistentVolumeAccessMode
{
return
[]
v1
.
PersistentVolumeAccessMode
{
return
[]
v1
.
PersistentVolumeAccessMode
{
v1
.
ReadWriteOnce
,
v1
.
ReadWriteOnce
,
}
}
...
@@ -136,12 +136,12 @@ func (p *flockerPlugin) getFlockerVolumeSource(spec *volume.Spec) (*v1.FlockerVo
...
@@ -136,12 +136,12 @@ func (p *flockerPlugin) getFlockerVolumeSource(spec *volume.Spec) (*v1.FlockerVo
return
spec
.
PersistentVolume
.
Spec
.
Flocker
,
readOnly
return
spec
.
PersistentVolume
.
Spec
.
Flocker
,
readOnly
}
}
func
(
p
lugin
*
flockerPlugin
)
NewMounter
(
spec
*
volume
.
Spec
,
pod
*
v1
.
Pod
,
_
volume
.
VolumeOptions
)
(
volume
.
Mounter
,
error
)
{
func
(
p
*
flockerPlugin
)
NewMounter
(
spec
*
volume
.
Spec
,
pod
*
v1
.
Pod
,
_
volume
.
VolumeOptions
)
(
volume
.
Mounter
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
p
lugin
.
newMounterInternal
(
spec
,
pod
.
UID
,
&
FlockerUtil
{},
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()))
return
p
.
newMounterInternal
(
spec
,
pod
.
UID
,
&
flockerUtil
{},
p
.
host
.
GetMounter
(
p
.
GetPluginName
()))
}
}
func
(
p
lugin
*
flockerPlugin
)
newMounterInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
volumeManager
,
mounter
mount
.
Interface
)
(
volume
.
Mounter
,
error
)
{
func
(
p
*
flockerPlugin
)
newMounterInternal
(
spec
*
volume
.
Spec
,
podUID
types
.
UID
,
manager
volumeManager
,
mounter
mount
.
Interface
)
(
volume
.
Mounter
,
error
)
{
volumeSource
,
readOnly
,
err
:=
getVolumeSource
(
spec
)
volumeSource
,
readOnly
,
err
:=
getVolumeSource
(
spec
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -158,15 +158,15 @@ func (plugin *flockerPlugin) newMounterInternal(spec *volume.Spec, podUID types.
...
@@ -158,15 +158,15 @@ func (plugin *flockerPlugin) newMounterInternal(spec *volume.Spec, podUID types.
datasetUUID
:
datasetUUID
,
datasetUUID
:
datasetUUID
,
mounter
:
mounter
,
mounter
:
mounter
,
manager
:
manager
,
manager
:
manager
,
plugin
:
p
lugin
,
plugin
:
p
,
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
spec
.
Name
(),
p
lugin
.
host
)),
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
spec
.
Name
(),
p
.
host
)),
},
},
readOnly
:
readOnly
},
nil
readOnly
:
readOnly
},
nil
}
}
func
(
p
*
flockerPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
func
(
p
*
flockerPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
// Inject real implementations here, test through the internal function.
// Inject real implementations here, test through the internal function.
return
p
.
newUnmounterInternal
(
volName
,
podUID
,
&
F
lockerUtil
{},
p
.
host
.
GetMounter
(
p
.
GetPluginName
()))
return
p
.
newUnmounterInternal
(
volName
,
podUID
,
&
f
lockerUtil
{},
p
.
host
.
GetMounter
(
p
.
GetPluginName
()))
}
}
func
(
p
*
flockerPlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
volumeManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
func
(
p
*
flockerPlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
volumeManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
...
@@ -304,7 +304,7 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -304,7 +304,7 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
}
_
,
err
:=
b
.
flockerClient
.
GetDatasetState
(
datasetUUID
)
_
,
err
:=
b
.
flockerClient
.
GetDatasetState
(
datasetUUID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"The volume with datasetUUID='%s' migrated unsuccessfully
.
"
,
datasetUUID
)
return
fmt
.
Errorf
(
"The volume with datasetUUID='%s' migrated unsuccessfully"
,
datasetUUID
)
}
}
}
}
...
@@ -433,11 +433,11 @@ func (c *flockerVolumeUnmounter) TearDownAt(dir string) error {
...
@@ -433,11 +433,11 @@ func (c *flockerVolumeUnmounter) TearDownAt(dir string) error {
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
}
func
(
p
lugin
*
flockerPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
func
(
p
*
flockerPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
return
p
lugin
.
newDeleterInternal
(
spec
,
&
F
lockerUtil
{})
return
p
.
newDeleterInternal
(
spec
,
&
f
lockerUtil
{})
}
}
func
(
p
lugin
*
flockerPlugin
)
newDeleterInternal
(
spec
*
volume
.
Spec
,
manager
volumeManager
)
(
volume
.
Deleter
,
error
)
{
func
(
p
*
flockerPlugin
)
newDeleterInternal
(
spec
*
volume
.
Spec
,
manager
volumeManager
)
(
volume
.
Deleter
,
error
)
{
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
Flocker
==
nil
{
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
Flocker
==
nil
{
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.Flocker is nil"
)
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.Flocker is nil"
)
}
}
...
@@ -450,15 +450,15 @@ func (plugin *flockerPlugin) newDeleterInternal(spec *volume.Spec, manager volum
...
@@ -450,15 +450,15 @@ func (plugin *flockerPlugin) newDeleterInternal(spec *volume.Spec, manager volum
}},
nil
}},
nil
}
}
func
(
p
lugin
*
flockerPlugin
)
NewProvisioner
(
options
volume
.
VolumeOptions
)
(
volume
.
Provisioner
,
error
)
{
func
(
p
*
flockerPlugin
)
NewProvisioner
(
options
volume
.
VolumeOptions
)
(
volume
.
Provisioner
,
error
)
{
return
p
lugin
.
newProvisionerInternal
(
options
,
&
F
lockerUtil
{})
return
p
.
newProvisionerInternal
(
options
,
&
f
lockerUtil
{})
}
}
func
(
p
lugin
*
flockerPlugin
)
newProvisionerInternal
(
options
volume
.
VolumeOptions
,
manager
volumeManager
)
(
volume
.
Provisioner
,
error
)
{
func
(
p
*
flockerPlugin
)
newProvisionerInternal
(
options
volume
.
VolumeOptions
,
manager
volumeManager
)
(
volume
.
Provisioner
,
error
)
{
return
&
flockerVolumeProvisioner
{
return
&
flockerVolumeProvisioner
{
flockerVolume
:
&
flockerVolume
{
flockerVolume
:
&
flockerVolume
{
manager
:
manager
,
manager
:
manager
,
plugin
:
p
lugin
,
plugin
:
p
,
},
},
options
:
options
,
options
:
options
,
},
nil
},
nil
...
...
pkg/volume/flocker/flocker_util.go
View file @
296ea67c
...
@@ -29,9 +29,9 @@ import (
...
@@ -29,9 +29,9 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
type
F
lockerUtil
struct
{}
type
f
lockerUtil
struct
{}
func
(
util
*
F
lockerUtil
)
DeleteVolume
(
d
*
flockerVolumeDeleter
)
error
{
func
(
util
*
f
lockerUtil
)
DeleteVolume
(
d
*
flockerVolumeDeleter
)
error
{
var
err
error
var
err
error
if
d
.
flockerClient
==
nil
{
if
d
.
flockerClient
==
nil
{
...
@@ -49,7 +49,7 @@ func (util *FlockerUtil) DeleteVolume(d *flockerVolumeDeleter) error {
...
@@ -49,7 +49,7 @@ func (util *FlockerUtil) DeleteVolume(d *flockerVolumeDeleter) error {
return
d
.
flockerClient
.
DeleteDataset
(
datasetUUID
)
return
d
.
flockerClient
.
DeleteDataset
(
datasetUUID
)
}
}
func
(
util
*
F
lockerUtil
)
CreateVolume
(
c
*
flockerVolumeProvisioner
)
(
datasetUUID
string
,
volumeSizeGiB
int
,
labels
map
[
string
]
string
,
err
error
)
{
func
(
util
*
f
lockerUtil
)
CreateVolume
(
c
*
flockerVolumeProvisioner
)
(
datasetUUID
string
,
volumeSizeGiB
int
,
labels
map
[
string
]
string
,
err
error
)
{
if
c
.
flockerClient
==
nil
{
if
c
.
flockerClient
==
nil
{
c
.
flockerClient
,
err
=
c
.
plugin
.
newFlockerClient
(
""
)
c
.
flockerClient
,
err
=
c
.
plugin
.
newFlockerClient
(
""
)
...
...
pkg/volume/flocker/flocker_util_test.go
View file @
296ea67c
...
@@ -44,7 +44,7 @@ func TestFlockerUtil_CreateVolume(t *testing.T) {
...
@@ -44,7 +44,7 @@ func TestFlockerUtil_CreateVolume(t *testing.T) {
defer
os
.
RemoveAll
(
dir
)
defer
os
.
RemoveAll
(
dir
)
provisioner
.
flockerClient
=
fakeFlockerClient
provisioner
.
flockerClient
=
fakeFlockerClient
flockerUtil
:=
&
F
lockerUtil
{}
flockerUtil
:=
&
f
lockerUtil
{}
datasetID
,
size
,
_
,
err
:=
flockerUtil
.
CreateVolume
(
provisioner
)
datasetID
,
size
,
_
,
err
:=
flockerUtil
.
CreateVolume
(
provisioner
)
assert
.
NoError
(
err
)
assert
.
NoError
(
err
)
...
...
pkg/volume/flocker/flocker_volume.go
View file @
296ea67c
...
@@ -43,8 +43,8 @@ func (b *flockerVolumeDeleter) GetPath() string {
...
@@ -43,8 +43,8 @@ func (b *flockerVolumeDeleter) GetPath() string {
return
getPath
(
b
.
podUID
,
b
.
volName
,
b
.
plugin
.
host
)
return
getPath
(
b
.
podUID
,
b
.
volName
,
b
.
plugin
.
host
)
}
}
func
(
d
*
flockerVolumeDeleter
)
Delete
()
error
{
func
(
b
*
flockerVolumeDeleter
)
Delete
()
error
{
return
d
.
manager
.
DeleteVolume
(
d
)
return
b
.
manager
.
DeleteVolume
(
b
)
}
}
type
flockerVolumeProvisioner
struct
{
type
flockerVolumeProvisioner
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment