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
7885aaf6
Commit
7885aaf6
authored
Jun 13, 2017
by
Chakravarthy Nelluri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove broken getvolumename and pass PV or volume name to attach call
parent
139d7eea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
41 deletions
+31
-41
lvm
examples/volumes/flexvolume/lvm
+2
-17
nfs
examples/volumes/flexvolume/nfs
+2
-11
attacher.go
pkg/volume/flexvolume/attacher.go
+1
-0
detacher.go
pkg/volume/flexvolume/detacher.go
+4
-3
driver-call.go
pkg/volume/flexvolume/driver-call.go
+8
-5
plugin.go
pkg/volume/flexvolume/plugin.go
+12
-3
plugin_test.go
pkg/volume/flexvolume/plugin_test.go
+2
-2
No files found.
examples/volumes/flexvolume/lvm
View file @
7885aaf6
...
...
@@ -24,7 +24,6 @@ usage() {
err
"
\t
$0
waitforattach <mount device> <json params>"
err
"
\t
$0
mountdevice <mount dir> <mount device> <json params>"
err
"
\t
$0
unmountdevice <mount dir>"
err
"
\t
$0
getvolumename <json params>"
err
"
\t
$0
isattached <json params> <nodename>"
exit
1
}
...
...
@@ -138,17 +137,6 @@ unmountdevice() {
exit
0
}
getvolumename
()
{
JSON_PARAMS
=
$1
DMDEV
=
$(
getdevice
)
# get lvm device UUID
UUID
=
`
lvs
-o
lv_uuid
--noheadings
${
DMDEV
}
2>/dev/null|tr
-d
" "
`
log
"{
\"
status
\"
:
\"
Success
\"
,
\"
volumeName
\"
:
\"
${
UUID
}
\"
}"
exit
0
}
isattached
()
{
log
"{
\"
status
\"
:
\"
Success
\"
,
\"
attached
\"
:true}"
exit
0
...
...
@@ -183,15 +171,12 @@ case "$op" in
unmountdevice
)
unmountdevice
$*
;;
getvolumename
)
getvolumename
$*
;;
isattached
)
isattached
$*
;;
*
)
err
"{
\"
status
\"
:
\"
Not supported
\"
}"
exit
1
log
"{
\"
status
\"
:
\"
Not supported
\"
}"
exit
0
esac
exit
1
examples/volumes/flexvolume/nfs
View file @
7885aaf6
...
...
@@ -21,7 +21,6 @@ usage() {
err
"
\t
$0
init"
err
"
\t
$0
mount <mount dir> <json params>"
err
"
\t
$0
unmount <mount dir>"
err
"
\t
$0
getvolumename <json params>"
exit
1
}
...
...
@@ -81,14 +80,6 @@ unmount() {
exit
0
}
getvolumename
()
{
NFS_SERVER
=
$(
echo
$1
| jq
-r
'.server'
)
SHARE
=
$(
echo
$1
| jq
-r
'.share'
)
log
"{
\"
status
\"
:
\"
Success
\"
,
\"
volumeName
\"
:
\"
${
NFS_SERVER
}
/
${
SHARE
}
\"
}"
exit
0
}
op
=
$1
if
[
"
$op
"
=
"init"
]
;
then
...
...
@@ -113,8 +104,8 @@ case "$op" in
getvolumename
$*
;;
*
)
err
"{
\"
status
\"
:
\"
Not supported
\"
}"
exit
1
log
"{
\"
status
\"
:
\"
Not supported
\"
}"
exit
0
esac
exit
1
pkg/volume/flexvolume/attacher.go
View file @
7885aaf6
...
...
@@ -33,6 +33,7 @@ var _ volume.Attacher = &flexVolumeAttacher{}
// Attach is part of the volume.Attacher interface
func
(
a
*
flexVolumeAttacher
)
Attach
(
spec
*
volume
.
Spec
,
hostName
types
.
NodeName
)
(
string
,
error
)
{
call
:=
a
.
plugin
.
NewDriverCall
(
attachCmd
)
call
.
AppendSpec
(
spec
,
a
.
plugin
.
host
,
nil
)
call
.
Append
(
string
(
hostName
))
...
...
pkg/volume/flexvolume/detacher.go
View file @
7885aaf6
...
...
@@ -34,14 +34,15 @@ type flexVolumeDetacher struct {
var
_
volume
.
Detacher
=
&
flexVolumeDetacher
{}
// Detach is part of the volume.Detacher interface.
func
(
d
*
flexVolumeDetacher
)
Detach
(
deviceName
string
,
hostName
types
.
NodeName
)
error
{
func
(
d
*
flexVolumeDetacher
)
Detach
(
pvOrVolumeName
string
,
hostName
types
.
NodeName
)
error
{
call
:=
d
.
plugin
.
NewDriverCall
(
detachCmd
)
call
.
Append
(
devic
eName
)
call
.
Append
(
pvOrVolum
eName
)
call
.
Append
(
string
(
hostName
))
_
,
err
:=
call
.
Run
()
if
isCmdNotSupportedErr
(
err
)
{
return
(
*
detacherDefaults
)(
d
)
.
Detach
(
devic
eName
,
hostName
)
return
(
*
detacherDefaults
)(
d
)
.
Detach
(
pvOrVolum
eName
,
hostName
)
}
return
err
}
...
...
pkg/volume/flexvolume/driver-call.go
View file @
7885aaf6
...
...
@@ -46,11 +46,12 @@ const (
unmountCmd
=
"unmount"
// Option keys
optionFSType
=
"kubernetes.io/fsType"
optionReadWrite
=
"kubernetes.io/readwrite"
optionKeySecret
=
"kubernetes.io/secret"
optionFSGroup
=
"kubernetes.io/fsGroup"
optionMountsDir
=
"kubernetes.io/mountsDir"
optionFSType
=
"kubernetes.io/fsType"
optionReadWrite
=
"kubernetes.io/readwrite"
optionKeySecret
=
"kubernetes.io/secret"
optionFSGroup
=
"kubernetes.io/fsGroup"
optionMountsDir
=
"kubernetes.io/mountsDir"
optionPVorVolumeName
=
"kubernetes.io/pvOrVolumeName"
optionKeyPodName
=
"kubernetes.io/pod.name"
optionKeyPodNamespace
=
"kubernetes.io/pod.namespace"
...
...
@@ -174,6 +175,8 @@ func NewOptionsForDriver(spec *volume.Spec, host volume.VolumeHost, extraOptions
options
[
optionReadWrite
]
=
"rw"
}
options
[
optionPVorVolumeName
]
=
spec
.
Name
()
for
key
,
value
:=
range
extraOptions
{
options
[
key
]
=
value
}
...
...
pkg/volume/flexvolume/plugin.go
View file @
7885aaf6
...
...
@@ -21,11 +21,12 @@ import (
"strings"
"sync"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/types"
api
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
)
...
...
@@ -70,13 +71,21 @@ func (plugin *flexVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error)
call
:=
plugin
.
NewDriverCall
(
getVolumeNameCmd
)
call
.
AppendSpec
(
spec
,
plugin
.
host
,
nil
)
status
,
err
:=
call
.
Run
()
_
,
err
:=
call
.
Run
()
if
isCmdNotSupportedErr
(
err
)
{
return
(
*
pluginDefaults
)(
plugin
)
.
GetVolumeName
(
spec
)
}
else
if
err
!=
nil
{
return
""
,
err
}
return
utilstrings
.
EscapeQualifiedNameForDisk
(
status
.
VolumeName
),
nil
name
,
err
:=
(
*
pluginDefaults
)(
plugin
)
.
GetVolumeName
(
spec
)
if
err
!=
nil
{
return
""
,
err
}
glog
.
Warning
(
logPrefix
(
plugin
),
"GetVolumeName is not supported yet. Defaulting to PV or volume name: "
,
name
)
return
name
,
nil
}
// CanSupport is part of the volume.VolumePlugin interface.
...
...
pkg/volume/flexvolume/plugin_test.go
View file @
7885aaf6
...
...
@@ -41,7 +41,7 @@ func TestGetVolumeName(t *testing.T) {
spec
:=
fakeVolumeSpec
()
plugin
,
_
:=
testPlugin
()
plugin
.
runner
=
fakeRunner
(
assertDriverCall
(
t
,
fakeVolumeNameOutput
(
"/dev/sdx"
),
getVolumeNameCmd
,
assertDriverCall
(
t
,
fakeVolumeNameOutput
(
spec
.
Name
()
),
getVolumeNameCmd
,
specJson
(
plugin
,
spec
,
nil
)),
)
...
...
@@ -49,7 +49,7 @@ func TestGetVolumeName(t *testing.T) {
if
err
!=
nil
{
t
.
Errorf
(
"GetVolumeName() failed: %v"
,
err
)
}
expectedName
:=
"~dev~sdx"
expectedName
:=
spec
.
Name
()
if
name
!=
expectedName
{
t
.
Errorf
(
"GetVolumeName() returned %v instead of %v"
,
name
,
expectedName
)
}
...
...
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