Documentation
¶
Index ¶
- Constants
- Variables
- func CleanupSecretPropagation(ctx context.Context, k8sClient client.Client, ownerObject metav1.Object, ...) error
- func ConvertSchedulingIntervalToCronSpec(schedulingInterval string) (*string, error)
- func DeployVolSyncToCluster(ctx context.Context, k8sClient client.Client, managedClusterName string, ...) error
- func GetRD(ctx context.Context, k8sClient client.Client, name, namespace string, ...) (*volsyncv1alpha1.ReplicationDestination, error)
- func GetVolSyncPSKSecretNameFromVRGName(vrgName string) string
- func PropagateSecretToClusters(ctx context.Context, k8sClient client.Client, sourceSecret *corev1.Secret, ...) error
- func RDStatusReady(rd *volsyncv1alpha1.ReplicationDestination, log logr.Logger) bool
- func ReconcileVolSyncReplicationSecret(ctx context.Context, k8sClient client.Client, ownerObject metav1.Object, ...) (*corev1.Secret, error)
- func ValidateObjectExists(ctx context.Context, c client.Client, obj client.Object) error
- type VSHandler
- func (v *VSHandler) AppendOrUpdateRdInfo(rdInfoList []ramendrv1alpha1.VolSyncReplicationDestinationInfo, ...) []ramendrv1alpha1.VolSyncReplicationDestinationInfo
- func (v *VSHandler) CleanupAfterRSFinalSync(pvcName, pvcNamespace string) error
- func (v *VSHandler) CleanupLocalResources(lrs *volsyncv1alpha1.ReplicationSource) error
- func (v *VSHandler) CleanupPVClaimRefForPVCDeletion(pvc corev1.PersistentVolumeClaim) error
- func (v *VSHandler) CleanupRDNotInSpecList(rdSpecList []ramendrv1alpha1.VolSyncReplicationDestinationSpec, ...) error
- func (v *VSHandler) CopySecretToPVCNamespace(secretName, namespace string) error
- func (v *VSHandler) CreateCurrentStateSnapshot(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec) (string, error)
- func (v *VSHandler) DeleteLocalRD(lrdName, lrdNamespace string) error
- func (v *VSHandler) DeleteMountJob(pvcName, pvcNamespace string) error
- func (v *VSHandler) DeleteRD(pvcName, pvcNamespace string) error
- func (v *VSHandler) DeleteRS(pvcName string, pvcNamespace string) error
- func (v *VSHandler) DeleteSnapshots(pvcNamespace string) error
- func (v *VSHandler) EnsureMountJobForUnmountedPVC(rsSpec *ramendrv1alpha1.VolSyncReplicationSourceSpec) (bool, error)
- func (v *VSHandler) EnsurePVCforDirectCopy(ctx context.Context, rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec) error
- func (v *VSHandler) EnsurePVCfromRD(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, failoverAction bool) error
- func (v *VSHandler) EnsureVolSyncMoverJobLabels(pvcName, namespace string)
- func (v *VSHandler) EnsureVolSyncServiceImportLabels(pvcName, namespace string)
- func (v *VSHandler) GetMoverConfigForPVC(pvcName, pvcNamespace string) *ramendrv1alpha1.MoverConfig
- func (v *VSHandler) GetOwner() metav1.Object
- func (v *VSHandler) GetRsyncServiceType() *corev1.ServiceType
- func (v *VSHandler) GetVolumeSnapshotClassFromPVCStorageClass(storageClassName *string) (string, error)
- func (v *VSHandler) GetVolumeSnapshotClasses() ([]snapv1.VolumeSnapshotClass, error)
- func (v *VSHandler) GetWorkloadStatus() string
- func (v *VSHandler) IsActiveJobPresent(name, namespace string) (bool, error)
- func (v *VSHandler) IsActiveVGSPresent(vgsNamespacedName types.NamespacedName) (bool, error)
- func (v *VSHandler) IsCopyMethodDirect() bool
- func (v *VSHandler) IsPVCInUseByNonRDPod(pvcNamespacedName types.NamespacedName) (bool, error)
- func (v *VSHandler) IsRDDataProtected(pvcName, pvcNamespace string) (bool, error)
- func (v *VSHandler) IsRSDataProtected(pvcName, pvcNamespace string) (bool, error)
- func (v *VSHandler) IsSnapshotReady(name, namespace string) (bool, error)
- func (v *VSHandler) IsSubmarinerEnabled() bool
- func (v *VSHandler) IsVRGInAdminNamespace() bool
- func (v *VSHandler) ModifyRSSpecForCephFS(rsSpec *ramendrv1alpha1.VolSyncReplicationSourceSpec, ...)
- func (v *VSHandler) PrecreateDestPVCIfEnabled(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec) (*string, error)
- func (v *VSHandler) PreparePVC(pvcNamespacedName types.NamespacedName, cgLabelVal string, ...) error
- func (v *VSHandler) ReconcileDiffLocalRD(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, pskSecretName string) (*volsyncv1alpha1.ReplicationDestination, error)
- func (v *VSHandler) ReconcileDiffLocalRS(rd *volsyncv1alpha1.ReplicationDestination, ...) (*volsyncv1alpha1.ReplicationSource, error)
- func (v *VSHandler) ReconcileRD(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, ...) (*volsyncv1alpha1.ReplicationDestination, ...)
- func (v *VSHandler) ReconcileRS(rsSpec ramendrv1alpha1.VolSyncReplicationSourceSpec, runFinalSync bool, ...) (bool, *volsyncv1alpha1.ReplicationSource, error)
- func (v *VSHandler) ReconcileServiceExportForRD(rd *volsyncv1alpha1.ReplicationDestination) error
- func (v *VSHandler) RetainPVForPVC(pvc corev1.PersistentVolumeClaim) error
- func (v *VSHandler) SetWorkloadStatus(status string)
- func (v *VSHandler) SetupTmpPVCForFinalSync(pvc *corev1.PersistentVolumeClaim) (bool, error)
- func (v *VSHandler) StripPVCOwnerReferences(pvc *corev1.PersistentVolumeClaim) error
- func (v *VSHandler) UndoAfterFinalSync(pvcName, pvcNamespace string) error
- func (v *VSHandler) UndoPVRetentionForPVC(pvc corev1.PersistentVolumeClaim) error
- func (v *VSHandler) UnprotectVolSyncPVC(pvc *corev1.PersistentVolumeClaim) error
- func (v *VSHandler) ValidateSecretAndAddVRGOwnerRef(secretName string) (bool, error)
- func (v *VSHandler) ValidateSnapshotAndEnsurePVC(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, ...) error
- func (v *VSHandler) WaitForMountJobDeletion(pvcName, pvcNamespace string) (bool, error)
Constants ¶
const ( ManagedClusterAddOnKind string = "ManagedClusterAddOn" ManagedClusterAddOnGroup string = "addon.open-cluster-management.io" ManagedClusterAddOnVersion string = "v1alpha1" VolsyncManagedClusterAddOnName string = "volsync" // Needs to have this name )
const ( ServiceExportKind string = "ServiceExport" ServiceExportGroup string = "multicluster.x-k8s.io" ServiceExportVersion string = "v1alpha1" VolumeSnapshotKind string = "VolumeSnapshot" VolumeSnapshotIsDefaultAnnotation string = "snapshot.storage.kubernetes.io/is-default-class" VolumeSnapshotIsDefaultAnnotationValue string = "true" PodVolumePVCClaimIndexName string = "spec.volumes.persistentVolumeClaim.claimName" VolumeAttachmentToPVIndexName string = "spec.source.persistentVolumeName" FinalSyncTriggerString string = "vrg-final-sync" PrepareForFinalSyncTriggerString string = "PREPARE-FOR-FINAL-SYNC-STOP-SCHEDULING" SchedulingIntervalMinLength int = 2 CronSpecMaxDayOfMonth int = 28 VolSyncDoNotDeleteLabel = "volsync.backube/do-not-delete" // TODO: point to volsync constant once it is available VolSyncDoNotDeleteLabelVal = "true" OwnerNameAnnotation = "ramendr.openshift.io/owner-name" OwnerNamespaceAnnotation = "ramendr.openshift.io/owner-namespace" // StorageClass label StorageIDLabel = "ramendr.openshift.io/storageid" PVAnnotationRetentionKey = "volumereplicationgroups.ramendr.openshift.io/volsync-retained" PVAnnotationRetentionValue = "retained" PVCFinalizerProtected = "volumereplicationgroups.ramendr.openshift.io/pvc-volsync-protection" // Prefix for the job that mounts unmounted PVC when RS is not found VolSyncMountJobNamePrefix = "volsync-pvc-mount-" )
const ( ServiceImportKind = "ServiceImport" ServiceImportVersion = "v1alpha1" )
Variables ¶
var DefaultRsyncServiceType corev1.ServiceType = corev1.ServiceTypeClusterIP
var DefaultScheduleCronSpec = "*/10 * * * *" // Every 10 mins
var LoadBalancerRsyncServiceType corev1.ServiceType = corev1.ServiceTypeLoadBalancer
Functions ¶
func CleanupSecretPropagation ¶
func CleanupSecretPropagation(ctx context.Context, k8sClient client.Client, ownerObject metav1.Object, log logr.Logger, ) error
Cleans up policy, placementrule and placementbinding used to replicate the volsync secret (if they exist) does not throw an error if they do not exist
func ConvertSchedulingIntervalToCronSpec ¶
Convert from schedulingInterval which is in the format of <num><m,h,d> to the format VolSync expects, which is cronspec: https://en.wikipedia.org/wiki/Cron#Overview
func DeployVolSyncToCluster ¶
func DeployVolSyncToCluster(ctx context.Context, k8sClient client.Client, managedClusterName string, log logr.Logger, ) error
Function to deploy Volsync from ACM to managed cluster via a ManagedClusterAddOn
Calling this function requires a clusterrole that can create/update ManagedClusterAddOns
Should be called from the Hub
func GetRD ¶
func GetRD(ctx context.Context, k8sClient client.Client, name, namespace string, log logr.Logger, ) (*volsyncv1alpha1.ReplicationDestination, error)
func PropagateSecretToClusters ¶
func PropagateSecretToClusters(ctx context.Context, k8sClient client.Client, sourceSecret *corev1.Secret, ownerObject metav1.Object, destClusters []string, destSecretName, destSecretNamespace string, log logr.Logger, ) error
Should be run from a hub - assumes the source secret exists on the hub cluster and should be propagated to destClusters. Creates Policy/PlacementRule/PlacementBinding on the hub in the same namespace as the source secret
func RDStatusReady ¶
func RDStatusReady(rd *volsyncv1alpha1.ReplicationDestination, log logr.Logger) bool
For ReplicationDestination - considered ready when a sync has completed - rsync address should be filled out in the status - latest image should be set properly in the status (at least one sync cycle has completed and we have a snapshot)
func ReconcileVolSyncReplicationSecret ¶
func ReconcileVolSyncReplicationSecret(ctx context.Context, k8sClient client.Client, ownerObject metav1.Object, secretName, secretNamespace string, log logr.Logger) (*corev1.Secret, error, )
Creates a new volsync replication secret on the cluster (should be called on the hub cluster). If the secret already exists, nop
Types ¶
type VSHandler ¶
type VSHandler struct {
// contains filtered or unexported fields
}
func NewVSHandler ¶
func (*VSHandler) AppendOrUpdateRdInfo ¶
func (v *VSHandler) AppendOrUpdateRdInfo( rdInfoList []ramendrv1alpha1.VolSyncReplicationDestinationInfo, newInfo ramendrv1alpha1.VolSyncReplicationDestinationInfo, ) []ramendrv1alpha1.VolSyncReplicationDestinationInfo
func (*VSHandler) CleanupAfterRSFinalSync ¶
func (*VSHandler) CleanupLocalResources ¶
func (v *VSHandler) CleanupLocalResources(lrs *volsyncv1alpha1.ReplicationSource) error
func (*VSHandler) CleanupPVClaimRefForPVCDeletion ¶
func (v *VSHandler) CleanupPVClaimRefForPVCDeletion(pvc corev1.PersistentVolumeClaim) error
CleanupPVClaimRefForPVCDeletion prepares the PV for rebinding before the PVC is deleted. Clears claimRef.UID, ResourceVersion, APIVersion while keeping Kind, Name, Namespace so the PV transitions to Available (not Released) and can rebind to a new PVC with the same name.
func (*VSHandler) CleanupRDNotInSpecList ¶
func (v *VSHandler) CleanupRDNotInSpecList(rdSpecList []ramendrv1alpha1.VolSyncReplicationDestinationSpec, repState ramendrv1alpha1.ReplicationState, ) error
func (*VSHandler) CopySecretToPVCNamespace ¶
func (*VSHandler) CreateCurrentStateSnapshot ¶
func (v *VSHandler) CreateCurrentStateSnapshot( rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, ) (string, error)
CreateCurrentStateSnapshot creates a VolumeSnapshot of the app PVC's current state. Used before diff sync rollback to capture the (possibly corrupted) state for diff calculation.
func (*VSHandler) DeleteLocalRD ¶
func (*VSHandler) DeleteMountJob ¶
DeleteMountJob deletes the mount job for a given PVC if it exists
func (*VSHandler) DeleteSnapshots ¶
func (*VSHandler) EnsureMountJobForUnmountedPVC ¶
func (v *VSHandler) EnsureMountJobForUnmountedPVC(rsSpec *ramendrv1alpha1.VolSyncReplicationSourceSpec, ) (bool, error)
func (*VSHandler) EnsurePVCforDirectCopy ¶
func (v *VSHandler) EnsurePVCforDirectCopy(ctx context.Context, rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, ) error
func (*VSHandler) EnsurePVCfromRD ¶
func (v *VSHandler) EnsurePVCfromRD(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, failoverAction bool, ) error
func (*VSHandler) EnsureVolSyncMoverJobLabels ¶
func (*VSHandler) EnsureVolSyncServiceImportLabels ¶
func (*VSHandler) GetMoverConfigForPVC ¶
func (v *VSHandler) GetMoverConfigForPVC(pvcName, pvcNamespace string) *ramendrv1alpha1.MoverConfig
func (*VSHandler) GetRsyncServiceType ¶
func (v *VSHandler) GetRsyncServiceType() *corev1.ServiceType
func (*VSHandler) GetVolumeSnapshotClassFromPVCStorageClass ¶
func (*VSHandler) GetVolumeSnapshotClasses ¶
func (v *VSHandler) GetVolumeSnapshotClasses() ([]snapv1.VolumeSnapshotClass, error)
func (*VSHandler) GetWorkloadStatus ¶
func (*VSHandler) IsActiveJobPresent ¶
func (*VSHandler) IsActiveVGSPresent ¶
func (v *VSHandler) IsActiveVGSPresent(vgsNamespacedName types.NamespacedName) (bool, error)
func (*VSHandler) IsCopyMethodDirect ¶
func (*VSHandler) IsPVCInUseByNonRDPod ¶
func (v *VSHandler) IsPVCInUseByNonRDPod(pvcNamespacedName types.NamespacedName) (bool, error)
func (*VSHandler) IsRDDataProtected ¶
Returns true if at least one sync has completed (we'll consider this "data protected")
func (*VSHandler) IsRSDataProtected ¶
func (*VSHandler) IsSnapshotReady ¶
IsSnapshotReady checks if a VolumeSnapshot has ReadyToUse=true.
func (*VSHandler) IsSubmarinerEnabled ¶
func (*VSHandler) IsVRGInAdminNamespace ¶
func (*VSHandler) ModifyRSSpecForCephFS ¶
func (v *VSHandler) ModifyRSSpecForCephFS(rsSpec *ramendrv1alpha1.VolSyncReplicationSourceSpec, storageClass *storagev1.StorageClass, )
Workaround for cephfs issue: FIXME: For CephFS only, there is a problem where restoring a PVC from snapshot can be very slow when there are a lot of files - on every replication cycle we need to create a PVC from snapshot in order to get a point-in-time copy of the source PVC to sync with the replicationdestination. If CephFS PVC, modify rsSpec AccessModes to use 'ReadOnlyMany'.
func (*VSHandler) PrecreateDestPVCIfEnabled ¶
func (v *VSHandler) PrecreateDestPVCIfEnabled(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, ) (*string, error)
func (*VSHandler) PreparePVC ¶
func (*VSHandler) ReconcileDiffLocalRD ¶
func (v *VSHandler) ReconcileDiffLocalRD( rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, pskSecretName string, ) (*volsyncv1alpha1.ReplicationDestination, error)
ReconcileDiffLocalRD creates a local ReplicationDestination with External spec for diff rollback.
func (*VSHandler) ReconcileDiffLocalRS ¶
func (v *VSHandler) ReconcileDiffLocalRS( rd *volsyncv1alpha1.ReplicationDestination, rdSpec *ramendrv1alpha1.VolSyncReplicationDestinationSpec, snapshotRef *corev1.TypedLocalObjectReference, currentStateSnapshotName string, pskSecretName, address string, ) (*volsyncv1alpha1.ReplicationSource, error)
ReconcileDiffLocalRS creates a local ReplicationSource with External spec for diff rollback.
func (*VSHandler) ReconcileRD ¶
func (v *VSHandler) ReconcileRD( rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, moverConfig *ramendrv1alpha1.MoverConfig) (*volsyncv1alpha1.ReplicationDestination, *ramendrv1alpha1.VolSyncReplicationDestinationInfo, error, )
returns replication destination only if create/update is successful and the RD is considered available. Callers should assume getting a nil replication destination back means they should retry/requeue.
func (*VSHandler) ReconcileRS ¶
func (v *VSHandler) ReconcileRS(rsSpec ramendrv1alpha1.VolSyncReplicationSourceSpec, runFinalSync bool, moverConfig *ramendrv1alpha1.MoverConfig) (bool, *volsyncv1alpha1.ReplicationSource, error, )
Returns true only if runFinalSync is true and the final sync is done Returns replication source only if create/update is successful Callers should assume getting a nil replication source back means they should retry/requeue. Returns true/false if final sync is complete, and also returns an RS if one was reconciled.
func (*VSHandler) ReconcileServiceExportForRD ¶
func (v *VSHandler) ReconcileServiceExportForRD(rd *volsyncv1alpha1.ReplicationDestination) error
Make sure a ServiceExport exists to export the service for this RD to remote clusters When diff sync is enabled, uses the ceph-volsync-plugin service name instead of rsync-tls. See: https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/ 2.4/html/services/services-overview#enable-service-discovery-submariner
func (*VSHandler) RetainPVForPVC ¶
func (v *VSHandler) RetainPVForPVC(pvc corev1.PersistentVolumeClaim) error
func (*VSHandler) SetWorkloadStatus ¶
func (*VSHandler) SetupTmpPVCForFinalSync ¶
func (v *VSHandler) SetupTmpPVCForFinalSync(pvc *corev1.PersistentVolumeClaim) (bool, error)
Handles the creation and management of the tmpPVC for final sync
func (*VSHandler) StripPVCOwnerReferences ¶
func (v *VSHandler) StripPVCOwnerReferences(pvc *corev1.PersistentVolumeClaim) error
StripPVCOwnerReferences removes any VRG, RS, or RD ownerReferences from the PVC. This is a migration step for PVCs that were protected by older versions of Ramen which set ownerReferences on PVCs. Without this, upgrading and then disabling DR would still trigger Kubernetes GC on those PVCs.
func (*VSHandler) UndoAfterFinalSync ¶
func (*VSHandler) UndoPVRetentionForPVC ¶
func (v *VSHandler) UndoPVRetentionForPVC(pvc corev1.PersistentVolumeClaim) error
func (*VSHandler) UnprotectVolSyncPVC ¶
func (v *VSHandler) UnprotectVolSyncPVC(pvc *corev1.PersistentVolumeClaim) error
func (*VSHandler) ValidateSecretAndAddVRGOwnerRef ¶
func (*VSHandler) ValidateSnapshotAndEnsurePVC ¶
func (v *VSHandler) ValidateSnapshotAndEnsurePVC(rdSpec ramendrv1alpha1.VolSyncReplicationDestinationSpec, snapshotRef corev1.TypedLocalObjectReference, failoverAction bool, ) error