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
407ff583
Commit
407ff583
authored
Oct 22, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16032 from rootfs/nfs-support
Auto commit by PR queue bot
parents
80be9836
1b3a88dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
nfs.go
pkg/volume/nfs/nfs.go
+24
-2
nfs_test.go
pkg/volume/nfs/nfs_test.go
+10
-2
No files found.
pkg/volume/nfs/nfs.go
View file @
407ff583
...
@@ -19,10 +19,12 @@ package nfs
...
@@ -19,10 +19,12 @@ package nfs
import
(
import
(
"fmt"
"fmt"
"os"
"os"
"runtime"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume"
...
@@ -66,9 +68,29 @@ func (plugin *nfsPlugin) Name() string {
...
@@ -66,9 +68,29 @@ func (plugin *nfsPlugin) Name() string {
return
nfsPluginName
return
nfsPluginName
}
}
func
hasNFSMount
()
bool
{
exe
:=
exec
.
New
()
switch
runtime
.
GOOS
{
case
"linux"
:
cmd1
:=
exe
.
Command
(
"/bin/ls"
,
"/sbin/mount.nfs"
)
_
,
err1
:=
cmd1
.
CombinedOutput
()
cmd2
:=
exe
.
Command
(
"/bin/ls"
,
"/sbin/mount.nfs4"
)
_
,
err2
:=
cmd2
.
CombinedOutput
()
return
(
err1
==
nil
||
err2
==
nil
)
case
"darwin"
:
cmd
:=
exe
.
Command
(
"/bin/ls"
,
"/sbin/mount_nfs"
)
_
,
err
:=
cmd
.
CombinedOutput
()
return
err
==
nil
}
return
false
}
func
(
plugin
*
nfsPlugin
)
CanSupport
(
spec
*
volume
.
Spec
)
bool
{
func
(
plugin
*
nfsPlugin
)
CanSupport
(
spec
*
volume
.
Spec
)
bool
{
return
(
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
NFS
!=
nil
)
||
if
(
spec
.
Volume
!=
nil
&&
spec
.
Volume
.
NFS
==
nil
)
||
(
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
NFS
==
nil
)
{
(
spec
.
Volume
!=
nil
&&
spec
.
Volume
.
NFS
!=
nil
)
return
false
}
// see if /sbin/mount.nfs* is there
return
hasNFSMount
()
}
}
func
(
plugin
*
nfsPlugin
)
GetAccessModes
()
[]
api
.
PersistentVolumeAccessMode
{
func
(
plugin
*
nfsPlugin
)
GetAccessModes
()
[]
api
.
PersistentVolumeAccessMode
{
...
...
pkg/volume/nfs/nfs_test.go
View file @
407ff583
...
@@ -38,12 +38,16 @@ func TestCanSupport(t *testing.T) {
...
@@ -38,12 +38,16 @@ func TestCanSupport(t *testing.T) {
if
plug
.
Name
()
!=
"kubernetes.io/nfs"
{
if
plug
.
Name
()
!=
"kubernetes.io/nfs"
{
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
t
.
Errorf
(
"Wrong name: %s"
,
plug
.
Name
())
}
}
if
!
plug
.
CanSupport
(
&
volume
.
Spec
{
Volume
:
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
NFS
:
&
api
.
NFSVolumeSource
{}}}})
{
foundMount
:=
hasNFSMount
()
if
plug
.
CanSupport
(
&
volume
.
Spec
{
Volume
:
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{
NFS
:
&
api
.
NFSVolumeSource
{}}}})
!=
foundMount
{
t
.
Errorf
(
"Expected true"
)
t
.
Errorf
(
"Expected true"
)
}
}
if
!
plug
.
CanSupport
(
&
volume
.
Spec
{
PersistentVolume
:
&
api
.
PersistentVolume
{
Spec
:
api
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
api
.
PersistentVolumeSource
{
NFS
:
&
api
.
NFSVolumeSource
{}}}}})
{
if
plug
.
CanSupport
(
&
volume
.
Spec
{
PersistentVolume
:
&
api
.
PersistentVolume
{
Spec
:
api
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
api
.
PersistentVolumeSource
{
NFS
:
&
api
.
NFSVolumeSource
{}}}}})
!=
foundMount
{
t
.
Errorf
(
"Expected true"
)
t
.
Errorf
(
"Expected true"
)
}
}
if
plug
.
CanSupport
(
&
volume
.
Spec
{
PersistentVolume
:
&
api
.
PersistentVolume
{
Spec
:
api
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
api
.
PersistentVolumeSource
{}}}})
{
t
.
Errorf
(
"Expected false"
)
}
if
plug
.
CanSupport
(
&
volume
.
Spec
{
Volume
:
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{}}})
{
if
plug
.
CanSupport
(
&
volume
.
Spec
{
Volume
:
&
api
.
Volume
{
VolumeSource
:
api
.
VolumeSource
{}}})
{
t
.
Errorf
(
"Expected false"
)
t
.
Errorf
(
"Expected false"
)
}
}
...
@@ -63,6 +67,10 @@ func TestGetAccessModes(t *testing.T) {
...
@@ -63,6 +67,10 @@ func TestGetAccessModes(t *testing.T) {
}
}
func
TestRecycler
(
t
*
testing
.
T
)
{
func
TestRecycler
(
t
*
testing
.
T
)
{
if
foundMount
:=
hasNFSMount
();
!
foundMount
{
// FindRecyclablePluginBySpec will test CanSupport() but mount helper is absent
return
}
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
:=
volume
.
VolumePluginMgr
{}
plugMgr
.
InitPlugins
([]
volume
.
VolumePlugin
{
&
nfsPlugin
{
nil
,
newMockRecycler
,
volume
.
VolumeConfig
{}}},
volume
.
NewFakeVolumeHost
(
"/tmp/fake"
,
nil
,
nil
))
plugMgr
.
InitPlugins
([]
volume
.
VolumePlugin
{
&
nfsPlugin
{
nil
,
newMockRecycler
,
volume
.
VolumeConfig
{}}},
volume
.
NewFakeVolumeHost
(
"/tmp/fake"
,
nil
,
nil
))
...
...
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