snapshotter

package
v2.8.2-0...-dd449ac Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StorkSnapshotRestoreNamespacesAnnotation is annotation used to specify the
	// comma separated list of namespaces to which the snapshot can be restored
	StorkSnapshotRestoreNamespacesAnnotation = "stork.libopenstorage.org/snapshot-restore-namespaces"

	// StorkSnapshotSourceNamespaceAnnotation Annotation used to specify the
	// source of the snapshot when creating a PVC
	StorkSnapshotSourceNamespaceAnnotation = "stork.libopenstorage.org/snapshot-source-namespace"
)

Variables

View Source
var (
	ExternalStorage = "external-storage"
)

List of supported snapshot drivers.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	// CreateSnapshot creates a volume snapshot for a pvc.
	CreateSnapshot(opts ...Option) (snapName, namespace, driverName string, err error)
	// DeleteSnapshot removes a snapshot.
	DeleteSnapshot(name, namespace string, retain bool) error
	// SnapshotStatus returns a status for a snapshot.
	SnapshotStatus(name, namespace string) (SnapshotInfo, error)
	// RestoreVolumeClaim creates a persistent volume claim from a provided snapshot.
	RestoreVolumeClaim(opts ...Option) (*v1.PersistentVolumeClaim, error)
	// RestoreStatus returns the status of a restore operation
	RestoreStatus(pvcName, namespace string) (RestoreInfo, error)
	// CancelRestore cancels a restore operation
	CancelRestore(pvcName, namespace string) error
	// Upload objects to cloud
	UploadSnapshotObjects(backupLocation *storkapi.BackupLocation, snapshotInfoList []SnapshotInfo, objectPath, objectName string) error
	// Download objects from cloud
	DownloadSnapshotObjects(backupLocation *storkapi.BackupLocation, objectPath string) ([]SnapshotInfo, error)
	// Delete objects in cloud
	DeleteSnapshotObject(backupLocation *storkapi.BackupLocation, objectPath string) error
	// Recreate snapshot resources before doing snapshot restore
	RecreateSnapshotResources(snapshotInfo SnapshotInfo, snapshotDriverName, namespace string, retain bool) (SnapshotInfo, error)
	// Retain local snapshots if required
	RetainLocalSnapshots(backupLocation *storkapi.BackupLocation, snapshotDriverName, snapshotClassName, namespace, pvcUID, objectPath string, retain bool) error
	// Restore from local snapshot if present
	RestoreFromLocalSnapshot(backupLocation *storkapi.BackupLocation, pvc *v1.PersistentVolumeClaim, snapshotDriverName, pvcUID, backupUID, objectPath, namespace string) (bool, error)
	// Cleanup resources if restore from localsnapshot fails
	CleanUpRestoredResources(backupLocation *storkapi.BackupLocation, pvc *v1.PersistentVolumeClaim, pvcUID, backupUID, objectPath, namespace string) error
}

Driver interface provides APIs for a storage provider to take a local snapshot and create a PVC referencing it.

func NewCSIDriver

func NewCSIDriver() (Driver, error)

NewCSIDriver returns the csi implementation of Driver object

type Option

type Option func(opts *Options) error

Option is used for snapshot configuration.

func Annotations

func Annotations(annotations map[string]string) Option

Annotations are the annotations applied on the snapshot related objects

func Labels

func Labels(labels map[string]string) Option

Labels are the labels applied on snapshot related objects

func Name

func Name(name string) Option

Name is used to set a snapshot name.

func Namespace

func Namespace(name string) Option

Namespace is used to set a snapshot namespace.

func PVC

PVC is a persistent volume claim spec to restore snapshot to.

func PVCName

func PVCName(name string) Option

PVCName is a persistent volume claim name to make snapshot from.

func PVCNamespace

func PVCNamespace(ns string) Option

PVCNamespace is a persistent volume claim namespace to make snapshot from.

func RestoreNamespace

func RestoreNamespace(namespace string) Option

RestoreNamespace is the namespace to which a snapshot should be restored to.

func RestoreSnapshotName

func RestoreSnapshotName(name string) Option

RestoreSnapshotName is the snapshot name from which a PVC will be restored

func SnapshotClassName

func SnapshotClassName(name string) Option

SnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot.

type Options

type Options struct {
	// Name is a snapshot name.
	Name string
	// Namespace is a snapshot namespace.
	Namespace string
	// PVCName is a persistent volume claim name to make snapshot from or restore to.
	PVCName string
	// PVCName is a persistent volume claim namespace to make snapshot from or restore to.
	PVCNamespace string
	// PVC is a persistent volume claim spec to restore snapshot to.
	PVC v1.PersistentVolumeClaim
	// RestoreNamespace is the namespace to which a snapshot should be restored to.
	RestoreNamespace string
	// SnapshotClassName is the name of the VolumeSnapshotClass requested by the VolumeSnapshot.
	SnapshotClassName string
	// RestoreSnapshotName is the name of the snapshot from which restore will be performed
	RestoreSnapshotName string
	// Annotations are the annotations that can be applied on the snapshot related objects
	Annotations map[string]string
	// Labels are the labels that can be applied on the snapshot related objects
	Labels map[string]string
}

Options defines all snapshot parameters.

type RestoreInfo

type RestoreInfo struct {
	// Status provides the current status of snapshot
	Status Status
	// Reason provides additional context to the status of the snapshot
	Reason string
	// VolumeName is the name of the volume being restored
	VolumeName string
	// Size is the size of the PVC being restored
	Size uint64
}

RestoreInfo provides the current status of Restore operation from a snapshot

type SnapshotInfo

type SnapshotInfo struct {
	// Status provides the current status of snapshot
	Status Status
	// Reason provides additional context to the status of the snapshot
	Reason string
	// Size is the actual size of the snapshot
	Size uint64
	// Class defines the driver specific snapshot attributes
	Class interface{}
	// SnapshotRequest is the original driver specific snapshot request
	SnapshotRequest interface{}
	// Content is the actual volume snapshot of a volume
	Content interface{}
}

SnapshotInfo provides the current state of Snapshot

type Snapshotter

type Snapshotter interface {
	// Driver returns the driver based on the provided name
	Driver(name string) (Driver, error)
}

Snapshotter inteface returns a Driver object

func NewDefaultSnapshotter

func NewDefaultSnapshotter() Snapshotter

NewDefaultSnapshotter returns the default implementation of Snapshotter

type Status

type Status string

Status is a snapshot status.

var (
	StatusInProgress Status = "InProgress"
	StatusReady      Status = "Ready"
	StatusFailed     Status = "Failed"
	StatusUnknown    Status = "Unknown"
)

List of known snapshot states.

Jump to

Keyboard shortcuts

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