mover

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

VolSync data movers are created by implementing the interfaces in this package. Each data mover must implement the Builder interface that constructs instances of the Mover (interface) given a ReplicationSource or ReplicationDestination CR. These builders must be created and Register()-ed with the Catalog at startup time for that mover type to be available.

When an RS or RD CR is reconciled, the Builders in the Catalog are tried in sequence. If one successfully returns a Mover, that mover is used to perform the reconcile.

Movers implement the actual synchronization of data and return a Result from each invocation. When one of the Mover's functions returns Completed(), the operation (either synchronization or cleanup of a previous synchronization is considered to be completed).

Index

Constants

View Source
const (
	// SnapshotBindTimeout is the amount of time we should wait before warning
	// that a VolumeSnapshot object is not bound to a VolumeSnapshotContent
	// object.
	SnapshotBindTimeout = 30 * time.Second
	// PVCBindTimeout is the time we should wait before warning that a PVC
	// object is not bound to a PV.
	PVCBindTimeout = 120 * time.Second
	// ServiceAddressTimeout is the time we should wait before warning that a
	// Service has not been assigned an address
	ServiceAddressTimeout = 15 * time.Second
)
View Source
const (
	VolSyncPrefix = "volsync-"
)

Variables

View Source
var (
	ErrNoMoverFound        = fmt.Errorf("a replication method must be specified")
	ErrMultipleMoversFound = fmt.Errorf("only one replication method can be supplied")
)
View Source
var Catalog []Builder

Catalog is the list of the available Builders for the controller to use when attempting to find an appropriate mover to service the RS/RD CR.

Functions

func Register

func Register(builder Builder)

Register should be called by each mover via an init function to register the mover w/ the main VolSync codebase.

Types

type Builder

type Builder interface {
	// FromSource attempts to construct a Mover from the provided
	// ReplicationSource. If the RS does not reference the Builder's mover type,
	// this function should return (nil, nil).
	FromSource(client client.Client, logger logr.Logger,
		eventRecorder events.EventRecorder,
		source *volsyncv1alpha1.ReplicationSource, privileged bool) (Mover, error)

	// FromDestination attempts to construct a Mover from the provided
	// ReplicationDestination. If the RS does not reference the Builder's mover
	// type, this function should return (nil, nil).
	FromDestination(client client.Client, logger logr.Logger,
		eventRecorder events.EventRecorder,
		destination *volsyncv1alpha1.ReplicationDestination, privileged bool) (Mover, error)

	// VersionInfo returns a string describing the version of this mover. In
	// most cases, this is the container image/tag that will be used.
	VersionInfo() string
}

Builder is used to construct Mover instances for the different data mover types.

type Mover

type Mover interface {
	// The name of this data mover
	Name() string

	// Synchronize begins or continues a synchronization attempt. Attempts will
	// continue at least until the Result indicates that the synchronization is
	// complete. Must be idempotent.
	Synchronize(ctx context.Context) (Result, error)

	// Cleanup begins or continues the post-synchronization cleanup of temporary
	// resources. Must be idempotent.
	Cleanup(ctx context.Context) (Result, error)
}

Mover is a common interface that all data movers implement

func GetDestinationMoverFromCatalog added in v0.5.0

func GetDestinationMoverFromCatalog(client client.Client, logger logr.Logger,
	eventRecorder events.EventRecorder,
	destination *volsyncv1alpha1.ReplicationDestination, privileged bool) (Mover, error)

func GetSourceMoverFromCatalog added in v0.5.0

func GetSourceMoverFromCatalog(client client.Client, logger logr.Logger,
	eventRecorder events.EventRecorder,
	source *volsyncv1alpha1.ReplicationSource, privileged bool) (Mover, error)

type Result

type Result struct {
	// Completed is set to true if the synchronization has completed. RetryAfter
	// will be ignored.
	Completed bool

	// Image is the resulting data image (PVC or Snapshot) that has been created
	// by the Synchronize() operation.
	Image *corev1.TypedLocalObjectReference

	// RetryAfter is used to indicate whether synchronization should be
	// explicitly retried, and when. Setting to nil (default) does not cause an
	// explicit retry, but Synchronize() will be retried when a watched object
	// is modified. Setting to 0 indicates an immediate retry. Other values
	// provide a delay.
	RetryAfter *time.Duration
}

Result indicates the outcome of a synchronization attempt

func Complete

func Complete() Result

Complete indicates that the operation has completed.

func CompleteWithImage

func CompleteWithImage(image *corev1.TypedLocalObjectReference) Result

CompleteWithImage indicates that the operation has completed, and it provides the synchronized image to the controller.

func InProgress

func InProgress() Result

InProgress result indicates that the requested operation is still ongoing, but it does not request an explicit requeueing.

func RetryAfter

func RetryAfter(s time.Duration) Result

RetryAfter indicates the operation is ongoing and requests explicit requeueing after the provided duration.

func (Result) ReconcileResult

func (mr Result) ReconcileResult() ctrl.Result

ReconcileResult converts a Result into controllerruntime's reconcile result structure

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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