diff --git a/pkg/volume/metrics_block.go b/pkg/volume/metrics_block.go index e370afca24d..2376f468b6c 100644 --- a/pkg/volume/metrics_block.go +++ b/pkg/volume/metrics_block.go @@ -37,7 +37,7 @@ type metricsBlock struct { device string } -// NewMetricsStatfs creates a new metricsBlock with the device node of the +// NewMetricsBlock creates a new metricsBlock with the device node of the // Volume. func NewMetricsBlock(device string) MetricsProvider { return &metricsBlock{device} diff --git a/pkg/volume/metrics_errors.go b/pkg/volume/metrics_errors.go index 0f7987e0936..93858b1c065 100644 --- a/pkg/volume/metrics_errors.go +++ b/pkg/volume/metrics_errors.go @@ -23,7 +23,11 @@ import ( const ( // ErrCodeNotSupported code for NotSupported Errors. ErrCodeNotSupported int = iota + 1 + + // ErrCodeNoPathDefined code for NoPathDefined Errors. ErrCodeNoPathDefined + + // ErrCodeFsInfoFailed code for FsInfoFailed Errors. ErrCodeFsInfoFailed ) diff --git a/pkg/volume/metrics_statfs.go b/pkg/volume/metrics_statfs.go index 81a6748b19a..74b3a1fb774 100644 --- a/pkg/volume/metrics_statfs.go +++ b/pkg/volume/metrics_statfs.go @@ -34,7 +34,7 @@ type metricsStatFS struct { path string } -// NewMetricsStatfs creates a new metricsStatFS with the Volume path. +// NewMetricsStatFS creates a new metricsStatFS with the Volume path. func NewMetricsStatFS(path string) MetricsProvider { return &metricsStatFS{path} } diff --git a/pkg/volume/plugins.go b/pkg/volume/plugins.go index 8eea6f6ac26..de12664dc5e 100644 --- a/pkg/volume/plugins.go +++ b/pkg/volume/plugins.go @@ -44,7 +44,10 @@ import ( "k8s.io/kubernetes/pkg/volume/util/subpath" ) +// ProbeOperation represents a type of operation for probing volume plugins. type ProbeOperation uint32 + +// ProbeEvent represents an event triggered during a volume plugin probe operation. type ProbeEvent struct { Plugin VolumePlugin // VolumePlugin that was added/updated/removed. if ProbeEvent.Op is 'ProbeRemove', Plugin should be nil PluginName string @@ -52,17 +55,22 @@ type ProbeEvent struct { } const ( - // Common parameter which can be specified in StorageClass to specify the desired FSType + // VolumeParameterFSType is a common parameter which can be specified in StorageClass to specify the desired FSType // Provisioners SHOULD implement support for this if they are block device based // Must be a filesystem type supported by the host operating system. // Ex. "ext4", "xfs", "ntfs". Default value depends on the provisioner VolumeParameterFSType = "fstype" + // ProbeAddOrUpdate represents an operation where a probe is added or updated. ProbeAddOrUpdate ProbeOperation = 1 << iota + + // ProbeRemove represents an operation to remove a probe. + // This operation is used to indicate that a previously added probe should be removed. ProbeRemove ) -var ErrNoPluiginMatched = errors.New("no volume plugin matched") +// ErrNoPluginMatched is used to return when no volume plugin matches the requested type. +var ErrNoPluginMatched = errors.New("no volume plugin matched") // VolumeOptions contains option information about a volume. type VolumeOptions struct { @@ -108,6 +116,7 @@ type NodeResizeOptions struct { OldSize resource.Quantity } +// DynamicPluginProber is an interface that defines methods for probing dynamic volume plugins. type DynamicPluginProber interface { Init() error @@ -653,7 +662,7 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) { } if len(matchedPluginNames) == 0 { - return nil, ErrNoPluiginMatched + return nil, ErrNoPluginMatched } if len(matchedPluginNames) > 1 { return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ",")) @@ -730,7 +739,7 @@ func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVol return nil, fmt.Errorf("no persistent volume plugin matched") } -// FindPersistentPluginByName fetches a persistent volume plugin by name. If +// FindPersistentPluginByName fetches a recyclable persistent volume plugin by name. If // no plugin is found, returns error. func (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVolumePlugin, error) { volumePlugin, err := pm.FindPluginByName(name) @@ -743,7 +752,7 @@ func (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVo return nil, fmt.Errorf("no persistent volume plugin matched") } -// FindRecyclablePluginByName fetches a persistent volume plugin by name. If +// FindRecyclablePluginBySpec fetches a recyclable persistent volume plugin by spec. If // no plugin is found, returns error. func (pm *VolumePluginMgr) FindRecyclablePluginBySpec(spec *Spec) (RecyclableVolumePlugin, error) { volumePlugin, err := pm.FindPluginBySpec(spec) @@ -756,7 +765,7 @@ func (pm *VolumePluginMgr) FindRecyclablePluginBySpec(spec *Spec) (RecyclableVol return nil, fmt.Errorf("no recyclable volume plugin matched") } -// FindProvisionablePluginByName fetches a persistent volume plugin by name. If +// FindProvisionablePluginByName fetches a provisionable persistent volume plugin by name. If // no plugin is found, returns error. func (pm *VolumePluginMgr) FindProvisionablePluginByName(name string) (ProvisionableVolumePlugin, error) { volumePlugin, err := pm.FindPluginByName(name) @@ -769,7 +778,7 @@ func (pm *VolumePluginMgr) FindProvisionablePluginByName(name string) (Provision return nil, fmt.Errorf("no provisionable volume plugin matched") } -// FindDeletablePluginBySpec fetches a persistent volume plugin by spec. If +// FindDeletablePluginBySpec fetches a provisionable persistent volume plugin by spec. If // no plugin is found, returns error. func (pm *VolumePluginMgr) FindDeletablePluginBySpec(spec *Spec) (DeletableVolumePlugin, error) { volumePlugin, err := pm.FindPluginBySpec(spec) @@ -782,7 +791,7 @@ func (pm *VolumePluginMgr) FindDeletablePluginBySpec(spec *Spec) (DeletableVolum return nil, fmt.Errorf("no deletable volume plugin matched") } -// FindDeletablePluginByName fetches a persistent volume plugin by name. If +// FindDeletablePluginByName fetches a deleteable persistent volume plugin by name. If // no plugin is found, returns error. func (pm *VolumePluginMgr) FindDeletablePluginByName(name string) (DeletableVolumePlugin, error) { volumePlugin, err := pm.FindPluginByName(name) @@ -829,7 +838,7 @@ func (pm *VolumePluginMgr) FindAttachablePluginByName(name string) (AttachableVo return nil, nil } -// FindDeviceMountablePluginBySpec fetches a persistent volume plugin by spec. +// FindDeviceMountablePluginBySpec fetches a devicemountable persistent volume plugin by spec. func (pm *VolumePluginMgr) FindDeviceMountablePluginBySpec(spec *Spec) (DeviceMountableVolumePlugin, error) { volumePlugin, err := pm.FindPluginBySpec(spec) if err != nil { @@ -845,7 +854,7 @@ func (pm *VolumePluginMgr) FindDeviceMountablePluginBySpec(spec *Spec) (DeviceMo return nil, nil } -// FindDeviceMountablePluginByName fetches a devicemountable volume plugin by name. +// FindDeviceMountablePluginByName fetches a devicemountable persistent volume plugin by name. func (pm *VolumePluginMgr) FindDeviceMountablePluginByName(name string) (DeviceMountableVolumePlugin, error) { volumePlugin, err := pm.FindPluginByName(name) if err != nil { @@ -857,7 +866,7 @@ func (pm *VolumePluginMgr) FindDeviceMountablePluginByName(name string) (DeviceM return nil, nil } -// FindExpandablePluginBySpec fetches a persistent volume plugin by spec. +// FindExpandablePluginBySpec fetches an expandable persistent volume plugin by spec. func (pm *VolumePluginMgr) FindExpandablePluginBySpec(spec *Spec) (ExpandableVolumePlugin, error) { volumePlugin, err := pm.FindPluginBySpec(spec) if err != nil { @@ -867,7 +876,7 @@ func (pm *VolumePluginMgr) FindExpandablePluginBySpec(spec *Spec) (ExpandableVol klog.V(4).InfoS("FindExpandablePluginBySpec -> returning noopExpandableVolumePluginInstance", "specName", spec.Name()) return &noopExpandableVolumePluginInstance{spec}, nil } - if errors.Is(err, ErrNoPluiginMatched) { + if errors.Is(err, ErrNoPluginMatched) { return nil, nil } klog.V(4).InfoS("FindExpandablePluginBySpec -> err", "specName", spec.Name(), "err", err) @@ -880,7 +889,7 @@ func (pm *VolumePluginMgr) FindExpandablePluginBySpec(spec *Spec) (ExpandableVol return nil, nil } -// FindExpandablePluginBySpec fetches a persistent volume plugin by name. +// FindExpandablePluginByName fetches an expandable persistent volume plugin by name. func (pm *VolumePluginMgr) FindExpandablePluginByName(name string) (ExpandableVolumePlugin, error) { volumePlugin, err := pm.FindPluginByName(name) if err != nil { @@ -919,7 +928,7 @@ func (pm *VolumePluginMgr) FindMapperPluginByName(name string) (BlockVolumePlugi return nil, nil } -// FindNodeExpandablePluginBySpec fetches a persistent volume plugin by spec +// FindNodeExpandablePluginBySpec fetches a node expandable persistent volume plugin by spec func (pm *VolumePluginMgr) FindNodeExpandablePluginBySpec(spec *Spec) (NodeExpandableVolumePlugin, error) { volumePlugin, err := pm.FindPluginBySpec(spec) if err != nil { @@ -931,7 +940,7 @@ func (pm *VolumePluginMgr) FindNodeExpandablePluginBySpec(spec *Spec) (NodeExpan return nil, nil } -// FindNodeExpandablePluginByName fetches a persistent volume plugin by name +// FindNodeExpandablePluginByName fetches a node expandable persistent volume plugin by name func (pm *VolumePluginMgr) FindNodeExpandablePluginByName(name string) (NodeExpandableVolumePlugin, error) { volumePlugin, err := pm.FindPluginByName(name) if err != nil { @@ -945,6 +954,9 @@ func (pm *VolumePluginMgr) FindNodeExpandablePluginByName(name string) (NodeExpa return nil, nil } +// Run starts the volume plugin manager, initializing and running the necessary +// tasks for managing volume plugins. This method is typically called to begin +// the plugin management lifecycle. func (pm *VolumePluginMgr) Run(stopCh <-chan struct{}) { kletHost, ok := pm.Host.(KubeletVolumeHost) if ok { @@ -1007,7 +1019,7 @@ func NewPersistentVolumeRecyclerPodTemplate() *v1.Pod { return pod } -// Check validity of recycle pod template +// ValidateRecyclerPodTemplate checks validity of recycle pod template // List of checks: // - at least one volume is defined in the recycle pod template // If successful, returns nil diff --git a/pkg/volume/volume_unsupported.go b/pkg/volume/volume_unsupported.go index 3b5a200a616..4cef01bad8d 100644 --- a/pkg/volume/volume_unsupported.go +++ b/pkg/volume/volume_unsupported.go @@ -24,6 +24,8 @@ import ( "k8s.io/kubernetes/pkg/volume/util/types" ) +// SetVolumeOwnership sets the ownership of a volume to the specified user and group. +// It typically modifies the user and group ownership of the volume's file system. func SetVolumeOwnership(mounter Mounter, dir string, fsGroup *int64, fsGroupChangePolicy *v1.PodFSGroupChangePolicy, completeFunc func(types.CompleteFuncParam)) error { return nil }