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
065e4543
Commit
065e4543
authored
Oct 09, 2018
by
Cheng Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix golint issues for pkg/volume/{fc,flocker} packages
parent
02df80d8
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 @
065e4543
...
...
@@ -389,8 +389,6 @@ pkg/volume/cephfs
pkg/volume/configmap
pkg/volume/csi/fake
pkg/volume/empty_dir
pkg/volume/fc
pkg/volume/flocker
pkg/volume/git_repo
pkg/volume/host_path
pkg/volume/iscsi
...
...
pkg/volume/fc/attacher.go
View file @
065e4543
...
...
@@ -49,7 +49,7 @@ var _ volume.DeviceMountableVolumePlugin = &fcPlugin{}
func
(
plugin
*
fcPlugin
)
NewAttacher
()
(
volume
.
Attacher
,
error
)
{
return
&
fcAttacher
{
host
:
plugin
.
host
,
manager
:
&
FC
Util
{},
manager
:
&
fc
Util
{},
},
nil
}
...
...
@@ -142,7 +142,7 @@ var _ volume.DeviceUnmounter = &fcDetacher{}
func
(
plugin
*
fcPlugin
)
NewDetacher
()
(
volume
.
Detacher
,
error
)
{
return
&
fcDetacher
{
mounter
:
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
()),
manager
:
&
FC
Util
{},
manager
:
&
fc
Util
{},
},
nil
}
...
...
pkg/volume/fc/fc.go
View file @
065e4543
...
...
@@ -35,7 +35,7 @@ import (
"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
{
return
[]
volume
.
VolumePlugin
{
&
fcPlugin
{
nil
}}
}
...
...
@@ -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
)
{
// 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
)
{
...
...
@@ -166,7 +166,7 @@ func (plugin *fcPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _ v
if
pod
!=
nil
{
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
)
{
...
...
@@ -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
)
{
// 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
)
{
...
...
@@ -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
)
{
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
)
{
...
...
pkg/volume/fc/fc_test.go
View file @
065e4543
...
...
@@ -96,7 +96,7 @@ type fakeDiskManager struct {
detachCalled
bool
}
func
N
ewFakeDiskManager
()
*
fakeDiskManager
{
func
n
ewFakeDiskManager
()
*
fakeDiskManager
{
return
&
fakeDiskManager
{
tmpDir
:
utiltesting
.
MkTmpdirOrDie
(
"fc_test"
),
}
...
...
@@ -161,7 +161,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
}
fakeManager
:=
N
ewFakeDiskManager
()
fakeManager
:=
n
ewFakeDiskManager
()
defer
fakeManager
.
Cleanup
()
fakeMounter
:=
&
mount
.
FakeMounter
{}
fakeExec
:=
mount
.
NewFakeExec
(
nil
)
...
...
@@ -190,7 +190,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
}
}
fakeManager2
:=
N
ewFakeDiskManager
()
fakeManager2
:=
n
ewFakeDiskManager
()
defer
fakeManager2
.
Cleanup
()
unmounter
,
err
:=
plug
.
(
*
fcPlugin
)
.
newUnmounterInternal
(
"vol1"
,
types
.
UID
(
"poduid"
),
fakeManager2
,
fakeMounter
)
if
err
!=
nil
{
...
...
@@ -224,7 +224,7 @@ func doTestPluginNilMounter(t *testing.T, spec *volume.Spec) {
if
err
!=
nil
{
t
.
Errorf
(
"Can't find the plugin by name"
)
}
fakeManager
:=
N
ewFakeDiskManager
()
fakeManager
:=
n
ewFakeDiskManager
()
defer
fakeManager
.
Cleanup
()
fakeMounter
:=
&
mount
.
FakeMounter
{}
fakeExec
:=
mount
.
NewFakeExec
(
nil
)
...
...
pkg/volume/fc/fc_util.go
View file @
065e4543
...
...
@@ -62,13 +62,13 @@ func (handler *osIOHandler) WriteFile(filename string, data []byte, perm os.File
// given a wwn and lun, find the device and associated devicemapper parent
func
findDisk
(
wwn
,
lun
string
,
io
ioHandler
,
deviceUtil
volumeutil
.
DeviceUtil
)
(
string
,
string
)
{
fc
_p
ath
:=
"-fc-0x"
+
wwn
+
"-lun-"
+
lun
dev
_p
ath
:=
byPath
if
dirs
,
err
:=
io
.
ReadDir
(
dev
_p
ath
);
err
==
nil
{
fc
P
ath
:=
"-fc-0x"
+
wwn
+
"-lun-"
+
lun
dev
P
ath
:=
byPath
if
dirs
,
err
:=
io
.
ReadDir
(
dev
P
ath
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
name
:=
f
.
Name
()
if
strings
.
Contains
(
name
,
fc
_p
ath
)
{
if
disk
,
err1
:=
io
.
EvalSymlinks
(
dev
_p
ath
+
name
);
err1
==
nil
{
if
strings
.
Contains
(
name
,
fc
P
ath
)
{
if
disk
,
err1
:=
io
.
EvalSymlinks
(
dev
P
ath
+
name
);
err1
==
nil
{
dm
:=
deviceUtil
.
FindMultipathDeviceForDevice
(
disk
)
glog
.
Infof
(
"fc: find disk: %v, dm: %v"
,
disk
,
dm
)
return
disk
,
dm
...
...
@@ -90,15 +90,15 @@ func findDiskWWIDs(wwid string, io ioHandler, deviceUtil volumeutil.DeviceUtil)
// The wwid could contain white space and it will be replaced
// underscore when wwid is exposed under /dev/by-id.
fc
_p
ath
:=
"scsi-"
+
wwid
dev
_id
:=
byID
if
dirs
,
err
:=
io
.
ReadDir
(
dev
_id
);
err
==
nil
{
fc
P
ath
:=
"scsi-"
+
wwid
dev
ID
:=
byID
if
dirs
,
err
:=
io
.
ReadDir
(
dev
ID
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
name
:=
f
.
Name
()
if
name
==
fc
_p
ath
{
disk
,
err
:=
io
.
EvalSymlinks
(
dev
_id
+
name
)
if
name
==
fc
P
ath
{
disk
,
err
:=
io
.
EvalSymlinks
(
dev
ID
+
name
)
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
""
,
""
}
dm
:=
deviceUtil
.
FindMultipathDeviceForDevice
(
disk
)
...
...
@@ -107,7 +107,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
""
,
""
}
...
...
@@ -121,10 +121,10 @@ func removeFromScsiSubsystem(deviceName string, io ioHandler) {
// rescan scsi bus
func
scsiHostRescan
(
io
ioHandler
)
{
scsi
_p
ath
:=
"/sys/class/scsi_host/"
if
dirs
,
err
:=
io
.
ReadDir
(
scsi
_p
ath
);
err
==
nil
{
scsi
P
ath
:=
"/sys/class/scsi_host/"
if
dirs
,
err
:=
io
.
ReadDir
(
scsi
P
ath
);
err
==
nil
{
for
_
,
f
:=
range
dirs
{
name
:=
scsi
_p
ath
+
f
.
Name
()
+
"/scan"
name
:=
scsi
P
ath
+
f
.
Name
()
+
"/scan"
data
:=
[]
byte
(
"- - -"
)
io
.
WriteFile
(
name
,
data
,
0666
)
}
...
...
@@ -135,33 +135,31 @@ func scsiHostRescan(io ioHandler) {
func
makePDNameInternal
(
host
volume
.
VolumeHost
,
wwns
[]
string
,
lun
string
,
wwids
[]
string
)
string
{
if
len
(
wwns
)
!=
0
{
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
func
makeVDPDNameInternal
(
host
volume
.
VolumeHost
,
wwns
[]
string
,
lun
string
,
wwids
[]
string
)
string
{
if
len
(
wwns
)
!=
0
{
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
)
}
// 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
)
}
func
searchDisk
(
b
fcDiskMounter
)
(
string
,
error
)
{
var
diskI
d
s
[]
string
var
diskI
D
s
[]
string
var
disk
string
var
dm
string
io
:=
b
.
io
...
...
@@ -170,9 +168,9 @@ func searchDisk(b fcDiskMounter) (string, error) {
lun
:=
b
.
lun
if
len
(
wwns
)
!=
0
{
diskI
d
s
=
wwns
diskI
D
s
=
wwns
}
else
{
diskI
d
s
=
wwids
diskI
D
s
=
wwids
}
rescaned
:=
false
...
...
@@ -180,11 +178,11 @@ func searchDisk(b fcDiskMounter) (string, error) {
// 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
for
true
{
for
_
,
diskI
d
:=
range
diskId
s
{
for
_
,
diskI
D
:=
range
diskID
s
{
if
len
(
wwns
)
!=
0
{
disk
,
dm
=
findDisk
(
diskI
d
,
lun
,
io
,
b
.
deviceUtil
)
disk
,
dm
=
findDisk
(
diskI
D
,
lun
,
io
,
b
.
deviceUtil
)
}
else
{
disk
,
dm
=
findDiskWWIDs
(
diskI
d
,
io
,
b
.
deviceUtil
)
disk
,
dm
=
findDiskWWIDs
(
diskI
D
,
io
,
b
.
deviceUtil
)
}
// if multipath device is found, break
if
dm
!=
""
{
...
...
@@ -212,7 +210,7 @@ func searchDisk(b fcDiskMounter) (string, error) {
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
)
if
err
!=
nil
{
return
""
,
err
...
...
@@ -251,7 +249,7 @@ func (util *FCUtil) AttachDisk(b fcDiskMounter) (string, error) {
}
// 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
// devicePath might be like /dev/mapper/mpathX. Find destination.
dstPath
,
err
:=
c
.
io
.
EvalSymlinks
(
devicePath
)
...
...
@@ -282,7 +280,7 @@ func (util *FCUtil) DetachDisk(c fcDiskUnmounter, devicePath string) error {
}
// 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.
if
!
strings
.
HasPrefix
(
devicePath
,
"/dev/"
)
{
return
fmt
.
Errorf
(
"fc detach disk: invalid device name: %s"
,
devicePath
)
...
...
@@ -295,7 +293,7 @@ func (util *FCUtil) detachFCDisk(io ioHandler, devicePath string) error {
// 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.
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
if
len
(
devicePath
)
!=
0
{
if
pathExists
,
pathErr
:=
checkPathExists
(
devicePath
);
!
pathExists
||
pathErr
!=
nil
{
...
...
pkg/volume/flocker/flocker.go
View file @
065e4543
...
...
@@ -34,7 +34,7 @@ import (
"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
{
return
[]
volume
.
VolumePlugin
{
&
flockerPlugin
{
nil
}}
}
...
...
@@ -116,11 +116,11 @@ func (p *flockerPlugin) SupportsMountOption() bool {
return
false
}
func
(
p
lugin
*
flockerPlugin
)
SupportsBulkVolumeVerification
()
bool
{
func
(
p
*
flockerPlugin
)
SupportsBulkVolumeVerification
()
bool
{
return
false
}
func
(
p
lugin
*
flockerPlugin
)
GetAccessModes
()
[]
v1
.
PersistentVolumeAccessMode
{
func
(
p
*
flockerPlugin
)
GetAccessModes
()
[]
v1
.
PersistentVolumeAccessMode
{
return
[]
v1
.
PersistentVolumeAccessMode
{
v1
.
ReadWriteOnce
,
}
...
...
@@ -136,12 +136,12 @@ func (p *flockerPlugin) getFlockerVolumeSource(spec *volume.Spec) (*v1.FlockerVo
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.
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
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -158,15 +158,15 @@ func (plugin *flockerPlugin) newMounterInternal(spec *volume.Spec, podUID types.
datasetUUID
:
datasetUUID
,
mounter
:
mounter
,
manager
:
manager
,
plugin
:
p
lugin
,
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
spec
.
Name
(),
p
lugin
.
host
)),
plugin
:
p
,
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
spec
.
Name
(),
p
.
host
)),
},
readOnly
:
readOnly
},
nil
}
func
(
p
*
flockerPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
// 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
)
{
...
...
@@ -304,7 +304,7 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
_
,
err
:=
b
.
flockerClient
.
GetDatasetState
(
datasetUUID
)
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 {
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
(
p
lugin
*
flockerPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
return
p
lugin
.
newDeleterInternal
(
spec
,
&
F
lockerUtil
{})
func
(
p
*
flockerPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
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
{
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.Flocker is nil"
)
}
...
...
@@ -450,15 +450,15 @@ func (plugin *flockerPlugin) newDeleterInternal(spec *volume.Spec, manager volum
}},
nil
}
func
(
p
lugin
*
flockerPlugin
)
NewProvisioner
(
options
volume
.
VolumeOptions
)
(
volume
.
Provisioner
,
error
)
{
return
p
lugin
.
newProvisionerInternal
(
options
,
&
F
lockerUtil
{})
func
(
p
*
flockerPlugin
)
NewProvisioner
(
options
volume
.
VolumeOptions
)
(
volume
.
Provisioner
,
error
)
{
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
{
flockerVolume
:
&
flockerVolume
{
manager
:
manager
,
plugin
:
p
lugin
,
plugin
:
p
,
},
options
:
options
,
},
nil
...
...
pkg/volume/flocker/flocker_util.go
View file @
065e4543
...
...
@@ -29,9 +29,9 @@ import (
"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
if
d
.
flockerClient
==
nil
{
...
...
@@ -49,7 +49,7 @@ func (util *FlockerUtil) DeleteVolume(d *flockerVolumeDeleter) error {
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
{
c
.
flockerClient
,
err
=
c
.
plugin
.
newFlockerClient
(
""
)
...
...
pkg/volume/flocker/flocker_util_test.go
View file @
065e4543
...
...
@@ -44,7 +44,7 @@ func TestFlockerUtil_CreateVolume(t *testing.T) {
defer
os
.
RemoveAll
(
dir
)
provisioner
.
flockerClient
=
fakeFlockerClient
flockerUtil
:=
&
F
lockerUtil
{}
flockerUtil
:=
&
f
lockerUtil
{}
datasetID
,
size
,
_
,
err
:=
flockerUtil
.
CreateVolume
(
provisioner
)
assert
.
NoError
(
err
)
...
...
pkg/volume/flocker/flocker_volume.go
View file @
065e4543
...
...
@@ -43,8 +43,8 @@ func (b *flockerVolumeDeleter) GetPath() string {
return
getPath
(
b
.
podUID
,
b
.
volName
,
b
.
plugin
.
host
)
}
func
(
d
*
flockerVolumeDeleter
)
Delete
()
error
{
return
d
.
manager
.
DeleteVolume
(
d
)
func
(
b
*
flockerVolumeDeleter
)
Delete
()
error
{
return
b
.
manager
.
DeleteVolume
(
b
)
}
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