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
32a49828
Unverified
Commit
32a49828
authored
Apr 17, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76456 from codenrhoden/mv-exec-mounter
Move ExecMount to pkg/volume/util/exec
parents
23e6f803
96476fd0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
32 deletions
+114
-32
BUILD
pkg/kubelet/BUILD
+1
-0
volume_host.go
pkg/kubelet/volume_host.go
+2
-1
BUILD
pkg/util/mount/BUILD
+0
-3
BUILD
pkg/volume/util/BUILD
+1
-0
BUILD
pkg/volume/util/exec/BUILD
+74
-0
exec_mount.go
pkg/volume/util/exec/exec_mount.go
+15
-11
exec_mount_test.go
pkg/volume/util/exec/exec_mount_test.go
+10
-8
exec_mount_unsupported.go
pkg/volume/util/exec/exec_mount_unsupported.go
+11
-9
No files found.
pkg/kubelet/BUILD
View file @
32a49828
...
...
@@ -110,6 +110,7 @@ go_library(
"//pkg/volume:go_default_library",
"//pkg/volume/csi:go_default_library",
"//pkg/volume/util:go_default_library",
"//pkg/volume/util/exec:go_default_library",
"//pkg/volume/util/subpath:go_default_library",
"//pkg/volume/util/types:go_default_library",
"//pkg/volume/util/volumepathhandler:go_default_library",
...
...
pkg/kubelet/volume_host.go
View file @
32a49828
...
...
@@ -43,6 +43,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
execmnt
"k8s.io/kubernetes/pkg/volume/util/exec"
"k8s.io/kubernetes/pkg/volume/util/subpath"
)
...
...
@@ -230,7 +231,7 @@ func (kvh *kubeletVolumeHost) GetMounter(pluginName string) mount.Interface {
if
exec
==
nil
{
return
kvh
.
kubelet
.
mounter
}
return
mou
nt
.
NewExecMounter
(
exec
,
kvh
.
kubelet
.
mounter
)
return
execm
nt
.
NewExecMounter
(
exec
,
kvh
.
kubelet
.
mounter
)
}
func
(
kvh
*
kubeletVolumeHost
)
GetHostName
()
string
{
...
...
pkg/util/mount/BUILD
View file @
32a49828
...
...
@@ -5,8 +5,6 @@ go_library(
srcs = [
"doc.go",
"exec.go",
"exec_mount.go",
"exec_mount_unsupported.go",
"fake.go",
"mount.go",
"mount_helper_common.go",
...
...
@@ -38,7 +36,6 @@ go_library(
go_test(
name = "go_default_test",
srcs = [
"exec_mount_test.go",
"mount_helper_test.go",
"mount_linux_test.go",
"mount_test.go",
...
...
pkg/volume/util/BUILD
View file @
32a49828
...
...
@@ -84,6 +84,7 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//pkg/volume/util/exec:all-srcs",
"//pkg/volume/util/fs:all-srcs",
"//pkg/volume/util/nestedpendingoperations:all-srcs",
"//pkg/volume/util/nsenter:all-srcs",
...
...
pkg/volume/util/exec/BUILD
0 → 100644
View file @
32a49828
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"exec_mount.go",
"exec_mount_unsupported.go",
],
importpath = "k8s.io/kubernetes/pkg/volume/util/exec",
visibility = ["//visibility:public"],
deps = select({
"@io_bazel_rules_go//go/platform:android": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:darwin": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:linux": [
"//pkg/util/mount:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
"@io_bazel_rules_go//go/platform:nacl": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:plan9": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:solaris": [
"//pkg/util/mount:go_default_library",
],
"@io_bazel_rules_go//go/platform:windows": [
"//pkg/util/mount:go_default_library",
],
"//conditions:default": [],
}),
)
go_test(
name = "go_default_test",
srcs = ["exec_mount_test.go"],
embed = [":go_default_library"],
deps = select({
"@io_bazel_rules_go//go/platform:linux": [
"//pkg/util/mount:go_default_library",
],
"//conditions:default": [],
}),
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
pkg/
util/mount
/exec_mount.go
→
pkg/
volume/util/exec
/exec_mount.go
View file @
32a49828
...
...
@@ -16,23 +16,27 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
mount
package
exec
import
(
"fmt"
"os"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/util/mount"
)
// ExecMounter is a mounter that uses provided Exec interface to mount and
// unmount a filesystem. For all other calls it uses a wrapped mounter.
type
execMounter
struct
{
wrappedMounter
Interface
exec
Exec
wrappedMounter
mount
.
Interface
exec
mount
.
Exec
}
func
NewExecMounter
(
exec
Exec
,
wrapped
Interface
)
Interface
{
// NewExecMounter returns a mounter that uses provided Exec interface to mount and
// unmount a filesystem. For all other calls it uses a wrapped mounter.
func
NewExecMounter
(
exec
mount
.
Exec
,
wrapped
mount
.
Interface
)
mount
.
Interface
{
return
&
execMounter
{
wrappedMounter
:
wrapped
,
exec
:
exec
,
...
...
@@ -40,11 +44,11 @@ func NewExecMounter(exec Exec, wrapped Interface) Interface {
}
// execMounter implements mount.Interface
var
_
Interface
=
&
execMounter
{}
var
_
mount
.
Interface
=
&
execMounter
{}
// Mount runs mount(8) using given exec interface.
func
(
m
*
execMounter
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
bind
,
bindOpts
,
bindRemountOpts
:=
IsBind
(
options
)
bind
,
bindOpts
,
bindRemountOpts
:=
mount
.
IsBind
(
options
)
if
bind
{
err
:=
m
.
doExecMount
(
source
,
target
,
fstype
,
bindOpts
)
...
...
@@ -60,11 +64,11 @@ func (m *execMounter) Mount(source string, target string, fstype string, options
// doExecMount calls exec(mount <what> <where>) using given exec interface.
func
(
m
*
execMounter
)
doExecMount
(
source
,
target
,
fstype
string
,
options
[]
string
)
error
{
klog
.
V
(
5
)
.
Infof
(
"Exec Mounting %s %s %s %v"
,
source
,
target
,
fstype
,
options
)
mountArgs
:=
MakeMountArgs
(
source
,
target
,
fstype
,
options
)
mountArgs
:=
mount
.
MakeMountArgs
(
source
,
target
,
fstype
,
options
)
output
,
err
:=
m
.
exec
.
Run
(
"mount"
,
mountArgs
...
)
klog
.
V
(
5
)
.
Infof
(
"Exec mounted %v: %v: %s"
,
mountArgs
,
err
,
string
(
output
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"mount failed: %v
\n
Mounting command: %s
\n
Mounting arguments: %s %s %s %v
\n
Output: %s
\n
"
,
return
fmt
.
Errorf
(
"mount failed: %v
\n
Mounting command: %s
\n
Mounting arguments: %s %s %s %v
\n
Output: %s"
,
err
,
"mount"
,
source
,
target
,
fstype
,
options
,
string
(
output
))
}
...
...
@@ -84,7 +88,7 @@ func (m *execMounter) Unmount(target string) error {
}
// List returns a list of all mounted filesystems.
func
(
m
*
execMounter
)
List
()
([]
MountPoint
,
error
)
{
func
(
m
*
execMounter
)
List
()
([]
mount
.
MountPoint
,
error
)
{
return
m
.
wrappedMounter
.
List
()
}
...
...
@@ -112,7 +116,7 @@ func (m *execMounter) GetDeviceNameFromMount(mountPath, pluginDir string) (strin
return
m
.
wrappedMounter
.
GetDeviceNameFromMount
(
mountPath
,
pluginDir
)
}
func
(
m
*
execMounter
)
IsMountPointMatch
(
mp
MountPoint
,
dir
string
)
bool
{
func
(
m
*
execMounter
)
IsMountPointMatch
(
mp
mount
.
MountPoint
,
dir
string
)
bool
{
return
m
.
wrappedMounter
.
IsMountPointMatch
(
mp
,
dir
)
}
...
...
@@ -120,7 +124,7 @@ func (m *execMounter) MakeRShared(path string) error {
return
m
.
wrappedMounter
.
MakeRShared
(
path
)
}
func
(
m
*
execMounter
)
GetFileType
(
pathname
string
)
(
FileType
,
error
)
{
func
(
m
*
execMounter
)
GetFileType
(
pathname
string
)
(
mount
.
FileType
,
error
)
{
return
m
.
wrappedMounter
.
GetFileType
(
pathname
)
}
...
...
pkg/
util/mount
/exec_mount_test.go
→
pkg/
volume/util/exec
/exec_mount_test.go
View file @
32a49828
...
...
@@ -16,13 +16,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
mount
package
exec
import
(
"fmt"
"reflect"
"strings"
"testing"
"k8s.io/kubernetes/pkg/util/mount"
)
var
(
...
...
@@ -33,7 +35,7 @@ var (
)
func
TestMount
(
t
*
testing
.
T
)
{
exec
:=
NewFakeExec
(
func
(
cmd
string
,
args
...
string
)
([]
byte
,
error
)
{
exec
:=
mount
.
NewFakeExec
(
func
(
cmd
string
,
args
...
string
)
([]
byte
,
error
)
{
if
cmd
!=
"mount"
{
t
.
Errorf
(
"expected mount command, got %q"
,
cmd
)
}
...
...
@@ -45,7 +47,7 @@ func TestMount(t *testing.T) {
return
nil
,
nil
})
wrappedMounter
:=
&
fakeMounter
{
FakeMounter
:
&
FakeMounter
{},
t
:
t
}
wrappedMounter
:=
&
fakeMounter
{
FakeMounter
:
&
mount
.
FakeMounter
{},
t
:
t
}
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
.
Mount
(
sourcePath
,
destinationPath
,
fsType
,
mountOptions
)
...
...
@@ -53,7 +55,7 @@ func TestMount(t *testing.T) {
func
TestBindMount
(
t
*
testing
.
T
)
{
cmdCount
:=
0
exec
:=
NewFakeExec
(
func
(
cmd
string
,
args
...
string
)
([]
byte
,
error
)
{
exec
:=
mount
.
NewFakeExec
(
func
(
cmd
string
,
args
...
string
)
([]
byte
,
error
)
{
cmdCount
++
if
cmd
!=
"mount"
{
t
.
Errorf
(
"expected mount command, got %q"
,
cmd
)
...
...
@@ -73,14 +75,14 @@ func TestBindMount(t *testing.T) {
return
nil
,
nil
})
wrappedMounter
:=
&
fakeMounter
{
FakeMounter
:
&
FakeMounter
{},
t
:
t
}
wrappedMounter
:=
&
fakeMounter
{
FakeMounter
:
&
mount
.
FakeMounter
{},
t
:
t
}
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
bindOptions
:=
append
(
mountOptions
,
"bind"
)
mounter
.
Mount
(
sourcePath
,
destinationPath
,
fsType
,
bindOptions
)
}
func
TestUnmount
(
t
*
testing
.
T
)
{
exec
:=
NewFakeExec
(
func
(
cmd
string
,
args
...
string
)
([]
byte
,
error
)
{
exec
:=
mount
.
NewFakeExec
(
func
(
cmd
string
,
args
...
string
)
([]
byte
,
error
)
{
if
cmd
!=
"umount"
{
t
.
Errorf
(
"expected unmount command, got %q"
,
cmd
)
}
...
...
@@ -92,7 +94,7 @@ func TestUnmount(t *testing.T) {
return
nil
,
nil
})
wrappedMounter
:=
&
fakeMounter
{
&
FakeMounter
{},
t
}
wrappedMounter
:=
&
fakeMounter
{
&
mount
.
FakeMounter
{},
t
}
mounter
:=
NewExecMounter
(
exec
,
wrappedMounter
)
mounter
.
Unmount
(
destinationPath
)
...
...
@@ -100,7 +102,7 @@ func TestUnmount(t *testing.T) {
/* Fake wrapped mounter */
type
fakeMounter
struct
{
*
FakeMounter
*
mount
.
FakeMounter
t
*
testing
.
T
}
...
...
pkg/
util/mount
/exec_mount_unsupported.go
→
pkg/
volume/util/exec
/exec_mount_unsupported.go
View file @
32a49828
...
...
@@ -16,18 +16,20 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
mount
package
exec
import
(
"errors"
"os"
"k8s.io/kubernetes/pkg/util/mount"
)
type
execMounter
struct
{}
//
ExecMounter i
s a mounter that uses provided Exec interface to mount and
//
NewExecMounter return
s a mounter that uses provided Exec interface to mount and
// unmount a filesystem. For all other calls it uses a wrapped mounter.
func
NewExecMounter
(
exec
Exec
,
wrapped
Interface
)
Interface
{
func
NewExecMounter
(
exec
mount
.
Exec
,
wrapped
mount
.
Interface
)
mount
.
Interface
{
return
&
execMounter
{}
}
...
...
@@ -39,11 +41,11 @@ func (mounter *execMounter) Unmount(target string) error {
return
nil
}
func
(
mounter
*
execMounter
)
List
()
([]
MountPoint
,
error
)
{
return
[]
MountPoint
{},
nil
func
(
mounter
*
execMounter
)
List
()
([]
mount
.
MountPoint
,
error
)
{
return
[]
mount
.
MountPoint
{},
nil
}
func
(
mounter
*
execMounter
)
IsMountPointMatch
(
mp
MountPoint
,
dir
string
)
bool
{
func
(
mounter
*
execMounter
)
IsMountPointMatch
(
mp
mount
.
MountPoint
,
dir
string
)
bool
{
return
(
mp
.
Path
==
dir
)
}
...
...
@@ -67,8 +69,8 @@ func (mounter *execMounter) MakeRShared(path string) error {
return
nil
}
func
(
mounter
*
execMounter
)
GetFileType
(
pathname
string
)
(
FileType
,
error
)
{
return
FileType
(
"fake"
),
errors
.
New
(
"not implemented"
)
func
(
mounter
*
execMounter
)
GetFileType
(
pathname
string
)
(
mount
.
FileType
,
error
)
{
return
mount
.
FileType
(
"fake"
),
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
execMounter
)
MakeDir
(
pathname
string
)
error
{
...
...
@@ -83,7 +85,7 @@ func (mounter *execMounter) ExistsPath(pathname string) (bool, error) {
return
true
,
errors
.
New
(
"not implemented"
)
}
func
(
m
*
execMounter
)
EvalHostSymlinks
(
pathname
string
)
(
string
,
error
)
{
func
(
m
ounter
*
execMounter
)
EvalHostSymlinks
(
pathname
string
)
(
string
,
error
)
{
return
""
,
errors
.
New
(
"not implemented"
)
}
...
...
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