common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 28 Imported by: 8

Documentation

Index

Constants

View Source
const (
	BackupServerVersion     string = "openshift.io/backup-server-version"
	RestoreServerVersion    string = "openshift.io/restore-server-version"
	BackupRegistryHostname  string = "openshift.io/backup-registry-hostname"
	RestoreRegistryHostname string = "openshift.io/restore-registry-hostname"
	MigrationRegistry       string = "openshift.io/migration-registry"
	PausedOwnerRef          string = "openshift.io/paused-owner-ref"
	// distinction for B/R and migration
	MigrationApplicationLabelKey   string = "app.kubernetes.io/part-of"
	MigrationApplicationLabelValue string = "openshift-migration"
)

src/dest cluster annotations, general migration

View Source
const (
	// Whether the backup/restore is associated with a stage or a final migration
	StageOrFinalMigrationAnnotation string = "migration.openshift.io/migmigration-type" // (stage|final)
	StageMigration                  string = "stage"
	FinalMigration                  string = "final"
	// Resources included in the stage backup.
	// Referenced by the Backup.LabelSelector. The value is the Task.UID().
	IncludedInStageBackupLabel = "migration-included-stage-backup"
	// Designated as an `initial` Backup.
	// The value is the Task.UID().
	InitialBackupLabel = "migration-initial-backup"
	// Designated as an `stage` Backup.
	// The value is the Task.UID().
	StageBackupLabel = "migration-stage-backup"
	// Designated as an `stage` Restore.
	// The value is the Task.UID().
	StageRestoreLabel = "migration-stage-restore"
	// Designated as a `final` Restore.
	// The value is the Task.UID().
	FinalRestoreLabel = "migration-final-restore"
	// Exclude PVCs if marked "move" or "snapshot" in the plan
	ExcludePVCPodAnnotation = "migration.openshift.io/exclude-pvcs"
)

annotations and labels related to stage vs. initial/final migrations/restores

View Source
const (
	MigrateTypeAnnotation         string = "openshift.io/migrate-type" // copy, move
	MigrateStorageClassAnnotation string = "openshift.io/target-storage-class"
	MigrateAccessModeAnnotation   string = "openshift.io/target-access-mode"
	MigrateCopyMethodAnnotation   string = "migration.openshift.io/copy-method" // snapshot, filesystem
	PvCopyAction                  string = "copy"
	PvMoveAction                  string = "move"
	PvFilesystemCopyMethod        string = "filesystem"
	PvSnapshotCopyMethod          string = "snapshot"
)

PV selection annotations

View Source
const (
	StagePodImageAnnotation   string = "migration.openshift.io/stage-pod-image"     // Stage pod (sleep) image
	RelatedIsTagNsAnnotation  string = "migration.openshift.io/related-istag-ns"    // Related istag ns
	RelatedIsTagAnnotation    string = "migration.openshift.io/related-istag"       // Related istag name
	PVCSelectedNodeAnnotation string = "volume.kubernetes.io/selected-node"         // kubernetes PVC annotations
	ResticBackupAnnotation    string = "backup.velero.io/backup-volumes"            // Restic annotations
	PVOriginalReclaimPolicy   string = "migration.openshift.io/orig-reclaim-policy" // Original PersistentVolumeReclaimPolicy
)

Other annotations

View Source
const (
	DCPodDeploymentLabel       string = "deployment"                             // identifies associated RC
	DCPodDeploymentConfigLabel string = "deploymentconfig"                       // identifies associated DC
	DCPodDisconnectedLabel     string = "oadp.openshift.io/disconnected-from-dc" // pod had DC labels removed on restore
	DCOriginalReplicas         string = "oadp.openshift.io/original-replicas"    // replicas value from backup
	DCOriginalPaused           string = "oadp.openshift.io/original-paused"      // replicas value from backup
	DCReplicasModifiedLabel    string = "oadp.openshift.io/replicas-modified"    // DC replicas modified on restore
)

DC-related labels/annotations

View Source
const (
	MigMigrationLabelKey string = "migration.openshift.io/migrated-by-migmigration"
	MigPlanLabelKey      string = "migration.openshift.io/migrated-by-migplan"
)

Restored items label

View Source
const (
	// Post Restore Hook must contain this annotation
	PostRestoreHookAnnotation string = "post.hook.restore.velero.io/command"
	//InitContainer restore hook must contain this annotation
	InitContainerRestoreHookAnnotation string = "init.hook.restore.velero.io/container-image"
)
View Source
const DisableImageCopy string = "migration.openshift.io/disable-image-copy"
View Source
const RegistryConfigMap string = "oadp-registry-config"

Configmap Name

View Source
const SkipImageCopy string = "openshift.io/skip-image-copy"

Variables

View Source
var (
	BackupUidMap map[types.UID]*CommonStruct
)

Functions

func GarbageCollectCommonStruct added in v1.1.0

func GarbageCollectCommonStruct()

