clone

package
v1.60.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PendingPhaseName is the phase when the clone is pending
	PendingPhaseName = "Pending"

	// SucceededPhaseName is the phase when the clone is succeeded
	SucceededPhaseName = "Succeeded"

	// ErrorPhaseName is the phase when the clone is in error
	ErrorPhaseName = "Error"
)
View Source
const (
	// CloneValidationFailed reports that a clone wasn't admitted by our validation mechanism (reason)
	CloneValidationFailed = "CloneValidationFailed"

	// MessageCloneValidationFailed reports that a clone wasn't admitted by our validation mechanism (message)
	MessageCloneValidationFailed = "The clone doesn't meet the validation requirements"

	// CloneWithoutSource reports that the source of a clone doesn't exists (reason)
	CloneWithoutSource = "CloneWithoutSource"

	// MessageCloneWithoutSource reports that the source of a clone doesn't exists (message)
	MessageCloneWithoutSource = "The source %s %s doesn't exist"

	// NoVolumeSnapshotClass reports that no compatible volumesnapshotclass was found (reason)
	NoVolumeSnapshotClass = "NoVolumeSnapshotClass"

	// MessageNoVolumeSnapshotClass reports that no compatible volumesnapshotclass was found (message)
	MessageNoVolumeSnapshotClass = "No compatible volumesnapshotclass found"

	// IncompatibleVolumeModes reports that the volume modes of source and target are incompatible (reason)
	IncompatibleVolumeModes = "IncompatibleVolumeModes"

	// MessageIncompatibleVolumeModes reports that the volume modes of source and target are incompatible (message)
	MessageIncompatibleVolumeModes = "The volume modes of source and target are incompatible"

	// NoVolumeExpansion reports that no volume expansion is possible (reason)
	NoVolumeExpansion = "NoVolumeExpansion"

	// MessageNoVolumeExpansion reports that no volume expansion is possible (message)
	MessageNoVolumeExpansion = "No volume expansion is possible"

	// NoProvisionerMatch reports that the storageclass provisioner does not match the volumesnapshotcontent driver (reason)
	NoProvisionerMatch = "NoProvisionerMatch"

	// MessageNoProvisionerMatch reports that the storageclass provisioner does not match the volumesnapshotcontent driver (message)
	MessageNoProvisionerMatch = "The storageclass provisioner does not match the volumesnapshotcontent driver"

	// IncompatibleProvisioners reports that the provisioners are incompatible (reason)
	IncompatibleProvisioners = "IncompatibleProvisioners"

	// MessageIncompatibleProvisioners reports that the provisioners are incompatible (message)
	MessageIncompatibleProvisioners = "Provisioners are incompatible"
)
View Source
const CSIClonePhaseName = "CSIClone"

CSIClonePhaseName is the name of the csi clone phase

View Source
const HostClonePhaseName = "HostClone"

HostClonePhaseName is the name of the host clone phase

View Source
const PrepClaimPhaseName = "PrepClaim"

PrepClaimPhaseName is the name of the prep claim phase

View Source
const RebindPhaseName = "Rebind"

RebindPhaseName is the name of the rebind phase

View Source
const SnapshotClonePhaseName = "SnapshotClone"

SnapshotClonePhaseName is the name of the snapshot clone phase

View Source
const SnapshotPhaseName = "Snapshot"

SnapshotPhaseName is the name of the snapshot phase

Variables

This section is empty.

Functions

func AddCommonClaimLabels

func AddCommonClaimLabels(pvc *corev1.PersistentVolumeClaim)

AddCommonClaimLabels adds common labels to a pvc

func AddCommonLabels

func AddCommonLabels(obj metav1.Object)

AddCommonLabels adds common labels to a resource

func AddOwnershipLabel

func AddOwnershipLabel(label string, obj, owner metav1.Object)

AddOwnershipLabel adds owner label

func GetCommonDriver

func GetCommonDriver(ctx context.Context, c client.Client, pvcs ...*corev1.PersistentVolumeClaim) (*string, error)

GetCommonDriver returns the name of the CSI driver shared by all PVCs

func GetCompatibleVolumeSnapshotClass

func GetCompatibleVolumeSnapshotClass(ctx context.Context, c client.Client, log logr.Logger, recorder record.EventRecorder, pvcs ...*corev1.PersistentVolumeClaim) (*string, error)

GetCompatibleVolumeSnapshotClass returns a VolumeSnapshotClass name that works for all PVCs Note the last PVC passed is considered the target PVC for logs and events

func GetDriverFromVolume

func GetDriverFromVolume(ctx context.Context, c client.Client, pvc *corev1.PersistentVolumeClaim) (*string, error)

GetDriverFromVolume returns the CSI driver name for a PVC

func GetGlobalCloneStrategyOverride

func GetGlobalCloneStrategyOverride(ctx context.Context, c client.Client) (*cdiv1.CDICloneStrategy, error)

GetGlobalCloneStrategyOverride returns the global clone strategy override

func GetStorageClassForClaim

func GetStorageClassForClaim(ctx context.Context, c client.Client, pvc *corev1.PersistentVolumeClaim) (*storagev1.StorageClass, error)

GetStorageClassForClaim returns the storageclass for a PVC

func IsDataSourcePVC

func IsDataSourcePVC(kind string) bool

IsDataSourcePVC checks for PersistentVolumeClaim source kind

func IsDataSourceSnapshot

func IsDataSourceSnapshot(kind string) bool

IsDataSourceSnapshot checks for Snapshot source kind

func IsSourceClaimReady

func IsSourceClaimReady(ctx context.Context, args *IsSourceClaimReadyArgs) (bool, error)

IsSourceClaimReady checks that PVC exists, is bound, and is not being used

func SameVolumeMode

func SameVolumeMode(pvc1 *corev1.PersistentVolumeClaim, others ...*corev1.PersistentVolumeClaim) bool

SameVolumeMode returns true if all pvcs have the same volume mode

Types

type CSIClonePhase

type CSIClonePhase struct {
	Owner          client.Object
	Namespace      string
	SourceName     string
	DesiredClaim   *corev1.PersistentVolumeClaim
	OwnershipLabel string
	Client         client.Client
	Log            logr.Logger
	Recorder       record.EventRecorder
}

CSIClonePhase is responsible for csi cloning a pvc

func (*CSIClonePhase) Name

func (p *CSIClonePhase) Name() string

Name returns the name of the phase

func (*CSIClonePhase) Reconcile

func (p *CSIClonePhase) Reconcile(ctx context.Context) (*reconcile.Result, error)

Reconcile ensures a csi cloned pvc is created correctly

type ChooseStrategyArgs

type ChooseStrategyArgs struct {
	Log         logr.Logger
	TargetClaim *corev1.PersistentVolumeClaim
	DataSource  *cdiv1.VolumeCloneSource
}

ChooseStrategyArgs are args for ChooseStrategy function

type ChooseStrategyResult

type ChooseStrategyResult struct {
	Strategy       cdiv1.CDICloneStrategy
	FallbackReason *string
}

ChooseStrategyResult is result returned by ChooseStrategy function

type HostClonePhase

type HostClonePhase struct {
	Owner             client.Object
	Namespace         string
	SourceName        string
	DesiredClaim      *corev1.PersistentVolumeClaim
	ImmediateBind     bool
	OwnershipLabel    string
	Preallocation     bool
	PriorityClassName string
	Client            client.Client
	Log               logr.Logger
	Recorder          record.EventRecorder
}

HostClonePhase creates and monitors a dumb clone operation

func (*HostClonePhase) Name

func (p *HostClonePhase) Name() string

Name returns the name of the phase

func (*HostClonePhase) Reconcile

func (p *HostClonePhase) Reconcile(ctx context.Context) (*reconcile.Result, error)

Reconcile creates the desired pvc and waits for the operation to complete

func (*HostClonePhase) Status

func (p *HostClonePhase) Status(ctx context.Context) (*PhaseStatus, error)

Status returns the phase status

type IsSourceClaimReadyArgs

type IsSourceClaimReadyArgs struct {
	Target          client.Object
	SourceNamespace string
	SourceName      string
	Client          client.Client
	Log             logr.Logger
	Recorder        record.EventRecorder
}

IsSourceClaimReadyArgs are arguments for IsSourceClaimReady

type Phase

type Phase interface {
	Name() string
	Reconcile(context.Context) (*reconcile.Result, error)
}

Phase is the interface implemented by all clone phases

type PhaseStatus

type PhaseStatus struct {
	Progress    string
	Annotations map[string]string
}

