utils

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixedSnapshotterSecretNameKey      = csiParameterPrefix + "snapshotter-secret-name"      // Prefixed name key for DeleteSnapshot secret
	PrefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace" // Prefixed namespace key for DeleteSnapshot secret

	PrefixedSnapshotterListSecretNameKey      = csiParameterPrefix + "snapshotter-list-secret-name"      // Prefixed name key for ListSnapshots secret
	PrefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace" // Prefixed namespace key for ListSnapshots secret

	// Name of finalizer on VolumeSnapshotContents that are bound by VolumeSnapshots
	VolumeSnapshotContentFinalizer = "snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection"
	// Name of finalizer on VolumeSnapshot that is being used as a source to create a PVC
	VolumeSnapshotBoundFinalizer = "snapshot.storage.kubernetes.io/volumesnapshot-bound-protection"
	// Name of finalizer on VolumeSnapshot that is used as a source to create a PVC
	VolumeSnapshotAsSourceFinalizer = "snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection"
	// Name of finalizer on PVCs that is being used as a source to create VolumeSnapshots
	PVCFinalizer = "snapshot.storage.kubernetes.io/pvc-as-source-protection"

	IsDefaultSnapshotClassAnnotation = "snapshot.storage.kubernetes.io/is-default-class"

	// AnnVolumeSnapshotBeingDeleted annotation applies to VolumeSnapshotContents.
	// It indicates that the common snapshot controller has verified that volume
	// snapshot has a deletion timestamp and is being deleted.
	// Sidecar controller needs to check the deletion policy on the
	// VolumeSnapshotContentand and decide whether to delete the volume snapshot
	// backing the snapshot content.
	AnnVolumeSnapshotBeingDeleted = "snapshot.storage.kubernetes.io/volumesnapshot-being-deleted"

	// AnnVolumeSnapshotBeingCreated annotation applies to VolumeSnapshotContents.
	// If it is set, it indicates that the csi-snapshotter
	// sidecar has sent the create snapshot request to the storage system and
	// is waiting for a response of success or failure.
	// This annotation will be removed once the driver's CreateSnapshot
	// CSI function returns success or a final error (determined by isFinalError()).
	// If the create snapshot request fails with a non-final error such as timeout,
	// retry will happen and the annotation will remain.
	// This only applies to dynamic provisioning of snapshots because
	// the create snapshot CSI method will not be called for pre-provisioned
	// snapshots.
	AnnVolumeSnapshotBeingCreated = "snapshot.storage.kubernetes.io/volumesnapshot-being-created"

	// Annotation for secret name and namespace will be added to the content
	// and used at snapshot content deletion time.
	AnnDeletionSecretRefName      = "snapshot.storage.kubernetes.io/deletion-secret-name"
	AnnDeletionSecretRefNamespace = "snapshot.storage.kubernetes.io/deletion-secret-namespace"
)

Variables

View Source
var SnapshotterListSecretParams = secretParamsMap{
	// contains filtered or unexported fields
}
View Source
var SnapshotterSecretParams = secretParamsMap{
	// contains filtered or unexported fields
}

Functions

func GetCredentials

func GetCredentials(k8s kubernetes.Interface, ref *v1.SecretReference) (map[string]string, error)

GetCredentials retrieves credentials stored in v1.SecretReference

func GetDynamicSnapshotContentNameForSnapshot added in v2.1.1

func GetDynamicSnapshotContentNameForSnapshot(snapshot *crdv1.VolumeSnapshot) string

GetDynamicSnapshotContentNameForSnapshot returns a unique content name for the passed in VolumeSnapshot to dynamically provision a snapshot.

func GetSecretReference

func GetSecretReference(secretParams secretParamsMap, snapshotClassParams map[string]string, snapContentName string, snapshot *crdv1.VolumeSnapshot) (*v1.SecretReference, error)

getSecretReference returns a reference to the secret specified in the given nameTemplate

and namespaceTemplate, or an error if the templates are not specified correctly.

No lookup of the referenced secret is performed, and the secret may or may not exist.

supported tokens for name resolution: - ${volumesnapshotcontent.name} - ${volumesnapshot.namespace} - ${volumesnapshot.name}

supported tokens for namespace resolution: - ${volumesnapshotcontent.name} - ${volumesnapshot.namespace}

an error is returned in the following situations: - the nameTemplate or namespaceTemplate contains a token that cannot be resolved - the resolved name is not a valid secret name - the resolved namespace is not a valid namespace name

func GetSnapshotStatusForLogging

func GetSnapshotStatusForLogging(snapshot *crdv1.VolumeSnapshot) string

Stateless functions

func IsBoundVolumeSnapshotContentNameSet

func IsBoundVolumeSnapshotContentNameSet(snapshot *crdv1.VolumeSnapshot) bool

func IsDefaultAnnotation

func IsDefaultAnnotation(obj metav1.ObjectMeta) bool

IsDefaultAnnotation returns a boolean if the annotation is set

func IsSnapshotDeletionCandidate

func IsSnapshotDeletionCandidate(snapshot *crdv1.VolumeSnapshot) bool

IsSnapshotDeletionCandidate checks if a volume snapshot deletionTimestamp is set and any finalizer is on the snapshot.

func IsSnapshotReady

func IsSnapshotReady(snapshot *crdv1.VolumeSnapshot) bool

func IsVolumeSnapshotRefSet

func IsVolumeSnapshotRefSet(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapshotContent) bool

func NeedToAddContentFinalizer

func NeedToAddContentFinalizer(content *crdv1.VolumeSnapshotContent) bool

NeedToAddContentFinalizer checks if a Finalizer needs to be added for the volume snapshot content.

func NeedToAddSnapshotAsSourceFinalizer

func NeedToAddSnapshotAsSourceFinalizer(snapshot *crdv1.VolumeSnapshot) bool

NeedToAddSnapshotAsSourceFinalizer checks if a Finalizer needs to be added for the volume snapshot as a source for PVC.

func NeedToAddSnapshotBoundFinalizer

func NeedToAddSnapshotBoundFinalizer(snapshot *crdv1.VolumeSnapshot) bool

NeedToAddSnapshotBoundFinalizer checks if a Finalizer needs to be added for the bound volume snapshot.

func NoResyncPeriodFunc

func NoResyncPeriodFunc() time.Duration

NoResyncPeriodFunc Returns 0 for resyncPeriod in case resyncing is not needed.

func RemovePrefixedParameters

func RemovePrefixedParameters(param map[string]string) (map[string]string, error)

func SnapshotKey

func SnapshotKey(vs *crdv1.VolumeSnapshot) string

func SnapshotRefKey

func SnapshotRefKey(vsref *v1.ObjectReference) string

func StoreObjectUpdate

func StoreObjectUpdate(store cache.Store, obj interface{}, className string) (bool, error)

storeObjectUpdate updates given cache with a new object version from Informer callback (i.e. with events from etcd) or with an object modified by the controller itself. Returns "true", if the cache was updated, false if the object is an old version and should be ignored.

Types

This section is empty.

Jump to

Keyboard shortcuts

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