cache

package
v0.0.0-...-1ee69d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFSResizeRequiredError

func IsFSResizeRequiredError(err error) bool

IsFSResizeRequiredError returns true if the specified error is a fsResizeRequiredError.

func IsRemountRequiredError

func IsRemountRequiredError(err error) bool

IsRemountRequiredError returns true if the specified error is a remountRequiredError.

func IsSELinuxMountMismatchError

func IsSELinuxMountMismatchError(err error) bool

IsSELinuxMountMismatchError returns true if the specified error is a seLinuxMountMismatchError.

func IsVolumeNotAttachedError

func IsVolumeNotAttachedError(err error) bool

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

func (av AttachedVolume) DeviceMayBeMounted() bool

DeviceMayBeMounted returns true if device is mounted in global path or is in uncertain state.

type FsResizeRequiredError

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

func (err FsResizeRequiredError) Error() string

type MountedVolume

type MountedVolume struct {
	operationexecutor.MountedVolume
}

MountedVolume represents a volume that has successfully been mounted to a pod.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL