Documentation ¶
Overview ¶
Package osutils provides methods to perform os specific operations
Index ¶
- Constants
- func GetMounter(ctx context.Context, osUtils *OsUtils) (mounter.CSIProxyMounter, error)
- type Device
- type NodePublishParams
- type NodeStageParams
- type OsUtils
- func (osUtils *OsUtils) CleanupPublishPath(ctx context.Context, target string, volID string) error
- func (osUtils *OsUtils) CleanupStagePath(ctx context.Context, stagingTarget string, volID string) error
- func (osUtils *OsUtils) ConvertUUID(uuid string) (string, error)
- func (osUtils *OsUtils) EnsureMountVol(ctx context.Context, log *zap.SugaredLogger, volCap *csi.VolumeCapability) (string, []string, error)
- func (osUtils *OsUtils) GetBlockSizeBytes(ctx context.Context, devicePath string) (int64, error)
- func (osUtils *OsUtils) GetDevFromMount(ctx context.Context, target string) (*Device, error)
- func (osUtils *OsUtils) GetDevice(ctx context.Context, path string) (*Device, error)
- func (osUtils *OsUtils) GetDiskID(pubCtx map[string]string, log *zap.SugaredLogger) (string, error)
- func (osUtils *OsUtils) GetMetrics(ctx context.Context, path string) (*k8svol.Metrics, error)
- func (osUtils *OsUtils) GetSystemUUID(ctx context.Context) (string, error)
- func (osUtils *OsUtils) GetVolumeCapabilityFsType(ctx context.Context, capability *csi.VolumeCapability) string
- func (osUtils *OsUtils) IsTargetInMounts(ctx context.Context, path string) (bool, error)
- func (osUtils *OsUtils) NodeStageBlockVolume(ctx context.Context, req *csi.NodeStageVolumeRequest, params NodeStageParams) (*csi.NodeStageVolumeResponse, error)
- func (osUtils *OsUtils) PreparePublishPath(ctx context.Context, path string) error
- func (osUtils *OsUtils) PublishBlockVol(ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, ...) (*csi.NodePublishVolumeResponse, error)
- func (osUtils *OsUtils) PublishFileVol(ctx context.Context, req *csi.NodePublishVolumeRequest, ...) (*csi.NodePublishVolumeResponse, error)
- func (osUtils *OsUtils) PublishMountVol(ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, ...) (*csi.NodePublishVolumeResponse, error)
- func (osUtils *OsUtils) RescanDevice(ctx context.Context, dev *Device) error
- func (osUtils *OsUtils) ResizeVolume(ctx context.Context, devicePath, volumePath string, reqVolSizeBytes int64) error
- func (osUtils *OsUtils) ShouldContinue(ctx context.Context)
- func (osUtils *OsUtils) VerifyTargetDir(ctx context.Context, target string, targetShouldExist bool) (bool, error)
- func (osUtils *OsUtils) VerifyVolumeAttachedAndFillParams(ctx context.Context, pubCtx map[string]string, params *NodePublishParams, ...) error
Constants ¶
const (
UUIDPrefix = "VMware-"
)
Variables ¶
This section is empty.
Functions ¶
func GetMounter ¶
Types ¶
type Device ¶
type Device struct { FullPath string // full path where device is mounted Name string // name of device RealDev string // in windows it represents volumeID and in linux it represents device path }
Device is a struct for holding details about a block device.
type NodePublishParams ¶
type NodePublishParams struct { // volID is the identifier for the underlying volume. VolID string // Target path is used to bind-mount a staged volume to the pod. Target string // Staging Target path is used to mount the volume to the node. StagingTarget string // diskID is the identifier for the disk. DiskID string // volumePath represents the sym-linked block volume full path. VolumePath string // device represents the actual path of the block volume. Device string // Read-only flag. Ro bool }
struct to hold params required for NodePublish operation
type NodeStageParams ¶
type NodeStageParams struct { // volID is the identifier for the underlying volume. VolID string // fsType is the file system type - ext3, ext4, nfs, nfs4. FsType string // Staging Target path is used to mount the volume to the node. StagingTarget string // Mount flags/options intended to be used while running the mount command. MntFlags []string // Read-only flag. Ro bool }
struct to hold params required for NodeStage operation
type OsUtils ¶
type OsUtils struct {
Mounter *mount.SafeFormatAndMount
}
func NewOsUtils ¶
NewOsUtils creates OsUtils with a linux specific mounter
func (*OsUtils) CleanupPublishPath ¶
CleanupPublishPath will unmount and remove publish path
func (*OsUtils) CleanupStagePath ¶
func (osUtils *OsUtils) CleanupStagePath(ctx context.Context, stagingTarget string, volID string) error
CleanupStagePath will unmount the volume from node and remove the stage directory
func (*OsUtils) ConvertUUID ¶
convertUUID helps convert UUID to vSphere format, for example, Input uuid: VMware-42 02 e9 7e 3d ad 2a 49-22 86 7f f9 89 c6 64 ef Returned uuid: 4202e97e-3dad-2a49-2286-7ff989c664ef
func (*OsUtils) EnsureMountVol ¶
func (osUtils *OsUtils) EnsureMountVol(ctx context.Context, log *zap.SugaredLogger, volCap *csi.VolumeCapability) (string, []string, error)
EnsureMountVol ensures that VolumeCapability has mount option and returns fstype, mount flags
func (*OsUtils) GetBlockSizeBytes ¶
GetBlockSizeBytes returns the Block size in bytes
func (*OsUtils) GetDevFromMount ¶
GetDevFromMount returns device info mounted on the target dir
func (*OsUtils) GetDevice ¶
GetDevice returns a Device struct with info about the given device, or an error if it doesn't exist or is not a block device.
func (*OsUtils) GetMetrics ¶
GetMetrics helps get volume metrics using k8s fsInfo strategy.
func (*OsUtils) GetSystemUUID ¶
GetSystemUUID returns the UUID used to identify node vm
func (*OsUtils) GetVolumeCapabilityFsType ¶
func (osUtils *OsUtils) GetVolumeCapabilityFsType(ctx context.Context, capability *csi.VolumeCapability) string
GetVolumeCapabilityFsType retrieves fstype from VolumeCapability. Defaults to nfs4 for file volume and ntfs for block volume when empty string is observed. This function also ignores default ext4 fstype supplied by external-provisioner when none is specified in the StorageClass
func (*OsUtils) IsTargetInMounts ¶
IsTargetInMounts checks if a path exists in the mounts this check is no op for windows
func (*OsUtils) NodeStageBlockVolume ¶
func (osUtils *OsUtils) NodeStageBlockVolume( ctx context.Context, req *csi.NodeStageVolumeRequest, params NodeStageParams) ( *csi.NodeStageVolumeResponse, error)
NodeStageBlockVolume mounts mount volume or file volume to staging target
func (*OsUtils) PreparePublishPath ¶
preparePublishPath - In case of windows, the publish code path creates a soft link from global stage path to the publish path. But kubelet creates the directory in advance. We work around this issue by deleting the publish path then recreating the link.
func (*OsUtils) PublishBlockVol ¶
func (osUtils *OsUtils) PublishBlockVol( ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, params NodePublishParams) ( *csi.NodePublishVolumeResponse, error)
PublishBlockVol mounts raw block device to publish target
func (*OsUtils) PublishFileVol ¶
func (osUtils *OsUtils) PublishFileVol( ctx context.Context, req *csi.NodePublishVolumeRequest, params NodePublishParams) ( *csi.NodePublishVolumeResponse, error)
PublishBlockVol mounts file volume to publish target
func (*OsUtils) PublishMountVol ¶
func (osUtils *OsUtils) PublishMountVol( ctx context.Context, req *csi.NodePublishVolumeRequest, dev *Device, params NodePublishParams) ( *csi.NodePublishVolumeResponse, error)
PublishBlockVol mounts block volume to publish target
func (*OsUtils) RescanDevice ¶
RescanDevice rescans the device
func (*OsUtils) ResizeVolume ¶
func (osUtils *OsUtils) ResizeVolume(ctx context.Context, devicePath, volumePath string, reqVolSizeBytes int64) error
ResizeVolume resizes the volume
func (*OsUtils) ShouldContinue ¶
decides if node should continue
func (*OsUtils) VerifyTargetDir ¶
func (osUtils *OsUtils) VerifyTargetDir(ctx context.Context, target string, targetShouldExist bool) (bool, error)
VerifyTargetDir checks if the target path is not empty, exists and is a directory. If targetShouldExist is set to false, then verifyTargetDir returns (false, nil) if the path does not exist. If targetShouldExist is set to true, then verifyTargetDir returns (false, err) if the path does not exist.
func (*OsUtils) VerifyVolumeAttachedAndFillParams ¶
func (osUtils *OsUtils) VerifyVolumeAttachedAndFillParams(ctx context.Context, pubCtx map[string]string, params *NodePublishParams, dev **Device) error
VerifyVolumeAttachedFillParams is a noop for windows