GarbageCollectCommonStructs removes old entries from the cache

func GetBackup

func GetBackup(uid types.UID, name string, namespace string) (*velero.Backup, error)

fetches backup for a given backup name and requester's uid

func GetBackupStorageLocation added in v1.1.0

func GetBackupStorageLocation(name, namespace string) (*velero.BackupStorageLocation, error)

func GetOwnerReferences

func GetOwnerReferences(item runtime.Unstructured) ([]metav1.OwnerReference, error)

GetOwnerReferences returns the array of OwnerReferences associated with the resource

func GetRegistryInfo

func GetRegistryInfo(log logrus.FieldLogger) (string, error)

func GetSecretKeyForBackupStorageLocation added in v1.1.0

func GetSecretKeyForBackupStorageLocation(name, namespace string) (*corev1.Secret, string, error)

Get secret for backup storage location along with key to use to get secret data.

func GetServerVersion

func GetServerVersion() (int, int, error)

returns major, minor versions for kube

func GetSrcAndDestRegistryInfo

func GetSrcAndDestRegistryInfo(item runtime.Unstructured) (string, string, error)

GetSrcAndDestRegistryInfo returns the Registry hostname for both src and dest clusters

func GetVeleroV1Client added in v1.1.0

func GetVeleroV1Client() (*rest.RESTClient, error)

func HasImageRefPrefix

func HasImageRefPrefix(s, prefix string) bool

HasImageRefPrefix returns true if the input image reference begins with the input prefix followed by "/"

func ReplaceImageRefPrefix

func ReplaceImageRefPrefix(s, oldPrefix, newPrefix string, namespaceMapping map[string]string) (string, error)

ReplaceImageRefPrefix replaces an image reference prefix with newPrefix. If the input image reference does not start with oldPrefix, an error is returned

func StringInSlice

func StringInSlice(a string, list []string) bool

func StringPtr

func StringPtr(s string) *string

func SwapContainerImageRefs

func SwapContainerImageRefs(containers []corev1API.Container, oldRegistry, newRegistry string, log logrus.FieldLogger, namespaceMapping map[string]string)

SwapContainerImageRefs updates internal image references from backup registry to restore registry pathnames

func UpdatePullSecret

func UpdatePullSecret(
	secretRef *corev1API.LocalObjectReference,
	secretList *corev1API.SecretList,
	log logrus.FieldLogger,
) (*corev1API.LocalObjectReference, error)

UpdatePullSecret updates registry pull (or push) secret with a secret found in the dest cluster

Types

type APIServerConfig

type APIServerConfig struct {
	ImagePolicyConfig imagePolicyConfig `json:"imagePolicyConfig"`
	RoutingConfig     routingConfig     `json:"routingConfig"`
}

APIServerConfig stores configuration information about the current cluster

type BackupPlugin

type BackupPlugin struct {
	Log logrus.FieldLogger
}

BackupPlugin is a backup item action plugin for Heptio Ark.

func (*BackupPlugin) AppliesTo

func (p *BackupPlugin) AppliesTo() (velero.ResourceSelector, error)

AppliesTo returns a velero.ResourceSelector that applies to the listed resources in the slice.

func (*BackupPlugin) Execute

Execute sets a custom annotation on the item being backed up. Finds OADP Registry to copy images to and set as migrationRegistry.

type CommonStruct added in v1.1.0

type CommonStruct struct {
	Backup *velero.Backup
	Ut     *udistribution.UdistributionTransport
	// contains filtered or unexported fields
}

common cache for backup UIDs

func (*CommonStruct) JustAccessed added in v1.1.0

func (c *CommonStruct) JustAccessed()

JustAccessed marks the item as recently accessed and triggers garbage collection

type LocalImageReference

type LocalImageReference struct {
	Registry  string
	Namespace string
	Name      string
	Tag       string
	Digest    string
}

LocalImageReference describes an image in the internal openshift registry

func ParseLocalImageReference

func ParseLocalImageReference(s, prefix string) (*LocalImageReference, error)

ParseLocalImageReference

type ResourceHookSelector

type ResourceHookSelector struct {
	Namespaces    *collections.IncludesExcludes
	Resources     *collections.IncludesExcludes
	LabelSelector labels.Selector
}

func (ResourceHookSelector) ApplicableTo

func (r ResourceHookSelector) ApplicableTo(groupResource schema.GroupResource, namespace string, labels labels.Set) bool

type RestorePlugin

type RestorePlugin struct {
	Log logrus.FieldLogger
}

RestorePlugin is a restore item action plugin for Heptio Ark.

func (*RestorePlugin) AppliesTo

func (p *RestorePlugin) AppliesTo() (velero.ResourceSelector, error)

AppliesTo returns a velero.ResourceSelector that applies to the listed resources in the slice.

func (*RestorePlugin) Execute

Execute sets a custom annotation on the item being restored.

Jump to

Keyboard shortcuts

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