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
15de3eed
Unverified
Commit
15de3eed
authored
Nov 05, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70461 from mysunshine92/golint
fix golint errors in pkg/volume/*
parents
2f837b15
18a904d1
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62 additions
and
64 deletions
+62
-64
.golint_failures
hack/.golint_failures
+0
-3
cephfs.go
pkg/volume/cephfs/cephfs.go
+17
-17
configmap.go
pkg/volume/configmap/configmap.go
+2
-2
sio_client.go
pkg/volume/scaleio/sio_client.go
+12
-12
sio_mgr.go
pkg/volume/scaleio/sio_mgr.go
+1
-1
sio_mgr_test.go
pkg/volume/scaleio/sio_mgr_test.go
+1
-1
sio_plugin.go
pkg/volume/scaleio/sio_plugin.go
+1
-0
sio_util.go
pkg/volume/scaleio/sio_util.go
+12
-12
sio_volume.go
pkg/volume/scaleio/sio_volume.go
+3
-3
sio_volume_test.go
pkg/volume/scaleio/sio_volume_test.go
+7
-7
secret.go
pkg/volume/secret/secret.go
+5
-5
storageos_util_test.go
pkg/volume/storageos/storageos_util_test.go
+1
-1
No files found.
hack/.golint_failures
View file @
15de3eed
...
@@ -397,8 +397,6 @@ pkg/version/verflag
...
@@ -397,8 +397,6 @@ pkg/version/verflag
pkg/volume
pkg/volume
pkg/volume/azure_dd
pkg/volume/azure_dd
pkg/volume/azure_file
pkg/volume/azure_file
pkg/volume/cephfs
pkg/volume/configmap
pkg/volume/csi/fake
pkg/volume/csi/fake
pkg/volume/git_repo
pkg/volume/git_repo
pkg/volume/host_path
pkg/volume/host_path
...
@@ -409,7 +407,6 @@ pkg/volume/photon_pd
...
@@ -409,7 +407,6 @@ pkg/volume/photon_pd
pkg/volume/portworx
pkg/volume/portworx
pkg/volume/rbd
pkg/volume/rbd
pkg/volume/scaleio
pkg/volume/scaleio
pkg/volume/secret
pkg/volume/storageos
pkg/volume/storageos
pkg/volume/testing
pkg/volume/testing
pkg/volume/util/fs
pkg/volume/util/fs
...
...
pkg/volume/cephfs/cephfs.go
View file @
15de3eed
...
@@ -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
{
&
cephfsPlugin
{
nil
}}
return
[]
volume
.
VolumePlugin
{
&
cephfsPlugin
{
nil
}}
}
}
...
@@ -144,7 +144,7 @@ func (plugin *cephfsPlugin) newMounterInternal(spec *volume.Spec, podUID types.U
...
@@ -144,7 +144,7 @@ func (plugin *cephfsPlugin) newMounterInternal(spec *volume.Spec, podUID types.U
path
:
path
,
path
:
path
,
secret
:
secret
,
secret
:
secret
,
id
:
id
,
id
:
id
,
secret
_file
:
secretFile
,
secret
File
:
secretFile
,
readonly
:
readOnly
,
readonly
:
readOnly
,
mounter
:
mounter
,
mounter
:
mounter
,
plugin
:
plugin
,
plugin
:
plugin
,
...
@@ -188,7 +188,7 @@ type cephfs struct {
...
@@ -188,7 +188,7 @@ type cephfs struct {
path
string
path
string
id
string
id
string
secret
string
secret
string
secret
_f
ile
string
secret
F
ile
string
readonly
bool
readonly
bool
mounter
mount
.
Interface
mounter
mount
.
Interface
plugin
*
cephfsPlugin
plugin
*
cephfsPlugin
...
@@ -213,7 +213,7 @@ func (cephfsVolume *cephfsMounter) GetAttributes() volume.Attributes {
...
@@ -213,7 +213,7 @@ func (cephfsVolume *cephfsMounter) GetAttributes() volume.Attributes {
// Checks prior to mount operations to verify that the required components (binaries, etc.)
// Checks prior to mount operations to verify that the required components (binaries, etc.)
// to mount the volume are available on the underlying node.
// to mount the volume are available on the underlying node.
// If not, it returns an error
// If not, it returns an error
func
(
cephfs
Mounter
*
cephfsMounter
)
CanMount
()
error
{
func
(
cephfs
Volume
*
cephfsMounter
)
CanMount
()
error
{
return
nil
return
nil
}
}
...
@@ -250,10 +250,10 @@ func (cephfsVolume *cephfsMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -250,10 +250,10 @@ func (cephfsVolume *cephfsMounter) SetUpAt(dir string, fsGroup *int64) error {
if
err
==
nil
{
if
err
==
nil
{
// cephfs fuse mount succeeded.
// cephfs fuse mount succeeded.
return
nil
return
nil
}
else
{
}
// if cephfs fuse mount failed, fallback to kernel mount.
// if cephfs fuse mount failed, fallback to kernel mount.
glog
.
V
(
2
)
.
Infof
(
"CephFS fuse mount failed: %v, fallback to kernel mount."
,
err
)
glog
.
V
(
2
)
.
Infof
(
"CephFS fuse mount failed: %v, fallback to kernel mount."
,
err
)
}
}
}
glog
.
V
(
4
)
.
Info
(
"CephFS kernel mount."
)
glog
.
V
(
4
)
.
Info
(
"CephFS kernel mount."
)
...
@@ -298,19 +298,19 @@ func (cephfsVolume *cephfs) GetKeyringPath() string {
...
@@ -298,19 +298,19 @@ func (cephfsVolume *cephfs) GetKeyringPath() string {
func
(
cephfsVolume
*
cephfs
)
execMount
(
mountpoint
string
)
error
{
func
(
cephfsVolume
*
cephfs
)
execMount
(
mountpoint
string
)
error
{
// cephfs mount option
// cephfs mount option
ceph
_o
pt
:=
""
ceph
O
pt
:=
""
// override secretfile if secret is provided
// override secretfile if secret is provided
if
cephfsVolume
.
secret
!=
""
{
if
cephfsVolume
.
secret
!=
""
{
ceph
_o
pt
=
"name="
+
cephfsVolume
.
id
+
",secret="
+
cephfsVolume
.
secret
ceph
O
pt
=
"name="
+
cephfsVolume
.
id
+
",secret="
+
cephfsVolume
.
secret
}
else
{
}
else
{
ceph
_opt
=
"name="
+
cephfsVolume
.
id
+
",secretfile="
+
cephfsVolume
.
secret_f
ile
ceph
Opt
=
"name="
+
cephfsVolume
.
id
+
",secretfile="
+
cephfsVolume
.
secretF
ile
}
}
// build option array
// build option array
opt
:=
[]
string
{}
opt
:=
[]
string
{}
if
cephfsVolume
.
readonly
{
if
cephfsVolume
.
readonly
{
opt
=
append
(
opt
,
"ro"
)
opt
=
append
(
opt
,
"ro"
)
}
}
opt
=
append
(
opt
,
ceph
_o
pt
)
opt
=
append
(
opt
,
ceph
O
pt
)
// build src like mon1:6789,mon2:6789,mon3:6789:/
// build src like mon1:6789,mon2:6789,mon3:6789:/
hosts
:=
cephfsVolume
.
mon
hosts
:=
cephfsVolume
.
mon
...
@@ -331,8 +331,8 @@ func (cephfsVolume *cephfs) execMount(mountpoint string) error {
...
@@ -331,8 +331,8 @@ func (cephfsVolume *cephfs) execMount(mountpoint string) error {
return
nil
return
nil
}
}
func
(
cephfs
Mounter
*
cephfsMounter
)
checkFuseMount
()
bool
{
func
(
cephfs
Volume
*
cephfsMounter
)
checkFuseMount
()
bool
{
execute
:=
cephfs
Mounter
.
plugin
.
host
.
GetExec
(
cephfsMounter
.
plugin
.
GetPluginName
())
execute
:=
cephfs
Volume
.
plugin
.
host
.
GetExec
(
cephfsVolume
.
plugin
.
GetPluginName
())
switch
runtime
.
GOOS
{
switch
runtime
.
GOOS
{
case
"linux"
:
case
"linux"
:
if
_
,
err
:=
execute
.
Run
(
"/usr/bin/test"
,
"-x"
,
"/sbin/mount.fuse.ceph"
);
err
==
nil
{
if
_
,
err
:=
execute
.
Run
(
"/usr/bin/test"
,
"-x"
,
"/sbin/mount.fuse.ceph"
);
err
==
nil
{
...
@@ -346,7 +346,7 @@ func (cephfsMounter *cephfsMounter) checkFuseMount() bool {
...
@@ -346,7 +346,7 @@ func (cephfsMounter *cephfsMounter) checkFuseMount() bool {
func
(
cephfsVolume
*
cephfs
)
execFuseMount
(
mountpoint
string
)
error
{
func
(
cephfsVolume
*
cephfs
)
execFuseMount
(
mountpoint
string
)
error
{
// cephfs keyring file
// cephfs keyring file
keyring
_f
ile
:=
""
keyring
F
ile
:=
""
// override secretfile if secret is provided
// override secretfile if secret is provided
if
cephfsVolume
.
secret
!=
""
{
if
cephfsVolume
.
secret
!=
""
{
// TODO: cephfs fuse currently doesn't support secret option,
// TODO: cephfs fuse currently doesn't support secret option,
...
@@ -380,10 +380,10 @@ func (cephfsVolume *cephfs) execFuseMount(mountpoint string) error {
...
@@ -380,10 +380,10 @@ func (cephfsVolume *cephfs) execFuseMount(mountpoint string) error {
return
err
return
err
}
}
keyring
_f
ile
=
path
.
Join
(
keyringPath
,
fileName
)
keyring
F
ile
=
path
.
Join
(
keyringPath
,
fileName
)
}
else
{
}
else
{
keyring
_file
=
cephfsVolume
.
secret_f
ile
keyring
File
=
cephfsVolume
.
secretF
ile
}
}
// build src like mon1:6789,mon2:6789,mon3:6789:/
// build src like mon1:6789,mon2:6789,mon3:6789:/
...
@@ -399,7 +399,7 @@ func (cephfsVolume *cephfs) execFuseMount(mountpoint string) error {
...
@@ -399,7 +399,7 @@ func (cephfsVolume *cephfs) execFuseMount(mountpoint string) error {
mountArgs
:=
[]
string
{}
mountArgs
:=
[]
string
{}
mountArgs
=
append
(
mountArgs
,
"-k"
)
mountArgs
=
append
(
mountArgs
,
"-k"
)
mountArgs
=
append
(
mountArgs
,
keyring
_f
ile
)
mountArgs
=
append
(
mountArgs
,
keyring
F
ile
)
mountArgs
=
append
(
mountArgs
,
"-m"
)
mountArgs
=
append
(
mountArgs
,
"-m"
)
mountArgs
=
append
(
mountArgs
,
src
)
mountArgs
=
append
(
mountArgs
,
src
)
mountArgs
=
append
(
mountArgs
,
mountpoint
)
mountArgs
=
append
(
mountArgs
,
mountpoint
)
...
@@ -423,7 +423,7 @@ func (cephfsVolume *cephfs) execFuseMount(mountpoint string) error {
...
@@ -423,7 +423,7 @@ func (cephfsVolume *cephfs) execFuseMount(mountpoint string) error {
command
:=
exec
.
Command
(
"ceph-fuse"
,
mountArgs
...
)
command
:=
exec
.
Command
(
"ceph-fuse"
,
mountArgs
...
)
output
,
err
:=
command
.
CombinedOutput
()
output
,
err
:=
command
.
CombinedOutput
()
if
err
!=
nil
||
!
(
strings
.
Contains
(
string
(
output
),
"starting fuse"
))
{
if
err
!=
nil
||
!
(
strings
.
Contains
(
string
(
output
),
"starting fuse"
))
{
return
fmt
.
Errorf
(
"Ceph-fuse failed: %v
\n
arguments: %s
\n
Output: %s
\n
"
,
err
,
mountArgs
,
string
(
output
))
return
fmt
.
Errorf
(
"Ceph-fuse failed: %v
\n
arguments: %s
\n
Output: %s"
,
err
,
mountArgs
,
string
(
output
))
}
}
return
nil
return
nil
...
...
pkg/volume/configmap/configmap.go
View file @
15de3eed
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
)
)
// ProbeVolumePlugin is the entry point for plugin detection in a package.
// ProbeVolumePlugin
s
is the entry point for plugin detection in a package.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
configMapPlugin
{}}
return
[]
volume
.
VolumePlugin
{
&
configMapPlugin
{}}
}
}
...
@@ -260,7 +260,7 @@ func (b *configMapVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -260,7 +260,7 @@ func (b *configMapVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
nil
return
nil
}
}
//
Note: this
function is exported so that it can be called from the projection volume driver
//
MakePayload
function is exported so that it can be called from the projection volume driver
func
MakePayload
(
mappings
[]
v1
.
KeyToPath
,
configMap
*
v1
.
ConfigMap
,
defaultMode
*
int32
,
optional
bool
)
(
map
[
string
]
volumeutil
.
FileProjection
,
error
)
{
func
MakePayload
(
mappings
[]
v1
.
KeyToPath
,
configMap
*
v1
.
ConfigMap
,
defaultMode
*
int32
,
optional
bool
)
(
map
[
string
]
volumeutil
.
FileProjection
,
error
)
{
if
defaultMode
==
nil
{
if
defaultMode
==
nil
{
return
nil
,
fmt
.
Errorf
(
"No defaultMode used, not even the default value for it"
)
return
nil
,
fmt
.
Errorf
(
"No defaultMode used, not even the default value for it"
)
...
...
pkg/volume/scaleio/sio_client.go
View file @
15de3eed
...
@@ -74,7 +74,7 @@ type sioClient struct {
...
@@ -74,7 +74,7 @@ type sioClient struct {
spClient
*
sio
.
StoragePool
spClient
*
sio
.
StoragePool
provisionMode
string
provisionMode
string
sdcPath
string
sdcPath
string
sdcG
uid
string
sdcG
UID
string
instanceID
string
instanceID
string
inited
bool
inited
bool
diskRegex
*
regexp
.
Regexp
diskRegex
*
regexp
.
Regexp
...
@@ -301,11 +301,11 @@ func (c *sioClient) IID() (string, error) {
...
@@ -301,11 +301,11 @@ func (c *sioClient) IID() (string, error) {
// if instanceID not set, retrieve it
// if instanceID not set, retrieve it
if
c
.
instanceID
==
""
{
if
c
.
instanceID
==
""
{
guid
,
err
:=
c
.
getG
uid
()
guid
,
err
:=
c
.
getG
UID
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
sdc
,
err
:=
c
.
sysClient
.
FindSdc
(
"SdcG
uid
"
,
guid
)
sdc
,
err
:=
c
.
sysClient
.
FindSdc
(
"SdcG
UID
"
,
guid
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Error
(
log
(
"failed to retrieve sdc info %s"
,
err
))
glog
.
Error
(
log
(
"failed to retrieve sdc info %s"
,
err
))
return
""
,
err
return
""
,
err
...
@@ -316,10 +316,10 @@ func (c *sioClient) IID() (string, error) {
...
@@ -316,10 +316,10 @@ func (c *sioClient) IID() (string, error) {
return
c
.
instanceID
,
nil
return
c
.
instanceID
,
nil
}
}
// getG
uid
returns instance GUID, if not set using resource labels
// getG
UID
returns instance GUID, if not set using resource labels
// it attempts to fallback to using drv_cfg binary
// it attempts to fallback to using drv_cfg binary
func
(
c
*
sioClient
)
getG
uid
()
(
string
,
error
)
{
func
(
c
*
sioClient
)
getG
UID
()
(
string
,
error
)
{
if
c
.
sdcG
uid
==
""
{
if
c
.
sdcG
UID
==
""
{
glog
.
V
(
4
)
.
Info
(
log
(
"sdc guid label not set, falling back to using drv_cfg"
))
glog
.
V
(
4
)
.
Info
(
log
(
"sdc guid label not set, falling back to using drv_cfg"
))
cmd
:=
c
.
getSdcCmd
()
cmd
:=
c
.
getSdcCmd
()
output
,
err
:=
c
.
exec
.
Run
(
cmd
,
"--query_guid"
)
output
,
err
:=
c
.
exec
.
Run
(
cmd
,
"--query_guid"
)
...
@@ -327,9 +327,9 @@ func (c *sioClient) getGuid() (string, error) {
...
@@ -327,9 +327,9 @@ func (c *sioClient) getGuid() (string, error) {
glog
.
Error
(
log
(
"drv_cfg --query_guid failed: %v"
,
err
))
glog
.
Error
(
log
(
"drv_cfg --query_guid failed: %v"
,
err
))
return
""
,
err
return
""
,
err
}
}
c
.
sdcG
uid
=
strings
.
TrimSpace
(
string
(
output
))
c
.
sdcG
UID
=
strings
.
TrimSpace
(
string
(
output
))
}
}
return
c
.
sdcG
uid
,
nil
return
c
.
sdcG
UID
,
nil
}
}
// getSioDiskPaths traverse local disk devices to retrieve device path
// getSioDiskPaths traverse local disk devices to retrieve device path
...
@@ -342,10 +342,10 @@ func (c *sioClient) getSioDiskPaths() ([]os.FileInfo, error) {
...
@@ -342,10 +342,10 @@ func (c *sioClient) getSioDiskPaths() ([]os.FileInfo, error) {
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
// sioDiskIDPath may not exist yet which is fine
// sioDiskIDPath may not exist yet which is fine
return
[]
os
.
FileInfo
{},
nil
return
[]
os
.
FileInfo
{},
nil
}
else
{
}
glog
.
Error
(
log
(
"failed to ReadDir %s: %v"
,
sioDiskIDPath
,
err
))
glog
.
Error
(
log
(
"failed to ReadDir %s: %v"
,
sioDiskIDPath
,
err
))
return
nil
,
err
return
nil
,
err
}
}
}
result
:=
[]
os
.
FileInfo
{}
result
:=
[]
os
.
FileInfo
{}
for
_
,
file
:=
range
files
{
for
_
,
file
:=
range
files
{
...
@@ -360,13 +360,13 @@ func (c *sioClient) getSioDiskPaths() ([]os.FileInfo, error) {
...
@@ -360,13 +360,13 @@ func (c *sioClient) getSioDiskPaths() ([]os.FileInfo, error) {
// GetVolumeRefs counts the number of references an SIO volume has a disk device.
// GetVolumeRefs counts the number of references an SIO volume has a disk device.
// This is useful in preventing premature detach.
// This is useful in preventing premature detach.
func
(
c
*
sioClient
)
GetVolumeRefs
(
volI
d
sioVolumeID
)
(
refs
int
,
err
error
)
{
func
(
c
*
sioClient
)
GetVolumeRefs
(
volI
D
sioVolumeID
)
(
refs
int
,
err
error
)
{
files
,
err
:=
c
.
getSioDiskPaths
()
files
,
err
:=
c
.
getSioDiskPaths
()
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
for
_
,
file
:=
range
files
{
for
_
,
file
:=
range
files
{
if
strings
.
Contains
(
file
.
Name
(),
string
(
volI
d
))
{
if
strings
.
Contains
(
file
.
Name
(),
string
(
volI
D
))
{
refs
++
refs
++
}
}
}
}
...
...
pkg/volume/scaleio/sio_mgr.go
View file @
15de3eed
...
@@ -81,7 +81,7 @@ func (m *sioMgr) getClient() (sioInterface, error) {
...
@@ -81,7 +81,7 @@ func (m *sioMgr) getClient() (sioInterface, error) {
client
.
spName
=
configs
[
confKey
.
storagePool
]
client
.
spName
=
configs
[
confKey
.
storagePool
]
client
.
sdcPath
=
configs
[
confKey
.
sdcRootPath
]
client
.
sdcPath
=
configs
[
confKey
.
sdcRootPath
]
client
.
provisionMode
=
configs
[
confKey
.
storageMode
]
client
.
provisionMode
=
configs
[
confKey
.
storageMode
]
client
.
sdcG
uid
=
configs
[
confKey
.
sdcGuid
]
client
.
sdcG
UID
=
configs
[
confKey
.
sdcGUID
]
m
.
client
=
client
m
.
client
=
client
...
...
pkg/volume/scaleio/sio_mgr_test.go
View file @
15de3eed
...
@@ -311,7 +311,7 @@ func (f *fakeSio) Devs() (map[string]string, error) {
...
@@ -311,7 +311,7 @@ func (f *fakeSio) Devs() (map[string]string, error) {
return
f
.
devs
,
nil
return
f
.
devs
,
nil
}
}
func
(
f
*
fakeSio
)
GetVolumeRefs
(
volI
d
sioVolumeID
)
(
int
,
error
)
{
func
(
f
*
fakeSio
)
GetVolumeRefs
(
volI
D
sioVolumeID
)
(
int
,
error
)
{
if
f
.
volume
==
nil
{
if
f
.
volume
==
nil
{
return
0
,
nil
return
0
,
nil
}
}
...
...
pkg/volume/scaleio/sio_plugin.go
View file @
15de3eed
...
@@ -36,6 +36,7 @@ type sioPlugin struct {
...
@@ -36,6 +36,7 @@ type sioPlugin struct {
volumeMtx
keymutex
.
KeyMutex
volumeMtx
keymutex
.
KeyMutex
}
}
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
p
:=
&
sioPlugin
{
p
:=
&
sioPlugin
{
host
:
nil
,
host
:
nil
,
...
...
pkg/volume/scaleio/sio_util.go
View file @
15de3eed
...
@@ -54,7 +54,7 @@ var (
...
@@ -54,7 +54,7 @@ var (
username
,
username
,
password
,
password
,
secretNamespace
,
secretNamespace
,
sdcG
uid
string
sdcG
UID
string
}{
}{
gateway
:
"gateway"
,
gateway
:
"gateway"
,
sslEnabled
:
"sslEnabled"
,
sslEnabled
:
"sslEnabled"
,
...
@@ -71,9 +71,9 @@ var (
...
@@ -71,9 +71,9 @@ var (
readOnly
:
"readOnly"
,
readOnly
:
"readOnly"
,
username
:
"username"
,
username
:
"username"
,
password
:
"password"
,
password
:
"password"
,
sdcG
uid
:
"sdcGuid
"
,
sdcG
UID
:
"sdcGUID
"
,
}
}
sdcG
uidLabelName
=
"scaleio.sdcGuid
"
sdcG
UIDLabelName
=
"scaleio.sdcGUID
"
sdcRootPath
=
"/opt/emc/scaleio/sdc/bin"
sdcRootPath
=
"/opt/emc/scaleio/sdc/bin"
secretNotFoundErr
=
errors
.
New
(
"secret not found"
)
secretNotFoundErr
=
errors
.
New
(
"secret not found"
)
...
@@ -232,30 +232,30 @@ func attachSecret(plug *sioPlugin, namespace string, configData map[string]strin
...
@@ -232,30 +232,30 @@ func attachSecret(plug *sioPlugin, namespace string, configData map[string]strin
return
nil
return
nil
}
}
// attachSdcG
uid
injects the sdc guid node label value into config
// attachSdcG
UID
injects the sdc guid node label value into config
func
attachSdcG
uid
(
plug
*
sioPlugin
,
conf
map
[
string
]
string
)
error
{
func
attachSdcG
UID
(
plug
*
sioPlugin
,
conf
map
[
string
]
string
)
error
{
guid
,
err
:=
getSdcG
uid
Label
(
plug
)
guid
,
err
:=
getSdcG
UID
Label
(
plug
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
conf
[
confKey
.
sdcG
uid
]
=
guid
conf
[
confKey
.
sdcG
UID
]
=
guid
return
nil
return
nil
}
}
// getSdcG
uid
Label fetches the scaleio.sdcGuid node label
// getSdcG
UID
Label fetches the scaleio.sdcGuid node label
// associated with the node executing this code.
// associated with the node executing this code.
func
getSdcG
uid
Label
(
plug
*
sioPlugin
)
(
string
,
error
)
{
func
getSdcG
UID
Label
(
plug
*
sioPlugin
)
(
string
,
error
)
{
nodeLabels
,
err
:=
plug
.
host
.
GetNodeLabels
()
nodeLabels
,
err
:=
plug
.
host
.
GetNodeLabels
()
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
label
,
ok
:=
nodeLabels
[
sdcG
uid
LabelName
]
label
,
ok
:=
nodeLabels
[
sdcG
UID
LabelName
]
if
!
ok
{
if
!
ok
{
glog
.
V
(
4
)
.
Info
(
log
(
"node label %s not found"
,
sdcG
uid
LabelName
))
glog
.
V
(
4
)
.
Info
(
log
(
"node label %s not found"
,
sdcG
UID
LabelName
))
return
""
,
nil
return
""
,
nil
}
}
glog
.
V
(
4
)
.
Info
(
log
(
"found node label %s=%s"
,
sdcG
uid
LabelName
,
label
))
glog
.
V
(
4
)
.
Info
(
log
(
"found node label %s=%s"
,
sdcG
UID
LabelName
,
label
))
return
label
,
nil
return
label
,
nil
}
}
...
...
pkg/volume/scaleio/sio_volume.go
View file @
15de3eed
...
@@ -266,7 +266,7 @@ func (v *sioVolume) Provision(selectedNode *api.Node, allowedTopologies []api.To
...
@@ -266,7 +266,7 @@ func (v *sioVolume) Provision(selectedNode *api.Node, allowedTopologies []api.To
// setup volume attrributes
// setup volume attrributes
genName
:=
v
.
generateName
(
"k8svol"
,
11
)
genName
:=
v
.
generateName
(
"k8svol"
,
11
)
var
oneGig
int64
=
1024
*
1024
*
1024
var
oneGig
int64
=
1024
*
1024
*
1024
var
eightGig
int64
=
8
*
oneGig
eightGig
:
=
8
*
oneGig
capacity
:=
v
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
api
.
ResourceName
(
api
.
ResourceStorage
)]
capacity
:=
v
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
api
.
ResourceName
(
api
.
ResourceStorage
)]
volSizeBytes
:=
capacity
.
Value
()
volSizeBytes
:=
capacity
.
Value
()
...
@@ -393,7 +393,7 @@ func (v *sioVolume) setSioMgr() error {
...
@@ -393,7 +393,7 @@ func (v *sioVolume) setSioMgr() error {
}
}
// merge in Sdc Guid label value
// merge in Sdc Guid label value
if
err
:=
attachSdcG
uid
(
v
.
plugin
,
configData
);
err
!=
nil
{
if
err
:=
attachSdcG
UID
(
v
.
plugin
,
configData
);
err
!=
nil
{
glog
.
Error
(
log
(
"failed to retrieve sdc guid: %v"
,
err
))
glog
.
Error
(
log
(
"failed to retrieve sdc guid: %v"
,
err
))
return
err
return
err
}
}
...
@@ -432,7 +432,7 @@ func (v *sioVolume) resetSioMgr() error {
...
@@ -432,7 +432,7 @@ func (v *sioVolume) resetSioMgr() error {
}
}
// merge in Sdc Guid label value
// merge in Sdc Guid label value
if
err
:=
attachSdcG
uid
(
v
.
plugin
,
configData
);
err
!=
nil
{
if
err
:=
attachSdcG
UID
(
v
.
plugin
,
configData
);
err
!=
nil
{
glog
.
Error
(
log
(
"failed to retrieve sdc guid: %v"
,
err
))
glog
.
Error
(
log
(
"failed to retrieve sdc guid: %v"
,
err
))
return
err
return
err
}
}
...
...
pkg/volume/scaleio/sio_volume_test.go
View file @
15de3eed
...
@@ -56,7 +56,7 @@ func newPluginMgr(t *testing.T, apiObject runtime.Object) (*volume.VolumePluginM
...
@@ -56,7 +56,7 @@ func newPluginMgr(t *testing.T, apiObject runtime.Object) (*volume.VolumePluginM
tmpDir
,
tmpDir
,
fakeClient
,
fakeClient
,
nil
,
nil
,
map
[
string
]
string
{
sdcG
uid
LabelName
:
"abc-123"
},
map
[
string
]
string
{
sdcG
UID
LabelName
:
"abc-123"
},
)
)
plugMgr
:=
&
volume
.
VolumePluginMgr
{}
plugMgr
:=
&
volume
.
VolumePluginMgr
{}
plugMgr
.
InitPlugins
(
ProbeVolumePlugins
(),
nil
/* prober */
,
host
)
plugMgr
.
InitPlugins
(
ProbeVolumePlugins
(),
nil
/* prober */
,
host
)
...
@@ -206,9 +206,9 @@ func TestVolumeMounterUnmounter(t *testing.T) {
...
@@ -206,9 +206,9 @@ func TestVolumeMounterUnmounter(t *testing.T) {
t
.
Errorf
(
"SetUp() - expecting multiple volume disabled by default"
)
t
.
Errorf
(
"SetUp() - expecting multiple volume disabled by default"
)
}
}
// did we read sdcG
uid
label
// did we read sdcG
UID
label
if
_
,
ok
:=
sioVol
.
sioMgr
.
configData
[
confKey
.
sdcG
uid
];
!
ok
{
if
_
,
ok
:=
sioVol
.
sioMgr
.
configData
[
confKey
.
sdcG
UID
];
!
ok
{
t
.
Errorf
(
"Expected to find node label scaleio.sdcG
uid
, but did not find it"
)
t
.
Errorf
(
"Expected to find node label scaleio.sdcG
UID
, but did not find it"
)
}
}
// rebuild spec
// rebuild spec
...
@@ -349,9 +349,9 @@ func TestVolumeProvisioner(t *testing.T) {
...
@@ -349,9 +349,9 @@ func TestVolumeProvisioner(t *testing.T) {
t
.
Fatalf
(
"Expected success, got: %v"
,
err
)
t
.
Fatalf
(
"Expected success, got: %v"
,
err
)
}
}
// did we read sdcG
uid
label
// did we read sdcG
UID
label
if
_
,
ok
:=
sioVol
.
sioMgr
.
configData
[
confKey
.
sdcG
uid
];
!
ok
{
if
_
,
ok
:=
sioVol
.
sioMgr
.
configData
[
confKey
.
sdcG
UID
];
!
ok
{
t
.
Errorf
(
"Expected to find node label scaleio.sdcG
uid
, but did not find it"
)
t
.
Errorf
(
"Expected to find node label scaleio.sdcG
UID
, but did not find it"
)
}
}
// isMultiMap applied
// isMultiMap applied
...
...
pkg/volume/secret/secret.go
View file @
15de3eed
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
)
)
// ProbeVolumePlugin is the entry point for plugin detection in a package.
// ProbeVolumePlugin
s
is the entry point for plugin detection in a package.
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
func
ProbeVolumePlugins
()
[]
volume
.
VolumePlugin
{
return
[]
volume
.
VolumePlugin
{
&
secretPlugin
{}}
return
[]
volume
.
VolumePlugin
{
&
secretPlugin
{}}
}
}
...
@@ -259,7 +259,7 @@ func (b *secretVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -259,7 +259,7 @@ func (b *secretVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
nil
return
nil
}
}
//
Note: this
function is exported so that it can be called from the projection volume driver
//
MakePayload
function is exported so that it can be called from the projection volume driver
func
MakePayload
(
mappings
[]
v1
.
KeyToPath
,
secret
*
v1
.
Secret
,
defaultMode
*
int32
,
optional
bool
)
(
map
[
string
]
volumeutil
.
FileProjection
,
error
)
{
func
MakePayload
(
mappings
[]
v1
.
KeyToPath
,
secret
*
v1
.
Secret
,
defaultMode
*
int32
,
optional
bool
)
(
map
[
string
]
volumeutil
.
FileProjection
,
error
)
{
if
defaultMode
==
nil
{
if
defaultMode
==
nil
{
return
nil
,
fmt
.
Errorf
(
"No defaultMode used, not even the default value for it"
)
return
nil
,
fmt
.
Errorf
(
"No defaultMode used, not even the default value for it"
)
...
@@ -281,9 +281,9 @@ func MakePayload(mappings []v1.KeyToPath, secret *v1.Secret, defaultMode *int32,
...
@@ -281,9 +281,9 @@ func MakePayload(mappings []v1.KeyToPath, secret *v1.Secret, defaultMode *int32,
if
optional
{
if
optional
{
continue
continue
}
}
err
_m
sg
:=
"references non-existent secret key"
err
M
sg
:=
"references non-existent secret key"
glog
.
Errorf
(
err
_m
sg
)
glog
.
Errorf
(
err
M
sg
)
return
nil
,
fmt
.
Errorf
(
err
_m
sg
)
return
nil
,
fmt
.
Errorf
(
err
M
sg
)
}
}
fileProjection
.
Data
=
[]
byte
(
content
)
fileProjection
.
Data
=
[]
byte
(
content
)
...
...
pkg/volume/storageos/storageos_util_test.go
View file @
15de3eed
...
@@ -30,7 +30,7 @@ import (
...
@@ -30,7 +30,7 @@ import (
"testing"
"testing"
)
)
var
testA
pi
SecretName
=
"storageos-api"
var
testA
PI
SecretName
=
"storageos-api"
var
testVolName
=
"storageos-test-vol"
var
testVolName
=
"storageos-test-vol"
var
testPVName
=
"storageos-test-pv"
var
testPVName
=
"storageos-test-pv"
var
testNamespace
=
"storageos-test-namespace"
var
testNamespace
=
"storageos-test-namespace"
...
...
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