Revert "Merge pull request #35821 from vishh/gci-mounter-scope"

This reverts commit 973fa6b334, reversing
changes made to 41b5fe86b6.
This commit is contained in:
saadali
2016-11-03 20:23:25 -07:00
parent b4e84d3e3b
commit 402116aed4
22 changed files with 3296 additions and 3233 deletions

View File

@@ -22,7 +22,6 @@ go_library(
tags = ["automanaged"],
deps = [
"//pkg/util/exec:go_default_library",
"//pkg/util/sets:go_default_library",
"//vendor:github.com/golang/glog",
],
)

View File

@@ -30,7 +30,7 @@ import (
const (
// Default mount command if mounter path is not specified
defaultMountCommand = "mount"
mount = "mount"
)
type Interface interface {
@@ -94,16 +94,25 @@ func (mounter *SafeFormatAndMount) FormatAndMount(source string, target string,
}
// New returns a mount.Interface for the current system.
func New() Interface {
return &Mounter{}
}
// NewCustomMounter returns a mount.Interface for the current system.
// It provides options to override the default mounter behavior.
// mounterPath allows using an alternative to `/bin/mount` for mounting.
func New(mounterPath string) Interface {
// mounterRootfsPath allows specifying a custom root filesystem path for non default `mounterPath`.
func NewCustomMounter(mounterPath, mounterRootfsPath string) Interface {
// If mounter-path flag is not set, use default mount path
if mounterPath == "" {
mounterPath = defaultMountCommand
mounterPath = mount
}
if mounterRootfsPath == "" {
mounterRootfsPath = "/"
}
return &Mounter{
mounterPath: mounterPath,
mounterPath: mounterPath,
mounterRootfsPath: mounterRootfsPath,
}
}

View File

@@ -25,13 +25,13 @@ import (
"io"
"os"
"os/exec"
"path"
"strconv"
"strings"
"syscall"
"github.com/golang/glog"
utilExec "k8s.io/kubernetes/pkg/util/exec"
"k8s.io/kubernetes/pkg/util/sets"
)
const (
@@ -54,7 +54,8 @@ const (
// for the linux platform. This implementation assumes that the
// kubelet is running in the host's root mount namespace.
type Mounter struct {
mounterPath string
mounterPath string
mounterRootfsPath string
}
// Mount mounts source to target as fstype with given options. 'source' and 'fstype' must
@@ -62,24 +63,18 @@ type Mounter struct {
// type, where kernel handles fs type for you. The mount 'options' is a list of options,
// currently come from mount(8), e.g. "ro", "remount", "bind", etc. If no more option is
// required, call Mount with an empty string list or nil.
// Update source path to include a root filesystem override to make a containerized mounter (specified via `mounterPath`) work.
func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error {
// Path to mounter binary. Set to mount accessible via $PATH by default.
// All Linux distros are expected to be shipped with a mount utility that an support bind mounts.
mounterPath := defaultMountCommand
bind, bindRemountOpts := isBind(options)
if bind {
err := doMount(mounterPath, source, target, fstype, []string{"bind"})
err := doMount(mounter.mounterPath, path.Join(mounter.mounterRootfsPath, source), path.Join(mounter.mounterRootfsPath, target), fstype, []string{"bind"})
if err != nil {
return err
}
return doMount(mounterPath, source, target, fstype, bindRemountOpts)
return doMount(mounter.mounterPath, path.Join(mounter.mounterRootfsPath, source), path.Join(mounter.mounterRootfsPath, target), fstype, bindRemountOpts)
} else {
return doMount(mounter.mounterPath, source, path.Join(mounter.mounterRootfsPath, target), fstype, options)
}
// These filesystem types are expected to be supported by the mount utility on the host across all Linux distros.
var defaultMounterFsTypes = sets.NewString("tmpfs", "ext4", "ext3", "ext2")
if !defaultMounterFsTypes.Has(fstype) {
mounterPath = mounter.mounterPath
}
return doMount(mounterPath, source, target, fstype, options)
}
// isBind detects whether a bind mount is being requested and makes the remount options to

View File

@@ -19,7 +19,8 @@ limitations under the License.
package mount
type Mounter struct {
mounterPath string
mounterPath string
mounterRootfsPath string
}
func (mounter *Mounter) Mount(source string, target string, fstype string, options []string) error {