mirror of https://github.com/k3s-io/k3s
Move MountsInGlobalPDPath from mount pkg to volume
Since pkg/util/mount is going to move out of k/k, this exported constant that is Kubernetes specific needed to move somewhere else. Made sense to move it to pkg/volume/util. Update GetDeviceNameFromMount in the mount interface to now take a pluginMountDir argument, which is volume plugin dir with the global mount path appended to it already.k3s-v1.15.3
parent
855c291cb8
commit
12b7f1450c
|
@ -182,8 +182,8 @@ func (f *FakeMounter) PathIsDevice(pathname string) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeMounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (f *FakeMounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return getDeviceNameFromMount(f, mountPath, pluginDir)
|
return getDeviceNameFromMount(f, mountPath, pluginMountDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeMounter) MakeRShared(path string) error {
|
func (f *FakeMounter) MakeRShared(path string) error {
|
||||||
|
|
|
@ -29,13 +29,12 @@ type FileType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Default mount command if mounter path is not specified
|
// Default mount command if mounter path is not specified
|
||||||
defaultMountCommand = "mount"
|
defaultMountCommand = "mount"
|
||||||
MountsInGlobalPDPath = "mounts"
|
FileTypeDirectory FileType = "Directory"
|
||||||
FileTypeDirectory FileType = "Directory"
|
FileTypeFile FileType = "File"
|
||||||
FileTypeFile FileType = "File"
|
FileTypeSocket FileType = "Socket"
|
||||||
FileTypeSocket FileType = "Socket"
|
FileTypeCharDev FileType = "CharDevice"
|
||||||
FileTypeCharDev FileType = "CharDevice"
|
FileTypeBlockDev FileType = "BlockDevice"
|
||||||
FileTypeBlockDev FileType = "BlockDevice"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
|
@ -62,8 +61,8 @@ type Interface interface {
|
||||||
// PathIsDevice determines if a path is a device.
|
// PathIsDevice determines if a path is a device.
|
||||||
PathIsDevice(pathname string) (bool, error)
|
PathIsDevice(pathname string) (bool, error)
|
||||||
// GetDeviceNameFromMount finds the device name by checking the mount path
|
// GetDeviceNameFromMount finds the device name by checking the mount path
|
||||||
// to get the global mount path which matches its plugin directory
|
// to get the global mount path within its plugin directory
|
||||||
GetDeviceNameFromMount(mountPath, pluginDir string) (string, error)
|
GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error)
|
||||||
// MakeRShared checks that given path is on a mount with 'rshared' mount
|
// MakeRShared checks that given path is on a mount with 'rshared' mount
|
||||||
// propagation. If not, it bind-mounts the path as rshared.
|
// propagation. If not, it bind-mounts the path as rshared.
|
||||||
MakeRShared(path string) error
|
MakeRShared(path string) error
|
||||||
|
|
|
@ -304,19 +304,19 @@ func ExclusiveOpenFailsOnDevice(pathname string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetDeviceNameFromMount: given a mount point, find the device name from its global mount point
|
//GetDeviceNameFromMount: given a mount point, find the device name from its global mount point
|
||||||
func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return GetDeviceNameFromMountLinux(mounter, mountPath, pluginDir)
|
return GetDeviceNameFromMountLinux(mounter, mountPath, pluginMountDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) {
|
func getDeviceNameFromMount(mounter Interface, mountPath, pluginMountDir string) (string, error) {
|
||||||
return GetDeviceNameFromMountLinux(mounter, mountPath, pluginDir)
|
return GetDeviceNameFromMountLinux(mounter, mountPath, pluginMountDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceNameFromMountLinux find the device name from /proc/mounts in which
|
// GetDeviceNameFromMountLinux find the device name from /proc/mounts in which
|
||||||
// the mount path reference should match the given plugin directory. In case no mount path reference
|
// the mount path reference should match the given plugin mount directory. In case no mount path reference
|
||||||
// matches, returns the volume name taken from its given mountPath
|
// matches, returns the volume name taken from its given mountPath
|
||||||
// This implementation is shared with NsEnterMounter
|
// This implementation is shared with NsEnterMounter
|
||||||
func GetDeviceNameFromMountLinux(mounter Interface, mountPath, pluginDir string) (string, error) {
|
func GetDeviceNameFromMountLinux(mounter Interface, mountPath, pluginMountDir string) (string, error) {
|
||||||
refs, err := mounter.GetMountRefs(mountPath)
|
refs, err := mounter.GetMountRefs(mountPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err)
|
klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err)
|
||||||
|
@ -326,10 +326,9 @@ func GetDeviceNameFromMountLinux(mounter Interface, mountPath, pluginDir string)
|
||||||
klog.V(4).Infof("Directory %s is not mounted", mountPath)
|
klog.V(4).Infof("Directory %s is not mounted", mountPath)
|
||||||
return "", fmt.Errorf("directory %s is not mounted", mountPath)
|
return "", fmt.Errorf("directory %s is not mounted", mountPath)
|
||||||
}
|
}
|
||||||
basemountPath := path.Join(pluginDir, MountsInGlobalPDPath)
|
|
||||||
for _, ref := range refs {
|
for _, ref := range refs {
|
||||||
if strings.HasPrefix(ref, basemountPath) {
|
if strings.HasPrefix(ref, pluginMountDir) {
|
||||||
volumeID, err := filepath.Rel(basemountPath, ref)
|
volumeID, err := filepath.Rel(pluginMountDir, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err)
|
klog.Errorf("Failed to get volume id from mount %s - %v", mountPath, err)
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
@ -58,11 +58,11 @@ func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||||
return true, unsupportedErr
|
return true, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return "", unsupportedErr
|
return "", unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) {
|
func getDeviceNameFromMount(mounter Interface, mountPath, pluginMountDir string) (string, error) {
|
||||||
return "", unsupportedErr
|
return "", unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,14 +196,14 @@ func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceNameFromMount given a mnt point, find the device
|
// GetDeviceNameFromMount given a mnt point, find the device
|
||||||
func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return getDeviceNameFromMount(mounter, mountPath, pluginDir)
|
return getDeviceNameFromMount(mounter, mountPath, pluginMountDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDeviceNameFromMount find the device(drive) name in which
|
// getDeviceNameFromMount find the device(drive) name in which
|
||||||
// the mount path reference should match the given plugin directory. In case no mount path reference
|
// the mount path reference should match the given plugin mount directory. In case no mount path reference
|
||||||
// matches, returns the volume name taken from its given mountPath
|
// matches, returns the volume name taken from its given mountPath
|
||||||
func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (string, error) {
|
func getDeviceNameFromMount(mounter Interface, mountPath, pluginMountDir string) (string, error) {
|
||||||
refs, err := mounter.GetMountRefs(mountPath)
|
refs, err := mounter.GetMountRefs(mountPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err)
|
klog.V(4).Infof("GetMountRefs failed for mount path %q: %v", mountPath, err)
|
||||||
|
@ -212,7 +212,7 @@ func getDeviceNameFromMount(mounter Interface, mountPath, pluginDir string) (str
|
||||||
if len(refs) == 0 {
|
if len(refs) == 0 {
|
||||||
return "", fmt.Errorf("directory %s is not mounted", mountPath)
|
return "", fmt.Errorf("directory %s is not mounted", mountPath)
|
||||||
}
|
}
|
||||||
basemountPath := normalizeWindowsPath(path.Join(pluginDir, MountsInGlobalPDPath))
|
basemountPath := normalizeWindowsPath(pluginMountDir)
|
||||||
for _, ref := range refs {
|
for _, ref := range refs {
|
||||||
if strings.Contains(ref, basemountPath) {
|
if strings.Contains(ref, basemountPath) {
|
||||||
volumeID, err := filepath.Rel(normalizeWindowsPath(basemountPath), ref)
|
volumeID, err := filepath.Rel(normalizeWindowsPath(basemountPath), ref)
|
||||||
|
|
|
@ -250,8 +250,8 @@ func getVolumeSource(
|
||||||
|
|
||||||
func (plugin *awsElasticBlockStorePlugin) ConstructVolumeSpec(volName, mountPath string) (*volume.Spec, error) {
|
func (plugin *awsElasticBlockStorePlugin) ConstructVolumeSpec(volName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
volumeID, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
volumeID, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ func makeGlobalPDPath(host volume.VolumeHost, volumeID aws.KubernetesVolumeID) s
|
||||||
// Clean up the URI to be more fs-friendly
|
// Clean up the URI to be more fs-friendly
|
||||||
name := string(volumeID)
|
name := string(volumeID)
|
||||||
name = strings.Replace(name, "://", "/", -1)
|
name = strings.Replace(name, "://", "/", -1)
|
||||||
return filepath.Join(host.GetPluginDir(awsElasticBlockStorePluginName), mount.MountsInGlobalPDPath, name)
|
return filepath.Join(host.GetPluginDir(awsElasticBlockStorePluginName), util.MountsInGlobalPDPath, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ebs *awsElasticBlockStore) GetPath() string {
|
func (ebs *awsElasticBlockStore) GetPath() string {
|
||||||
|
|
|
@ -199,7 +199,7 @@ func (a *azureDiskAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error
|
||||||
}
|
}
|
||||||
|
|
||||||
if volumeSource.Kind == nil { // this spec was constructed from info on the node
|
if volumeSource.Kind == nil { // this spec was constructed from info on the node
|
||||||
pdPath := filepath.Join(a.plugin.host.GetPluginDir(azureDataDiskPluginName), mount.MountsInGlobalPDPath, volumeSource.DataDiskURI)
|
pdPath := filepath.Join(a.plugin.host.GetPluginDir(azureDataDiskPluginName), util.MountsInGlobalPDPath, volumeSource.DataDiskURI)
|
||||||
return pdPath, nil
|
return pdPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
|
"k8s.io/kubernetes/pkg/volume/util"
|
||||||
"k8s.io/legacy-cloud-providers/azure"
|
"k8s.io/legacy-cloud-providers/azure"
|
||||||
utilstrings "k8s.io/utils/strings"
|
utilstrings "k8s.io/utils/strings"
|
||||||
)
|
)
|
||||||
|
@ -80,7 +80,7 @@ func makeGlobalPDPath(host volume.VolumeHost, diskUri string, isManaged bool) (s
|
||||||
}
|
}
|
||||||
// "{m for managed b for blob}{hashed diskUri or DiskId depending on disk kind }"
|
// "{m for managed b for blob}{hashed diskUri or DiskId depending on disk kind }"
|
||||||
diskName := fmt.Sprintf(uniqueDiskNameTemplate, prefix, hashedDiskUri)
|
diskName := fmt.Sprintf(uniqueDiskNameTemplate, prefix, hashedDiskUri)
|
||||||
pdPath := filepath.Join(host.GetPluginDir(azureDataDiskPluginName), mount.MountsInGlobalPDPath, diskName)
|
pdPath := filepath.Join(host.GetPluginDir(azureDataDiskPluginName), util.MountsInGlobalPDPath, diskName)
|
||||||
|
|
||||||
return pdPath, nil
|
return pdPath, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,8 +328,8 @@ var _ volume.NodeExpandableVolumePlugin = &azureDataDiskPlugin{}
|
||||||
|
|
||||||
func (plugin *azureDataDiskPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
func (plugin *azureDataDiskPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -266,8 +266,8 @@ func (plugin *cinderPlugin) getCloudProvider() (BlockStorageProvider, error) {
|
||||||
|
|
||||||
func (plugin *cinderPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
func (plugin *cinderPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeGlobalPDName(host volume.VolumeHost, devName string) string {
|
func makeGlobalPDName(host volume.VolumeHost, devName string) string {
|
||||||
return path.Join(host.GetPluginDir(cinderVolumePluginName), mount.MountsInGlobalPDPath, devName)
|
return path.Join(host.GetPluginDir(cinderVolumePluginName), util.MountsInGlobalPDPath, devName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cd *cinderVolume) GetPath() string {
|
func (cd *cinderVolume) GetPath() string {
|
||||||
|
|
|
@ -302,8 +302,8 @@ var _ volume.NodeExpandableVolumePlugin = &gcePersistentDiskPlugin{}
|
||||||
|
|
||||||
func (plugin *gcePersistentDiskPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
func (plugin *gcePersistentDiskPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeGlobalPDName(host volume.VolumeHost, devName string) string {
|
func makeGlobalPDName(host volume.VolumeHost, devName string) string {
|
||||||
return path.Join(host.GetPluginDir(gcePersistentDiskPluginName), mount.MountsInGlobalPDPath, devName)
|
return path.Join(host.GetPluginDir(gcePersistentDiskPluginName), util.MountsInGlobalPDPath, devName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *gcePersistentDiskMounter) GetPath() string {
|
func (b *gcePersistentDiskMounter) GetPath() string {
|
||||||
|
|
|
@ -222,7 +222,7 @@ func (plugin *localVolumePlugin) ConstructBlockVolumeSpec(podUID types.UID, volu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *localVolumePlugin) generateBlockDeviceBaseGlobalPath() string {
|
func (plugin *localVolumePlugin) generateBlockDeviceBaseGlobalPath() string {
|
||||||
return filepath.Join(plugin.host.GetPluginDir(localVolumePluginName), mount.MountsInGlobalPDPath)
|
return filepath.Join(plugin.host.GetPluginDir(localVolumePluginName), util.MountsInGlobalPDPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *localVolumePlugin) getGlobalLocalPath(spec *volume.Spec) (string, error) {
|
func (plugin *localVolumePlugin) getGlobalLocalPath(spec *volume.Spec) (string, error) {
|
||||||
|
|
|
@ -136,8 +136,8 @@ func (plugin *photonPersistentDiskPlugin) newUnmounterInternal(volName string, p
|
||||||
|
|
||||||
func (plugin *photonPersistentDiskPlugin) ConstructVolumeSpec(volumeSpecName, mountPath string) (*volume.Spec, error) {
|
func (plugin *photonPersistentDiskPlugin) ConstructVolumeSpec(volumeSpecName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
pdID, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
pdID, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ func (c *photonPersistentDiskUnmounter) TearDownAt(dir string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeGlobalPDPath(host volume.VolumeHost, devName string) string {
|
func makeGlobalPDPath(host volume.VolumeHost, devName string) string {
|
||||||
return path.Join(host.GetPluginDir(photonPersistentDiskPluginName), mount.MountsInGlobalPDPath, devName)
|
return path.Join(host.GetPluginDir(photonPersistentDiskPluginName), util.MountsInGlobalPDPath, devName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ppd *photonPersistentDisk) GetPath() string {
|
func (ppd *photonPersistentDisk) GetPath() string {
|
||||||
|
|
|
@ -374,8 +374,8 @@ func (plugin *rbdPlugin) newUnmounterInternal(volName string, podUID types.UID,
|
||||||
|
|
||||||
func (plugin *rbdPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
func (plugin *rbdPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := volutil.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
"k8s.io/kubernetes/pkg/util/node"
|
"k8s.io/kubernetes/pkg/util/node"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
|
volutil "k8s.io/kubernetes/pkg/volume/util"
|
||||||
utilpath "k8s.io/utils/path"
|
utilpath "k8s.io/utils/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -255,7 +256,7 @@ func makePDNameInternal(host volume.VolumeHost, pool string, image string) strin
|
||||||
return deprecatedDir
|
return deprecatedDir
|
||||||
}
|
}
|
||||||
// Return the canonical format path.
|
// Return the canonical format path.
|
||||||
return path.Join(host.GetPluginDir(rbdPluginName), mount.MountsInGlobalPDPath, pool+"-image-"+image)
|
return path.Join(host.GetPluginDir(rbdPluginName), volutil.MountsInGlobalPDPath, pool+"-image-"+image)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a directory like /var/lib/kubelet/plugins/kubernetes.io/rbd/volumeDevices/pool-image-image.
|
// Make a directory like /var/lib/kubelet/plugins/kubernetes.io/rbd/volumeDevices/pool-image-image.
|
||||||
|
|
|
@ -441,7 +441,7 @@ func (b *storageosMounter) SetUpAt(dir string, fsGroup *int64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeGlobalPDName(host volume.VolumeHost, pvName, volNamespace, volName string) string {
|
func makeGlobalPDName(host volume.VolumeHost, pvName, volNamespace, volName string) string {
|
||||||
return path.Join(host.GetPluginDir(utilstrings.EscapeQualifiedName(storageosPluginName)), mount.MountsInGlobalPDPath, pvName+"."+volNamespace+"."+volName)
|
return path.Join(host.GetPluginDir(utilstrings.EscapeQualifiedName(storageosPluginName)), util.MountsInGlobalPDPath, pvName+"."+volNamespace+"."+volName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given the pod id and PV name, finds the volume's namespace and name from the
|
// Given the pod id and PV name, finds the volume's namespace and name from the
|
||||||
|
|
|
@ -112,8 +112,8 @@ func (m *execMounter) PathIsDevice(pathname string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetDeviceNameFromMount given a mount point, find the volume id from checking /proc/mounts
|
//GetDeviceNameFromMount given a mount point, find the volume id from checking /proc/mounts
|
||||||
func (m *execMounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (m *execMounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return m.wrappedMounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
return m.wrappedMounter.GetDeviceNameFromMount(mountPath, pluginMountDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *execMounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool {
|
func (m *execMounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool {
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (mounter *execMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mounter *execMounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (mounter *execMounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,8 +228,8 @@ func (n *Mounter) PathIsDevice(pathname string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetDeviceNameFromMount given a mount point, find the volume id from checking /proc/mounts
|
//GetDeviceNameFromMount given a mount point, find the volume id from checking /proc/mounts
|
||||||
func (n *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (n *Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return mount.GetDeviceNameFromMountLinux(n, mountPath, pluginDir)
|
return mount.GetDeviceNameFromMountLinux(n, mountPath, pluginMountDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeRShared checks if path is shared and bind-mounts it as rshared if needed.
|
// MakeRShared checks if path is shared and bind-mounts it as rshared if needed.
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (*Mounter) PathIsDevice(pathname string) (bool, error) {
|
||||||
|
|
||||||
// GetDeviceNameFromMount finds the device name from its global mount point using the
|
// GetDeviceNameFromMount finds the device name from its global mount point using the
|
||||||
// given mountpath and plugin location. It is a noop of unsupported platforms
|
// given mountpath and plugin location. It is a noop of unsupported platforms
|
||||||
func (*Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (string, error) {
|
func (*Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,10 @@ const (
|
||||||
// that decides if pod volumes are unmounted when pod is terminated
|
// that decides if pod volumes are unmounted when pod is terminated
|
||||||
KeepTerminatedPodVolumesAnnotation string = "volumes.kubernetes.io/keep-terminated-pod-volumes"
|
KeepTerminatedPodVolumesAnnotation string = "volumes.kubernetes.io/keep-terminated-pod-volumes"
|
||||||
|
|
||||||
|
// MountsInGlobalPDPath is name of the directory appended to a volume plugin
|
||||||
|
// name to create the place for volume mounts in the global PD path.
|
||||||
|
MountsInGlobalPDPath = "mounts"
|
||||||
|
|
||||||
// VolumeGidAnnotationKey is the of the annotation on the PersistentVolume
|
// VolumeGidAnnotationKey is the of the annotation on the PersistentVolume
|
||||||
// object that specifies a supplemental GID.
|
// object that specifies a supplemental GID.
|
||||||
VolumeGidAnnotationKey = "pv.beta.kubernetes.io/gid"
|
VolumeGidAnnotationKey = "pv.beta.kubernetes.io/gid"
|
||||||
|
@ -530,3 +534,10 @@ func MapBlockVolume(
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPluginMountDir returns the global mount directory name appended
|
||||||
|
// to the given plugin name's plugin directory
|
||||||
|
func GetPluginMountDir(host volume.VolumeHost, name string) string {
|
||||||
|
mntDir := filepath.Join(host.GetPluginDir(name), MountsInGlobalPDPath)
|
||||||
|
return mntDir
|
||||||
|
}
|
||||||
|
|
|
@ -145,8 +145,8 @@ func (plugin *vsphereVolumePlugin) newUnmounterInternal(volName string, podUID t
|
||||||
|
|
||||||
func (plugin *vsphereVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
func (plugin *vsphereVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
|
||||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||||
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
|
pluginMntDir := util.GetPluginMountDir(plugin.host, plugin.GetPluginName())
|
||||||
volumePath, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
|
volumePath, err := mounter.GetDeviceNameFromMount(mountPath, pluginMntDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ func (v *vsphereVolumeUnmounter) TearDownAt(dir string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeGlobalPDPath(host volume.VolumeHost, devName string) string {
|
func makeGlobalPDPath(host volume.VolumeHost, devName string) string {
|
||||||
return path.Join(host.GetPluginDir(vsphereVolumePluginName), mount.MountsInGlobalPDPath, devName)
|
return path.Join(host.GetPluginDir(vsphereVolumePluginName), util.MountsInGlobalPDPath, devName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vv *vsphereVolume) GetPath() string {
|
func (vv *vsphereVolume) GetPath() string {
|
||||||
|
|
Loading…
Reference in New Issue