Documentation ¶
Overview ¶
Package cache implements data structures used by the kubelet volume manager to keep track of attached volumes and the pods that mounted them.
Package cache implements data structures used by the kubelet volume manager to keep track of attached volumes and the pods that mounted them.
Index ¶
- func IsFSResizeRequiredError(err error) bool
- func IsRemountRequiredError(err error) bool
- func IsSELinuxMountMismatchError(err error) bool
- func IsVolumeNotAttachedError(err error) bool
- type ActualStateOfWorld
- type AttachedVolume
- type DesiredStateOfWorld
- type FsResizeRequiredError
- type MountedVolume
- type VolumeToMount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFSResizeRequiredError ¶ added in v1.11.0
IsFSResizeRequiredError returns true if the specified error is a fsResizeRequiredError.
func IsRemountRequiredError ¶
IsRemountRequiredError returns true if the specified error is a remountRequiredError.
func IsSELinuxMountMismatchError ¶ added in v1.25.0
IsSELinuxMountMismatchError returns true if the specified error is a seLinuxMountMismatchError.
func IsVolumeNotAttachedError ¶
IsVolumeNotAttachedError returns true if the specified error is a volumeNotAttachedError.
Types ¶
type ActualStateOfWorld ¶
type ActualStateOfWorld interface { // ActualStateOfWorld must implement the methods required to allow // operationexecutor to interact with it. operationexecutor.ActualStateOfWorldMounterUpdater // ActualStateOfWorld must implement the methods required to allow // operationexecutor to interact with it. operationexecutor.ActualStateOfWorldAttacherUpdater // AddPodToVolume adds the given pod to the given volume in the cache // indicating the specified volume has been successfully mounted to the // specified pod. // If a pod with the same unique name already exists under the specified // volume, reset the pod's remountRequired value. // If a volume with the name volumeName does not exist in the list of // attached volumes, an error is returned. AddPodToVolume(operationexecutor.MarkVolumeOpts) error // MarkRemountRequired marks each volume that is successfully attached and // mounted for the specified pod as requiring remount (if the plugin for the // volume indicates it requires remounting on pod updates). Atomically // updating volumes depend on this to update the contents of the volume on // pod update. MarkRemountRequired(podName volumetypes.UniquePodName) // SetDeviceMountState sets device mount state for the given volume. When deviceMountState is set to DeviceGloballyMounted // then device is mounted at a global mount point. When it is set to DeviceMountUncertain then also it means volume // MAY be globally mounted at a global mount point. In both cases - the volume must be unmounted from // global mount point prior to detach. // If a volume with the name volumeName does not exist in the list of // attached volumes, an error is returned. SetDeviceMountState(volumeName v1.UniqueVolumeName, deviceMountState operationexecutor.DeviceMountState, devicePath, deviceMountPath, seLinuxMountContext string) error // DeletePodFromVolume removes the given pod from the given volume in the // cache indicating the volume has been successfully unmounted from the pod. // If a pod with the same unique name does not exist under the specified // volume, this is a no-op. // If a volume with the name volumeName does not exist in the list of // attached volumes, an error is returned. DeletePodFromVolume(podName volumetypes.UniquePodName, volumeName v1.UniqueVolumeName) error // DeleteVolume removes the given volume from the list of attached volumes // in the cache indicating the volume has been successfully detached from // this node. // If a volume with the name volumeName does not exist in the list of // attached volumes, this is a no-op. // If a volume with the name volumeName exists and its list of mountedPods // is not empty, an error is returned. DeleteVolume(volumeName v1.UniqueVolumeName) error // PodExistsInVolume returns true if the given pod exists in the list of // mountedPods for the given volume in the cache, indicating that the volume // is attached to this node and the pod has successfully mounted it. // If a pod with the same unique name does not exist under the specified // volume, false is returned. // If a volume with the name volumeName does not exist in the list of // attached volumes, a volumeNotAttachedError is returned indicating the // given volume is not yet attached. // If the given volumeName/podName combo exists but the value of // remountRequired is true, a remountRequiredError is returned indicating // the given volume has been successfully mounted to this pod but should be // remounted to reflect changes in the referencing pod. Atomically updating // volumes, depend on this to update the contents of the volume. // All volume mounting calls should be idempotent so a second mount call for // volumes that do not need to update contents should not fail. PodExistsInVolume(podName volumetypes.UniquePodName, volumeName v1.UniqueVolumeName, desiredVolumeSize resource.Quantity, seLinuxLabel string) (bool, string, error) // PodRemovedFromVolume returns true if the given pod does not exist in the list of // mountedPods for the given volume in the cache, indicating that the pod has // fully unmounted it or it was never mounted the volume. // If the volume is fully mounted or is in uncertain mount state for the pod, it is // considered that the pod still exists in volume manager's actual state of the world // and false is returned. PodRemovedFromVolume(podName volumetypes.UniquePodName, volumeName v1.UniqueVolumeName) bool // VolumeExistsWithSpecName returns true if the given volume specified with the // volume spec name (a.k.a., InnerVolumeSpecName) exists in the list of // volumes that should be attached to this node. // If a pod with the same name does not exist under the specified // volume, false is returned. VolumeExistsWithSpecName(podName volumetypes.UniquePodName, volumeSpecName string) bool // VolumeExists returns true if the given volume exists in the list of // attached volumes in the cache, indicating the volume is attached to this // node. VolumeExists(volumeName v1.UniqueVolumeName) bool // GetMountedVolumes generates and returns a list of volumes and the pods // they are successfully attached and mounted for based on the current // actual state of the world. GetMountedVolumes() []MountedVolume // GetAllMountedVolumes returns list of all possibly mounted volumes including // those that are in VolumeMounted state and VolumeMountUncertain state. GetAllMountedVolumes() []MountedVolume // GetMountedVolumesForPod generates and returns a list of volumes that are // successfully attached and mounted for the specified pod based on the // current actual state of the world. GetMountedVolumesForPod(podName volumetypes.UniquePodName) []MountedVolume // GetPossiblyMountedVolumesForPod generates and returns a list of volumes for // the specified pod that either are attached and mounted or are "uncertain", // i.e. a volume plugin may be mounting the volume right now. GetPossiblyMountedVolumesForPod(podName volumetypes.UniquePodName) []MountedVolume // GetGloballyMountedVolumes generates and returns a list of all attached // volumes that are globally mounted. This list can be used to determine // which volumes should be reported as "in use" in the node's VolumesInUse // status field. Globally mounted here refers to the shared plugin mount // point for the attachable volume from which the pod specific mount points // are created (via bind mount). GetGloballyMountedVolumes() []AttachedVolume // GetUnmountedVolumes generates and returns a list of attached volumes that // have no mountedPods. This list can be used to determine which volumes are // no longer referenced and may be globally unmounted and detached. GetUnmountedVolumes() []AttachedVolume // GetAttachedVolumes returns a list of volumes that is known to be attached // to the node. This list can be used to determine volumes that are either in-use // or have a mount/unmount operation pending. GetAttachedVolumes() []AttachedVolume // SyncReconstructedVolume check the volume.outerVolumeSpecName in asw and // the one populated from dsw, if they do not match, update this field from the value from dsw. SyncReconstructedVolume(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName, outerVolumeSpecName string) // Add the specified volume to ASW as uncertainly attached. AddAttachUncertainReconstructedVolume(volumeName v1.UniqueVolumeName, volumeSpec *volume.Spec, nodeName types.NodeName, devicePath string) error // UpdateReconstructedDevicePath updates devicePath of a reconstructed volume // from Node.Status.VolumesAttached. The ASW is updated only when the volume is still // uncertain. If the volume got mounted in the meantime, its devicePath must have // been fixed by such an update. UpdateReconstructedDevicePath(volumeName v1.UniqueVolumeName, devicePath string) // UpdateReconstructedVolumeAttachability updates volume attachability from the API server. UpdateReconstructedVolumeAttachability(volumeName v1.UniqueVolumeName, volumeAttachable bool) }
ActualStateOfWorld defines a set of thread-safe operations for the kubelet volume manager's actual state of the world cache. This cache contains volumes->pods i.e. a set of all volumes attached to this node and the pods that the manager believes have successfully mounted the volume. Note: This is distinct from the ActualStateOfWorld implemented by the attach/detach controller. They both keep track of different objects. This contains kubelet volume manager specific state.
func NewActualStateOfWorld ¶
func NewActualStateOfWorld( nodeName types.NodeName, volumePluginMgr *volume.VolumePluginMgr) ActualStateOfWorld
NewActualStateOfWorld returns a new instance of ActualStateOfWorld.
type AttachedVolume ¶
type AttachedVolume struct { operationexecutor.AttachedVolume // DeviceMountState indicates if device has been globally mounted or is not. DeviceMountState operationexecutor.DeviceMountState // SELinuxMountContext is the context with that the volume is globally mounted // (via -o context=XYZ mount option). If empty, the volume is not mounted with // "-o context=". SELinuxMountContext string }
AttachedVolume represents a volume that is attached to a node.
func (AttachedVolume) DeviceMayBeMounted ¶ added in v1.18.0
func (av AttachedVolume) DeviceMayBeMounted() bool
DeviceMayBeMounted returns true if device is mounted in global path or is in uncertain state.
type DesiredStateOfWorld ¶
type DesiredStateOfWorld interface { // AddPodToVolume adds the given pod to the given volume in the cache // indicating the specified pod should mount the specified volume. // A unique volumeName is generated from the volumeSpec and returned on // success. // If no volume plugin can support the given volumeSpec or more than one // plugin can support it, an error is returned. // If a volume with the name volumeName does not exist in the list of // volumes that should be attached to this node, the volume is implicitly // added. // If a pod with the same unique name already exists under the specified // volume, this is a no-op. AddPodToVolume(podName types.UniquePodName, pod *v1.Pod, volumeSpec *volume.Spec, outerVolumeSpecName string, volumeGidValue string, seLinuxContainerContexts []*v1.SELinuxOptions) (v1.UniqueVolumeName, error) // MarkVolumesReportedInUse sets the ReportedInUse value to true for the // reportedVolumes. For volumes not in the reportedVolumes list, the // ReportedInUse value is reset to false. The default ReportedInUse value // for a newly created volume is false. // When set to true this value indicates that the volume was successfully // added to the VolumesInUse field in the node's status. Mount operation needs // to check this value before issuing the operation. // If a volume in the reportedVolumes list does not exist in the list of // volumes that should be attached to this node, it is skipped without error. MarkVolumesReportedInUse(reportedVolumes []v1.UniqueVolumeName) // DeletePodFromVolume removes the given pod from the given volume in the // cache indicating the specified pod no longer requires the specified // volume. // If a pod with the same unique name does not exist under the specified // volume, this is a no-op. // If a volume with the name volumeName does not exist in the list of // attached volumes, this is a no-op. // If after deleting the pod, the specified volume contains no other child // pods, the volume is also deleted. DeletePodFromVolume(podName types.UniquePodName, volumeName v1.UniqueVolumeName) // VolumeExists returns true if the given volume exists in the list of // volumes that should be attached to this node. // If a pod with the same unique name does not exist under the specified // volume, false is returned. VolumeExists(volumeName v1.UniqueVolumeName, seLinuxMountContext string) bool // PodExistsInVolume returns true if the given pod exists in the list of // podsToMount for the given volume in the cache. // If a pod with the same unique name does not exist under the specified // volume, false is returned. // If a volume with the name volumeName does not exist in the list of // attached volumes, false is returned. PodExistsInVolume(podName types.UniquePodName, volumeName v1.UniqueVolumeName, seLinuxMountContext string) bool // GetVolumesToMount generates and returns a list of volumes that should be // attached to this node and the pods they should be mounted to based on the // current desired state of the world. GetVolumesToMount() []VolumeToMount // GetPods generates and returns a map of pods in which map is indexed // with pod's unique name. This map can be used to determine which pod is currently // in desired state of world. GetPods() map[types.UniquePodName]bool // VolumeExistsWithSpecName returns true if the given volume specified with the // volume spec name (a.k.a., InnerVolumeSpecName) exists in the list of // volumes that should be attached to this node. // If a pod with the same name does not exist under the specified // volume, false is returned. VolumeExistsWithSpecName(podName types.UniquePodName, volumeSpecName string) bool // AddErrorToPod adds the given error to the given pod in the cache. // It will be returned by subsequent GetPodErrors(). // Each error string is stored only once. AddErrorToPod(podName types.UniquePodName, err string) // PopPodErrors returns accumulated errors on a given pod and clears // them. PopPodErrors(podName types.UniquePodName) []string // GetPodsWithErrors returns names of pods that have stored errors. GetPodsWithErrors() []types.UniquePodName // MarkVolumeAttachability updates the volume's attachability for a given volume MarkVolumeAttachability(volumeName v1.UniqueVolumeName, attachable bool) // UpdatePersistentVolumeSize updates persistentVolumeSize in desired state of the world // so as it can be compared against actual size and volume expansion performed // if necessary UpdatePersistentVolumeSize(volumeName v1.UniqueVolumeName, size *resource.Quantity) }
DesiredStateOfWorld defines a set of thread-safe operations for the kubelet volume manager's desired state of the world cache. This cache contains volumes->pods i.e. a set of all volumes that should be attached to this node and the pods that reference them and should mount the volume. Note: This is distinct from the DesiredStateOfWorld implemented by the attach/detach controller. They both keep track of different objects. This contains kubelet volume manager specific state.
func NewDesiredStateOfWorld ¶
func NewDesiredStateOfWorld(volumePluginMgr *volume.VolumePluginMgr, seLinuxTranslator util.SELinuxLabelTranslator) DesiredStateOfWorld
NewDesiredStateOfWorld returns a new instance of DesiredStateOfWorld.
type FsResizeRequiredError ¶ added in v1.24.0
type FsResizeRequiredError struct { CurrentSize resource.Quantity // contains filtered or unexported fields }
fsResizeRequiredError is an error returned when PodExistsInVolume() found volume/pod attached/mounted but fsResizeRequired was true, indicating the given volume receives an resize request after attached/mounted.
func (FsResizeRequiredError) Error ¶ added in v1.24.0
func (err FsResizeRequiredError) Error() string
type MountedVolume ¶
type MountedVolume struct {
operationexecutor.MountedVolume
}
MountedVolume represents a volume that has successfully been mounted to a pod.
type VolumeToMount ¶
type VolumeToMount struct {
operationexecutor.VolumeToMount
}
VolumeToMount represents a volume that is attached to this node and needs to be mounted to PodName.