PhaseStatus contains phase status data

type PlanArgs

type PlanArgs struct {
	Log         logr.Logger
	TargetClaim *corev1.PersistentVolumeClaim
	DataSource  *cdiv1.VolumeCloneSource
	Strategy    cdiv1.CDICloneStrategy
}

PlanArgs are args to plan clone op for populator

type Planner

type Planner struct {
	RootObjectType  client.ObjectList
	OwnershipLabel  string
	UIDField        string
	Image           string
	PullPolicy      corev1.PullPolicy
	InstallerLabels map[string]string
	Client          client.Client
	Recorder        record.EventRecorder
	Controller      controller.Controller
	GetCache        func() cache.Cache
	// contains filtered or unexported fields
}

Planner plans clone operations

func (*Planner) AddCoreWatches

func (p *Planner) AddCoreWatches(log logr.Logger) error

AddCoreWatches watches "core" types

func (*Planner) ChooseStrategy

func (p *Planner) ChooseStrategy(ctx context.Context, args *ChooseStrategyArgs) (*ChooseStrategyResult, error)

ChooseStrategy picks the strategy for a clone op

func (*Planner) Cleanup

func (p *Planner) Cleanup(ctx context.Context, log logr.Logger, owner client.Object) error

Cleanup cleans up after a clone op

func (*Planner) Plan

func (p *Planner) Plan(ctx context.Context, args *PlanArgs) ([]Phase, error)

Plan creates phases for populator clone

type PrepClaimPhase

type PrepClaimPhase struct {
	Owner           client.Object
	DesiredClaim    *corev1.PersistentVolumeClaim
	Image           string
	PullPolicy      corev1.PullPolicy
	InstallerLabels map[string]string
	OwnershipLabel  string
	Client          client.Client
	Log             logr.Logger
	Recorder        record.EventRecorder
}

PrepClaimPhase is responsible for prepping a PVC for rebind

func (*PrepClaimPhase) Name

func (p *PrepClaimPhase) Name() string

Name returns the name of the phase

func (*PrepClaimPhase) Reconcile

func (p *PrepClaimPhase) Reconcile(ctx context.Context) (*reconcile.Result, error)

Reconcile ensures that a pvc is bound and resized if necessary

type RebindPhase

type RebindPhase struct {
	SourceNamespace string
	SourceName      string
	TargetNamespace string
	TargetName      string
	Client          client.Client
	Log             logr.Logger
	Recorder        record.EventRecorder
}

RebindPhase binds a PV from one PVC to another

func (*RebindPhase) Name

func (p *RebindPhase) Name() string

Name returns the name of the phase

func (*RebindPhase) Reconcile

func (p *RebindPhase) Reconcile(ctx context.Context) (*reconcile.Result, error)

Reconcile rebinds a PV

type SnapshotClonePhase

type SnapshotClonePhase struct {
	Owner          client.Object
	Namespace      string
	SourceName     string
	DesiredClaim   *corev1.PersistentVolumeClaim
	OwnershipLabel string
	Client         client.Client
	Log            logr.Logger
	Recorder       record.EventRecorder
}

SnapshotClonePhase waits for a snapshot to be ready and creates a PVC from it

func (*SnapshotClonePhase) Name

func (p *SnapshotClonePhase) Name() string

Name returns the name of the phase

func (*SnapshotClonePhase) Reconcile

func (p *SnapshotClonePhase) Reconcile(ctx context.Context) (*reconcile.Result, error)

Reconcile ensures a snapshot is created correctly

type SnapshotPhase

type SnapshotPhase struct {
	Owner               client.Object
	SourceNamespace     string
	SourceName          string
	TargetName          string
	VolumeSnapshotClass string
	OwnershipLabel      string
	Client              client.Client
	Log                 logr.Logger
	Recorder            record.EventRecorder
}

SnapshotPhase snapshots a PVC

func (*SnapshotPhase) Name

func (p *SnapshotPhase) Name() string

Name returns the name of the phase

func (*SnapshotPhase) Reconcile

func (p *SnapshotPhase) Reconcile(ctx context.Context) (*reconcile.Result, error)

Reconcile ensures a snapshot is created correctly

type StatusReporter

type StatusReporter interface {
	Status(context.Context) (*PhaseStatus, error)
}

StatusReporter allows a phase to report status

Jump to

Keyboard shortcuts

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