mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
add systemd mount options interface to support the no-systemd mount
This commit is contained in:
parent
53d9bed6e0
commit
27cb5cf4f0
@ -399,7 +399,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, mounterArgs volume.Mou
|
|||||||
options = append(options, "ro")
|
options = append(options, "ro")
|
||||||
}
|
}
|
||||||
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
||||||
err = b.mounter.Mount(globalPDPath, dir, "", mountOptions)
|
err = b.mounter.MountSensitiveWithoutSystemd(globalPDPath, dir, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
@ -305,7 +305,7 @@ func (b *azureFileMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
|
|||||||
|
|
||||||
mountComplete := false
|
mountComplete := false
|
||||||
err = wait.PollImmediate(1*time.Second, 2*time.Minute, func() (bool, error) {
|
err = wait.PollImmediate(1*time.Second, 2*time.Minute, func() (bool, error) {
|
||||||
err := b.mounter.MountSensitive(source, dir, "cifs", mountOptions, sensitiveMountOptions)
|
err := b.mounter.MountSensitiveWithoutSystemd(source, dir, "cifs", mountOptions, sensitiveMountOptions)
|
||||||
mountComplete = true
|
mountComplete = true
|
||||||
return true, err
|
return true, err
|
||||||
})
|
})
|
||||||
|
@ -131,7 +131,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mountErr := mounter.Mount(globalPDPath, dir, *volumeSource.FSType, options)
|
mountErr := mounter.MountSensitiveWithoutSystemd(globalPDPath, dir, *volumeSource.FSType, options, nil)
|
||||||
// Everything in the following control flow is meant as an
|
// Everything in the following control flow is meant as an
|
||||||
// attempt cleanup a failed setupAt (bind mount)
|
// attempt cleanup a failed setupAt (bind mount)
|
||||||
if mountErr != nil {
|
if mountErr != nil {
|
||||||
|
@ -418,7 +418,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs
|
|||||||
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
||||||
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
|
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
|
||||||
klog.V(4).Infof("Attempting to mount cinder volume %s to %s with options %v", b.pdName, dir, mountOptions)
|
klog.V(4).Infof("Attempting to mount cinder volume %s to %s with options %v", b.pdName, dir, mountOptions)
|
||||||
err = b.mounter.Mount(globalPDPath, dir, "", options)
|
err = b.mounter.MountSensitiveWithoutSystemd(globalPDPath, dir, "", options, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(4).Infof("Mount failed: %v", err)
|
klog.V(4).Infof("Mount failed: %v", err)
|
||||||
notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||||
|
@ -96,7 +96,7 @@ func (fake *fakePDManager) AttachDisk(b *cinderVolumeMounter, globalPDPath strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if notmnt {
|
if notmnt {
|
||||||
err = b.mounter.Mount(fakeDeviceName, globalPath, "", []string{"bind"})
|
err = b.mounter.MountSensitiveWithoutSystemd(fakeDeviceName, globalPath, "", []string{"bind"}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ func (ed *emptyDir) setupTmpfs(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
klog.V(3).Infof("pod %v: mounting tmpfs for volume %v", ed.pod.UID, ed.volName)
|
klog.V(3).Infof("pod %v: mounting tmpfs for volume %v", ed.pod.UID, ed.volName)
|
||||||
return ed.mounter.Mount("tmpfs", dir, "tmpfs", nil /* options */)
|
return ed.mounter.MountSensitiveWithoutSystemd("tmpfs", dir, "tmpfs", nil /* options */, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setupHugepages creates a hugepage mount at the specified directory.
|
// setupHugepages creates a hugepage mount at the specified directory.
|
||||||
@ -317,7 +317,7 @@ func (ed *emptyDir) setupHugepages(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
klog.V(3).Infof("pod %v: mounting hugepages for volume %v", ed.pod.UID, ed.volName)
|
klog.V(3).Infof("pod %v: mounting hugepages for volume %v", ed.pod.UID, ed.volName)
|
||||||
return ed.mounter.Mount("nodev", dir, "hugetlbfs", []string{pageSizeMountOption})
|
return ed.mounter.MountSensitiveWithoutSystemd("nodev", dir, "hugetlbfs", []string{pageSizeMountOption}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPageSizeMountOption retrieves pageSize mount option from Pod's resources
|
// getPageSizeMountOption retrieves pageSize mount option from Pod's resources
|
||||||
|
@ -61,7 +61,7 @@ func diskSetUp(manager diskManager, b fcDiskMounter, volPath string, mounter mou
|
|||||||
options = append(options, "ro")
|
options = append(options, "ro")
|
||||||
}
|
}
|
||||||
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
||||||
err = mounter.Mount(globalPDPath, volPath, "", mountOptions)
|
err = mounter.MountSensitiveWithoutSystemd(globalPDPath, volPath, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to bind mount: source:%s, target:%s, err:%v", globalPDPath, volPath, err)
|
klog.Errorf("Failed to bind mount: source:%s, target:%s, err:%v", globalPDPath, volPath, err)
|
||||||
noMnt, mntErr := b.mounter.IsLikelyNotMountPoint(volPath)
|
noMnt, mntErr := b.mounter.IsLikelyNotMountPoint(volPath)
|
||||||
|
@ -140,7 +140,7 @@ func prepareForMount(mounter mount.Interface, deviceMountPath string) (bool, err
|
|||||||
// Mounts the device at the given path.
|
// Mounts the device at the given path.
|
||||||
// It is expected that prepareForMount has been called before.
|
// It is expected that prepareForMount has been called before.
|
||||||
func doMount(mounter mount.Interface, devicePath, deviceMountPath, fsType string, options []string) error {
|
func doMount(mounter mount.Interface, devicePath, deviceMountPath, fsType string, options []string) error {
|
||||||
err := mounter.Mount(devicePath, deviceMountPath, fsType, options)
|
err := mounter.MountSensitiveWithoutSystemd(devicePath, deviceMountPath, fsType, options, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to mount the volume at %s, device: %s, error: %s", deviceMountPath, devicePath, err.Error())
|
klog.Errorf("Failed to mount the volume at %s, device: %s, error: %s", deviceMountPath, devicePath, err.Error())
|
||||||
return err
|
return err
|
||||||
|
@ -332,7 +332,7 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArg
|
|||||||
globalFlockerPath := makeGlobalFlockerPath(datasetUUID)
|
globalFlockerPath := makeGlobalFlockerPath(datasetUUID)
|
||||||
klog.V(4).Infof("attempting to mount %s", dir)
|
klog.V(4).Infof("attempting to mount %s", dir)
|
||||||
|
|
||||||
err = b.mounter.Mount(globalFlockerPath, dir, "", options)
|
err = b.mounter.MountSensitiveWithoutSystemd(globalFlockerPath, dir, "", options, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
@ -401,7 +401,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, mounterArgs volume.Mounte
|
|||||||
|
|
||||||
mountOptions := util.JoinMountOptions(b.mountOptions, options)
|
mountOptions := util.JoinMountOptions(b.mountOptions, options)
|
||||||
|
|
||||||
err = b.mounter.Mount(globalPDPath, dir, "", mountOptions)
|
err = b.mounter.MountSensitiveWithoutSystemd(globalPDPath, dir, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
@ -67,7 +67,7 @@ func diskSetUp(manager diskManager, b iscsiDiskMounter, volPath string, mounter
|
|||||||
}
|
}
|
||||||
globalPDPath := manager.MakeGlobalPDName(*b.iscsiDisk)
|
globalPDPath := manager.MakeGlobalPDName(*b.iscsiDisk)
|
||||||
mountOptions := util.JoinMountOptions(b.mountOptions, options)
|
mountOptions := util.JoinMountOptions(b.mountOptions, options)
|
||||||
err = mounter.Mount(globalPDPath, volPath, "", mountOptions)
|
err = mounter.MountSensitiveWithoutSystemd(globalPDPath, volPath, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to bind mount: source:%s, target:%s, err:%v", globalPDPath, volPath, err)
|
klog.Errorf("Failed to bind mount: source:%s, target:%s, err:%v", globalPDPath, volPath, err)
|
||||||
noMnt, mntErr := b.mounter.IsLikelyNotMountPoint(volPath)
|
noMnt, mntErr := b.mounter.IsLikelyNotMountPoint(volPath)
|
||||||
|
@ -120,7 +120,7 @@ func (fake *fakeDiskManager) AttachDisk(b iscsiDiskMounter) (string, error) {
|
|||||||
}
|
}
|
||||||
// Simulate the global mount so that the fakeMounter returns the
|
// Simulate the global mount so that the fakeMounter returns the
|
||||||
// expected number of mounts for the attached disk.
|
// expected number of mounts for the attached disk.
|
||||||
b.mounter.Mount(globalPath, globalPath, b.fsType, nil)
|
b.mounter.MountSensitiveWithoutSystemd(globalPath, globalPath, b.fsType, nil, nil)
|
||||||
|
|
||||||
return "/dev/sdb", nil
|
return "/dev/sdb", nil
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ func (m *localVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs)
|
|||||||
|
|
||||||
klog.V(4).Infof("attempting to mount %s", dir)
|
klog.V(4).Infof("attempting to mount %s", dir)
|
||||||
globalPath := util.MakeAbsolutePath(runtime.GOOS, m.globalPath)
|
globalPath := util.MakeAbsolutePath(runtime.GOOS, m.globalPath)
|
||||||
err = m.mounter.Mount(globalPath, dir, "", mountOptions)
|
err = m.mounter.MountSensitiveWithoutSystemd(globalPath, dir, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Mount of volume %s failed: %v", dir, err)
|
klog.Errorf("Mount of volume %s failed: %v", dir, err)
|
||||||
notMnt, mntErr := mount.IsNotMountPoint(m.mounter, dir)
|
notMnt, mntErr := mount.IsNotMountPoint(m.mounter, dir)
|
||||||
|
@ -259,7 +259,7 @@ func (nfsMounter *nfsMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs
|
|||||||
options = append(options, "ro")
|
options = append(options, "ro")
|
||||||
}
|
}
|
||||||
mountOptions := util.JoinMountOptions(nfsMounter.mountOptions, options)
|
mountOptions := util.JoinMountOptions(nfsMounter.mountOptions, options)
|
||||||
err = nfsMounter.mounter.Mount(source, dir, "nfs", mountOptions)
|
err = nfsMounter.mounter.MountSensitiveWithoutSystemd(source, dir, "nfs", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notMnt, mntErr := mount.IsNotMountPoint(nfsMounter.mounter, dir)
|
notMnt, mntErr := mount.IsNotMountPoint(nfsMounter.mounter, dir)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
@ -259,7 +259,7 @@ func (mounter *quobyteMounter) SetUpAt(dir string, mounterArgs volume.MounterArg
|
|||||||
|
|
||||||
//if a trailing slash is missing we add it here
|
//if a trailing slash is missing we add it here
|
||||||
mountOptions := util.JoinMountOptions(mounter.mountOptions, options)
|
mountOptions := util.JoinMountOptions(mounter.mountOptions, options)
|
||||||
if err := mounter.mounter.Mount(mounter.correctTraillingSlash(mounter.registry), dir, "quobyte", mountOptions); err != nil {
|
if err := mounter.mounter.MountSensitiveWithoutSystemd(mounter.correctTraillingSlash(mounter.registry), dir, "quobyte", mountOptions, nil); err != nil {
|
||||||
return fmt.Errorf("quobyte: mount failed: %v", err)
|
return fmt.Errorf("quobyte: mount failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ func (b *storageosMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs) e
|
|||||||
globalPDPath := makeGlobalPDName(b.plugin.host, b.pvName, b.volNamespace, b.volName)
|
globalPDPath := makeGlobalPDName(b.plugin.host, b.pvName, b.volNamespace, b.volName)
|
||||||
klog.V(4).Infof("Attempting to bind mount to pod volume at %s", dir)
|
klog.V(4).Infof("Attempting to bind mount to pod volume at %s", dir)
|
||||||
|
|
||||||
err = b.mounter.Mount(globalPDPath, dir, "", mountOptions)
|
err = b.mounter.MountSensitiveWithoutSystemd(globalPDPath, dir, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
notMnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
@ -210,7 +210,7 @@ func doBindSubPath(mounter mount.Interface, subpath Subpath) (hostPath string, e
|
|||||||
// Do the bind mount
|
// Do the bind mount
|
||||||
options := []string{"bind"}
|
options := []string{"bind"}
|
||||||
klog.V(5).Infof("bind mounting %q at %q", mountSource, bindPathTarget)
|
klog.V(5).Infof("bind mounting %q at %q", mountSource, bindPathTarget)
|
||||||
if err = mounter.Mount(mountSource, bindPathTarget, "" /*fstype*/, options); err != nil {
|
if err = mounter.MountSensitiveWithoutSystemd(mountSource, bindPathTarget, "" /*fstype*/, options, nil); err != nil {
|
||||||
return "", fmt.Errorf("error mounting %s: %s", subpath.Path, err)
|
return "", fmt.Errorf("error mounting %s: %s", subpath.Path, err)
|
||||||
}
|
}
|
||||||
success = true
|
success = true
|
||||||
|
@ -141,7 +141,7 @@ func mapBindMountDevice(v VolumePathHandler, devicePath string, mapPath string,
|
|||||||
|
|
||||||
// Bind mount file
|
// Bind mount file
|
||||||
mounter := &mount.SafeFormatAndMount{Interface: mount.New(""), Exec: utilexec.New()}
|
mounter := &mount.SafeFormatAndMount{Interface: mount.New(""), Exec: utilexec.New()}
|
||||||
if err := mounter.Mount(devicePath, linkPath, "" /* fsType */, []string{"bind"}); err != nil {
|
if err := mounter.MountSensitiveWithoutSystemd(devicePath, linkPath, "" /* fsType */, []string{"bind"}, nil); err != nil {
|
||||||
return fmt.Errorf("failed to bind mount devicePath: %s to linkPath %s: %v", devicePath, linkPath, err)
|
return fmt.Errorf("failed to bind mount devicePath: %s to linkPath %s: %v", devicePath, linkPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ func (b *vsphereVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArg
|
|||||||
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
|
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
|
||||||
globalPDPath := makeGlobalPDPath(b.plugin.host, b.volPath)
|
globalPDPath := makeGlobalPDPath(b.plugin.host, b.volPath)
|
||||||
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
mountOptions := util.JoinMountOptions(options, b.mountOptions)
|
||||||
err = b.mounter.Mount(globalPDPath, dir, "", mountOptions)
|
err = b.mounter.MountSensitiveWithoutSystemd(globalPDPath, dir, "", mountOptions, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||||
if mntErr != nil {
|
if mntErr != nil {
|
||||||
|
@ -132,6 +132,10 @@ func (f *FakeMounter) MountSensitive(source string, target string, fstype string
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FakeMounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
||||||
|
return f.MountSensitive(source, target, fstype, options, nil /* sensitiveOptions */)
|
||||||
|
}
|
||||||
|
|
||||||
// Unmount records the unmount event and updates the in-memory mount points for FakeMounter
|
// Unmount records the unmount event and updates the in-memory mount points for FakeMounter
|
||||||
func (f *FakeMounter) Unmount(target string) error {
|
func (f *FakeMounter) Unmount(target string) error {
|
||||||
f.mutex.Lock()
|
f.mutex.Lock()
|
||||||
|
@ -46,6 +46,8 @@ type Interface interface {
|
|||||||
// method should be used by callers that pass sensitive material (like
|
// method should be used by callers that pass sensitive material (like
|
||||||
// passwords) as mount options.
|
// passwords) as mount options.
|
||||||
MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error
|
MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error
|
||||||
|
// MountSensitiveWithoutSystemd is the same as MountSensitive() but this method disable using systemd mount.
|
||||||
|
MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error
|
||||||
// Unmount unmounts given target.
|
// Unmount unmounts given target.
|
||||||
Unmount(target string) error
|
Unmount(target string) error
|
||||||
// List returns a list of all mounted filesystems. This can be large.
|
// List returns a list of all mounted filesystems. This can be large.
|
||||||
|
@ -83,11 +83,11 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
|
|||||||
mounterPath := ""
|
mounterPath := ""
|
||||||
bind, bindOpts, bindRemountOpts, bindRemountOptsSensitive := MakeBindOptsSensitive(options, sensitiveOptions)
|
bind, bindOpts, bindRemountOpts, bindRemountOptsSensitive := MakeBindOptsSensitive(options, sensitiveOptions)
|
||||||
if bind {
|
if bind {
|
||||||
err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts, bindRemountOptsSensitive)
|
err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts, bindRemountOptsSensitive, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindRemountOpts, bindRemountOptsSensitive)
|
return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindRemountOpts, bindRemountOptsSensitive, true)
|
||||||
}
|
}
|
||||||
// The list of filesystems that require containerized mounter on GCI image cluster
|
// The list of filesystems that require containerized mounter on GCI image cluster
|
||||||
fsTypesNeedMounter := map[string]struct{}{
|
fsTypesNeedMounter := map[string]struct{}{
|
||||||
@ -99,12 +99,37 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
|
|||||||
if _, ok := fsTypesNeedMounter[fstype]; ok {
|
if _, ok := fsTypesNeedMounter[fstype]; ok {
|
||||||
mounterPath = mounter.mounterPath
|
mounterPath = mounter.mounterPath
|
||||||
}
|
}
|
||||||
return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, options, sensitiveOptions)
|
return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, options, sensitiveOptions, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MountSensitiveWithoutSystemd is the same as MountSensitive() but disable using systemd mount.
|
||||||
|
func (mounter *Mounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
||||||
|
mounterPath := ""
|
||||||
|
bind, bindOpts, bindRemountOpts, bindRemountOptsSensitive := MakeBindOptsSensitive(options, sensitiveOptions)
|
||||||
|
if bind {
|
||||||
|
err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts, bindRemountOptsSensitive, false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindRemountOpts, bindRemountOptsSensitive, false)
|
||||||
|
}
|
||||||
|
// The list of filesystems that require containerized mounter on GCI image cluster
|
||||||
|
fsTypesNeedMounter := map[string]struct{}{
|
||||||
|
"nfs": {},
|
||||||
|
"glusterfs": {},
|
||||||
|
"ceph": {},
|
||||||
|
"cifs": {},
|
||||||
|
}
|
||||||
|
if _, ok := fsTypesNeedMounter[fstype]; ok {
|
||||||
|
mounterPath = mounter.mounterPath
|
||||||
|
}
|
||||||
|
return mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, options, sensitiveOptions, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// doMount runs the mount command. mounterPath is the path to mounter binary if containerized mounter is used.
|
// doMount runs the mount command. mounterPath is the path to mounter binary if containerized mounter is used.
|
||||||
// sensitiveOptions is an extension of options except they will not be logged (because they may contain sensitive material)
|
// sensitiveOptions is an extension of options except they will not be logged (because they may contain sensitive material)
|
||||||
func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
// systemdMountRequired is an extension of option to decide whether uses systemd mount.
|
||||||
|
func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source string, target string, fstype string, options []string, sensitiveOptions []string, systemdMountRequired bool) error {
|
||||||
mountArgs, mountArgsLogStr := MakeMountArgsSensitive(source, target, fstype, options, sensitiveOptions)
|
mountArgs, mountArgsLogStr := MakeMountArgsSensitive(source, target, fstype, options, sensitiveOptions)
|
||||||
if len(mounterPath) > 0 {
|
if len(mounterPath) > 0 {
|
||||||
mountArgs = append([]string{mountCmd}, mountArgs...)
|
mountArgs = append([]string{mountCmd}, mountArgs...)
|
||||||
@ -112,7 +137,7 @@ func (mounter *Mounter) doMount(mounterPath string, mountCmd string, source stri
|
|||||||
mountCmd = mounterPath
|
mountCmd = mounterPath
|
||||||
}
|
}
|
||||||
|
|
||||||
if mounter.withSystemd {
|
if mounter.withSystemd && systemdMountRequired {
|
||||||
// Try to run mount via systemd-run --scope. This will escape the
|
// Try to run mount via systemd-run --scope. This will escape the
|
||||||
// service where kubelet runs and any fuse daemons will be started in a
|
// service where kubelet runs and any fuse daemons will be started in a
|
||||||
// specific scope. kubelet service than can be restarted without killing
|
// specific scope. kubelet service than can be restarted without killing
|
||||||
|
@ -43,11 +43,16 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
|
|||||||
return errUnsupported
|
return errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount always returns an error on unsupported platforms
|
// MountSensitive always returns an error on unsupported platforms
|
||||||
func (mounter *Mounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
func (mounter *Mounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
||||||
return errUnsupported
|
return errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MountSensitiveWithoutSystemd always returns an error on unsupported platforms
|
||||||
|
func (mounter *Mounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
||||||
|
return errUnsupported
|
||||||
|
}
|
||||||
|
|
||||||
// Unmount always returns an error on unsupported platforms
|
// Unmount always returns an error on unsupported platforms
|
||||||
func (mounter *Mounter) Unmount(target string) error {
|
func (mounter *Mounter) Unmount(target string) error {
|
||||||
return errUnsupported
|
return errUnsupported
|
||||||
|
@ -54,6 +54,12 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
|
|||||||
return mounter.MountSensitive(source, target, fstype, options, nil /* sensitiveOptions */)
|
return mounter.MountSensitive(source, target, fstype, options, nil /* sensitiveOptions */)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MountSensitiveWithoutSystemd is the same as MountSensitive() but disable using ssytemd mount.
|
||||||
|
// Windows not supported systemd mount, this function degrades to MountSensitive().
|
||||||
|
func (mounter *Mounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error {
|
||||||
|
return mounter.MountSensitive(source, target, fstype, options, sensitiveOptions /* sensitiveOptions */)
|
||||||
|
}
|
||||||
|
|
||||||
// MountSensitive is the same as Mount() but this method allows
|
// MountSensitive is the same as Mount() but this method allows
|
||||||
// sensitiveOptions to be passed in a separate parameter from the normal
|
// sensitiveOptions to be passed in a separate parameter from the normal
|
||||||
// mount options and ensures the sensitiveOptions are never logged. This
|
// mount options and ensures the sensitiveOptions are never logged. This
|
||||||
|
Loading…
Reference in New Issue
Block a user