controllers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 85 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DRClusterConditionReasonInitializing = "Initializing"
	DRClusterConditionReasonFencing      = "Fencing"
	DRClusterConditionReasonUnfencing    = "Unfencing"
	DRClusterConditionReasonCleaning     = "Cleaning"
	DRClusterConditionReasonFenced       = "Fenced"
	DRClusterConditionReasonUnfenced     = "Unfenced"
	DRClusterConditionReasonClean        = "Clean"
	DRClusterConditionReasonValidated    = "Succeeded"

	DRClusterConditionReasonFenceError   = "FenceError"
	DRClusterConditionReasonUnfenceError = "UnfenceError"
	DRClusterConditionReasonCleanError   = "CleanError"

	DRClusterConditionReasonError        = "Error"
	DRClusterConditionReasonErrorUnknown = "UnknownError"
)

DRCluster condition reasons

View Source
const (
	StorageAnnotationSecretName      = "drcluster.ramendr.openshift.io/storage-secret-name"
	StorageAnnotationSecretNamespace = "drcluster.ramendr.openshift.io/storage-secret-namespace"
	StorageAnnotationClusterID       = "drcluster.ramendr.openshift.io/storage-clusterid"
	StorageAnnotationDriver          = "drcluster.ramendr.openshift.io/storage-driver"
)
View Source
const (
	DRClusterConfigConditionReasonInitializing = "Initializing"

	DRClusterConfigConditionConfigurationProcessed = "Succeeded"
	DRClusterConfigConditionConfigurationFailed    = "Failed"

	DRClusterConfigS3Reachable   = "Reachable"
	DRClusterConfigS3Unreachable = "Unreachable"
	NADCRDMissing                = "NADCRDMissing"
	NADWatchNotRegistered        = "NADWatchNotRegistered"
	StaticIPDiscoveryEnabled     = "StaticIPDiscoveryEnabled"
)

DRClusterConfig condition reasons

View Source
const (
	NADDRNetworkLabel      = "ramendr.openshift.io/dr-network"
	NADResourceName        = "network-attachment-definitions.k8s.cni.cncf.io"
	StaticIPDiscoveryReady = "StaticIPDiscoveryReady"
)

NADDRNetworkLabel is an opt-in marker for Ramen's static-IP disaster recovery workflow.

NADs labeled with:

ramendr.openshift.io/dr-network: "true"

are included in DR network discovery and validation. NADs labeled "false", or NADs that do not carry this label, are ignored.

View Source
const (
	// Annotations for MW and PlacementRule
	DRPCNameAnnotation      = "drplacementcontrol.ramendr.openshift.io/drpc-name"
	DRPCNamespaceAnnotation = "drplacementcontrol.ramendr.openshift.io/drpc-namespace"

	// Annotation that stores the UID of DRPC that created the resource on the managed cluster using a ManifestWork
	DRPCUIDAnnotation = "drplacementcontrol.ramendr.openshift.io/drpc-uid"

	// Annotation for the last cluster on which the application was running
	LastAppDeploymentCluster = "drplacementcontrol.ramendr.openshift.io/last-app-deployment-cluster"

	// Annotation for application namespace on the managed cluster
	DRPCAppNamespace = "drplacementcontrol.ramendr.openshift.io/app-namespace"

	// Annotation to mark test failover (dry-run) mode
	DRPCTestFailoverDryRunAnnotation = "drplacementcontrol.ramendr.openshift.io/test-failover-dryrun"

	// DRPCTestFailoverDryRunAnnotationValueTrue is the value set in the test failover annotation
	DRPCTestFailoverDryRunAnnotationValueTrue = "true"

	// Annotation for the last action performed on the DRPC
	DRPCLastAction = "drplacementcontrol.ramendr.openshift.io/last-action"

	// DRPCNetworkMappingAnnotation references a ConfigMap (by name, same namespace) that
	// holds the bidirectional cluster-pair network subnet mappings for VM static-IP translation.
	// Value is the ConfigMap name; namespace defaults to the DRPC namespace.
	DRPCNetworkMappingAnnotation = "drplacementcontrol.ramendr.openshift.io/network-mapping"
)
View Source
const (
	DRTypeSync  = DRType("sync")
	DRTypeAsync = DRType("async")
)
View Source
const (
	// DRPC CR finalizer
	DRPCFinalizer string = "drpc.ramendr.openshift.io/finalizer"

	// Ramen scheduler
	RamenScheduler string = "ramen"

	ClonedPlacementRuleNameFormat string = "drpc-plrule-%s-%s"

	// StatusCheckDelay is used to frequencly update the DRPC status when the reconciler is idle.
	// This is needed in order to sync up the DRPC status and the VRG status.
	StatusCheckDelay = time.Minute * 10

	// PlacementDecisionName format, prefix is the Placement name, and suffix is a PlacementDecision index
	PlacementDecisionName = "%s-decision-%d"

	// PlacementDecisionReasonFailoverRetained is a reason added to retain a cluster decision that the DRPC
	// failed over from. It is to aid deletion of the decision once VRG is noted as Secondary on the cluster
	PlacementDecisionReasonFailoverRetained = "RetainedForFailover"

	// Maximum retries to create PlacementDecisionName with an increasing index in case of conflicts
	// with existing PlacementDecision resources
	MaxPlacementDecisionConflictCount = 5

	DestinationClusterAnnotationKey = "drplacementcontrol.ramendr.openshift.io/destination-cluster"

	IsSubmarinerEnabledAnnotation    = "drplacementcontrol.ramendr.openshift.io/is-submariner-enabled"
	IsSubmarinerEnabledAnnotationVal = "true"
)
View Source
const (
	Continue      = 1
	AllowFailover = 2
	Stop          = 3
)
View Source
const (
	LastSyncTimestampSeconds = "last_sync_timestamp_seconds"
	LastSyncDurationSeconds  = "last_sync_duration_seconds"
	LastSyncDataBytes        = "last_sync_data_bytes"
	WorkloadProtectionStatus = "workload_protection_status"
	CGEnabled                = "unsupported_consistency_grouping_enabled"
	GlobalActionStatus       = "global_action_consensus_status"
	// Added for drpc progression state
	DRProgressionState = "progression_state"
)
View Source
const (
	InvalidCIDRsDetected = "invalid_cidrs_detected"
	UndetectedCIDRsFound = "undetected_cidrs_found"
)
View Source
const (
	DRPolicyTypeName    = "dr_policy_type"
	DRProtectedAppsName = "dr_protected_apps"
	DRActionsName       = "dr_actions"
)

DR telemetry metrics, forwarded to Red Hat Telemetry via the cluster-monitoring-operator allowlist. Label cardinality is bounded (3 + 2 + 2 = 7 series) as required by telemetry.

View Source
const (
	DRTypeLabel           = "dr_type"
	ManagementMethodLabel = "management_method"
	ActionLabel           = "action"
)
View Source
const (
	DRTypeMetro    = "metro"
	DRTypeRegional = "regional"
	DRTypeUnknown  = "unknown"

	ManagementMethodDiscovered = "discovered"
	ManagementMethodManaged    = "managed"

	ActionFailover = "failover"
	ActionRelocate = "relocate"
)
View Source
const (
	ObjType               = "obj_type"
	ObjName               = "obj_name"
	ObjNamespace          = "obj_namespace"
	Policyname            = "policyname"
	SchedulingInterval    = "scheduling_interval"
	ProgressionStateLabel = "state"
)
View Source
const (
	HubOperatorConfigMapName       = hubOperatorNameDefault + configMapNameSuffix
	DrClusterOperatorConfigMapName = drClusterOperatorNameDefault + configMapNameSuffix

	HubLeaderElectionResourceName = hubName + leaderElectionResourceNameSuffix

	ConfigMapRamenConfigKeyName = "ramen_manager_config.yaml"

	DefaultCephFSCSIDriverName = "openshift-storage.cephfs.csi.ceph.com"
	VeleroNamespaceNameDefault = "velero"

	DefaultVolSyncCopyMethod = "Snapshot"
)
View Source
const (
	// PV data is ready. When failing over or relocating an app to a different
	// cluster, app's PVC will be able to access the storage volume only after
	// this condition is true.
	VRGConditionTypeDataReady = "DataReady"

	// PV data is protected. This means that, the PV data from the storage
	// is in complete sync with its remote peer.
	VRGConditionTypeDataProtected = "DataProtected"

	// PV cluster data is ready.  When failing over or relocating an app to a
	// different cluster, deploying the app prior to ClusterDataReady condition
	// could result in the PVCs binding to newly created PVs instead of binding
	// to their corresponding replicated PVs.  App's PVC should be deployed only
	// after this condition is true.
	VRGConditionTypeClusterDataReady = "ClusterDataReady"

	// Kube objects are ready. This condition is used to indicate that all the
	// Kube objects required for the app to be active in the cluster are ready.
	VRGConditionTypeKubeObjectsReady = "KubeObjectsReady"

	// PV cluster data is protected.  This condition indicates whether an app,
	// which is active in a cluster, has all its PV related cluster data
	// protected from a disaster by uploading it to the required S3 store(s).
	VRGConditionTypeClusterDataProtected = "ClusterDataProtected"

	// Adds explicit visibility into the controller’s automatic cleanup workflow for VM/PVC
	// resources after DR operations (e.g., failover/relocate). This condition helps operators
	// and automation understand whether cleanup is in progress, blocked, or completed.
	VRGConditionTypeAutoCleanup = "AutoCleanup"
	// VolSync related conditions. These conditions are only applicable
	// at individual PVCs and not generic VRG conditions.
	VRGConditionTypeVolSyncRepSourceSetup      = "ReplicationSourceSetup"
	VRGConditionTypeVolSyncFinalSyncInProgress = "FinalSyncInProgress"
	VRGConditionTypeVolSyncRepDestinationSetup = "ReplicationDestinationSetup"
	VRGConditionTypeVolSyncPVsRestored         = "PVsRestored"

	// Indicates no conflict in PVC and Kubernetes resource data
	// between primary and secondary clusters.
	VRGConditionTypeNoClusterDataConflict = "NoClusterDataConflict"

	// Indicates whether all VRGs sharing the same global VGR label have
	// reached the desired replication state.
	VRGConditionTypeGlobalState = "GlobalState"

	// Indicates whether this VRG's PVCs are not in use, allowing the shared
	// global VGR to transition to secondary. Only applicable for global VGR VRGs.
	VRGConditionTypeGlobalSecondary = "GlobalSecondary"

	// Indicates the status of hook execution in recipes.
	// This condition helps identify hook failures separately from other kube object protection issues.
	VRGConditionTypeHooksReady = "HooksReady"
	// Indicates destination volume info is available from the VolumeReplication resource.
	// Only set when VRs report this condition; absent means not applicable.
	VRGConditionTypeDestinationInfoAvailable = "DestinationInfoAvailable"
)

VRG status condition types. These condition are applicable at the VRG summary level and at the individual PVC level. The ClusterDataReady condition is only applicable at the VRG summary level and is not a condition that applies to individual PVCs.

View Source
const (
	VRGConditionReasonUnused                      = "Unused"
	VRGConditionReasonInitializing                = "Initializing"
	VRGConditionReasonReplicating                 = "Replicating"
	VRGConditionReasonReplicated                  = "Replicated"
	VRGConditionReasonReady                       = "Ready"
	VRGConditionReasonDataProtected               = "DataProtected"
	VRGConditionReasonProgressing                 = "Progressing"
	VRGConditionReasonClusterDataRestored         = "Restored"
	VRGConditionReasonClusterDataUnused           = "Unused"
	VRGConditionReasonKubeObjectsRestored         = "KubeObjectsRestored"
	VRGConditionReasonKubeObjectsUnused           = "Unused"
	VRGConditionReasonError                       = "Error"
	VRGConditionReasonErrorUnknown                = "UnknownError"
	VRGConditionReasonUploading                   = "Uploading"
	VRGConditionReasonUploaded                    = "Uploaded"
	VRGConditionReasonUploadError                 = "UploadError"
	VRGConditionReasonVolSyncRepSourceInited      = "SourceInitialized"
	VRGConditionReasonVolSyncRepDestInited        = "DestinationInitialized"
	VRGConditionReasonVolSyncPVsRestored          = "Restored"
	VRGConditionReasonVolSyncFinalSyncInProgress  = "Syncing"
	VRGConditionReasonVolSyncFinalSyncComplete    = "Synced"
	VRGConditionReasonClusterDataAnnotationFailed = "AnnotationFailed"
	VRGConditionReasonPeerClassNotFound           = "PeerClassNotFound"
	VRGConditionReasonStorageIDNotFound           = "StorageIDNotFound"
	// Indicates a conflict in cluster data detected on the primary cluster.
	VRGConditionReasonClusterDataConflictPrimary = "ClusterDataConflictPrimary"

	// Indicates a conflict in cluster data detected on the secondary cluster.
	VRGConditionReasonClusterDataConflictSecondary = "ClusterDataConflictSecondary"

	// Indicates no conflict in cluster data detected on both the primary and secondary cluster.
	VRGConditionReasonNoConflictDetected = "NoConflictDetected"

	VRGConditionReasonAutoCleanupProgressing = "Progressing"
	VRGConditionReasonAutoCleanupNotFeasible = "NotFeasible"
	VRGConditionReasonAutoCleanupCompleted   = "Completed"

	// Global consensus reasons for GlobalState condition.
	ConditionReasonConsensusReached    = "ConsensusReached"
	ConditionReasonConsensusNotReached = "ConsensusNotReached"

	// Global secondary transition reasons for GlobalSecondary condition.
	VRGConditionReasonPVCsNotInUse = "PVCsNotInUse"
	VRGConditionReasonPVCsInUse    = "PVCsInUse"

	// Hook-specific condition reasons for better visibility of hook failures
	VRGConditionReasonHookExecuted = "HookExecuted"
	VRGConditionReasonHookFailed   = "HookFailed"
)

VRG condition reasons

View Source
const (
	PvcVRFinalizerProtected = "volumereplicationgroups.ramendr.openshift.io/pvc-vr-protection"

	RestoreAnnotation = "volumereplicationgroups.ramendr.openshift.io/ramen-restore"
	RestoredByRamen   = "True"

	// StorageClass label
	StorageIDLabel = "ramendr.openshift.io/storageid"

	// StorageClass offloaded label
	StorageOffloadedLabel = "ramendr.openshift.io/offloaded"

	// VolumeReplicationClass and VolumeGroupReplicationClass label
	ReplicationIDLabel = "ramendr.openshift.io/replicationid"

	// VolumeGroupReplicationClass label
	GroupReplicationIDLabel = "ramendr.openshift.io/groupreplicationid"

	// VolumeGroupReplicationClass global label
	GlobalReplicationLabel = "ramendr.openshift.io/global"

	// Maintenance mode label
	MModesLabel = "ramendr.openshift.io/maintenancemodes"

	// VolumeReplicationClass and VolumeGroupReplicationClass schedule parameter key
	ReplicationClassScheduleKey = "schedulingInterval"
)
View Source
const (
	WorkflowAnyError       = "any-error"
	WorkflowEssentialError = "essential-error"
	WorkflowFullError      = "full-error"
)
View Source
const AllDRPolicyAnnotation = "drpolicy.ramendr.openshift.io"

AllDRPolicyAnnotation is added to related resources that can be watched to reconcile all related DRPolicy resources

View Source
const ConditionNetworkAttachmentsValidated = "NetworkAttachmentsValidated"

ConditionNetworkAttachmentsValidated is set on DRPolicy.Status.Conditions when NAD-pair validation has run.

  • True: all NADs used by static-IP VMs are present on both clusters.
  • False: one or more NADs are missing; the message lists them.
View Source
const DRActionCountAnnotation = "drplacementcontrol.ramendr.openshift.io/dr-action-count"

DRActionCountAnnotation persists the cumulative failover and relocate action counts on a DRPC, so that the counts survive operator restarts and hub recovery. lastPhase records the last accounted status.phase, ensuring each initiated action is counted exactly once across retried reconciles.

View Source
const (
	DRClusterNameAnnotation = "drcluster.ramendr.openshift.io/drcluster-name"
)
View Source
const DRClusterPairCount = 2
View Source
const (
	DRPolicySyncIntervalSeconds = "policy_schedule_interval_seconds"
)
View Source
const GlobalVGRLabel = "ramendr.openshift.io/global-vgr"

VRG and DRPC label to associate them with a shared VolumeGroupReplication resource.

View Source
const (
	NetworkFencePrefix = "network-fence"
)
View Source
const NoS3StoreAvailable = "NoS3"

FIXME

View Source
const ReasonDRClusterNotFound = "DRClusterNotFound"

ReasonDRClusterNotFound is set when the DRPolicy could not find the referenced DRCluster(s)

View Source
const ReasonDRClustersUnavailable = "DRClustersUnavailable"

ReasonDRClustersUnavailable is set when the DRPolicy has none of the referenced DRCluster(s) are in a validated state

View Source
const ReasonDRPolicyConflictFound = "DRPolicyConflictFound"

ReasonDRPolicyConflictFound is set when the DRPolicy has overlapping metro clusters with another DRPolicy

View Source
const ReasonNoEligibleNetworkAttachments = "NoEligibleNetworkAttachments"

ReasonNoEligibleNetworkAttachments is set on NetworkAttachmentsValidated when no NADs eligible for static-IP translation were discovered on either cluster; symmetry is trivially satisfied.

View Source
const ReasonSucceeded = "Succeeded"

ReasonSucceeded is set when the DRPolicy validation completes successfully

View Source
const ReasonValidationFailed = "ValidationFailed"

ReasonValidationFailed is set when the DRPolicy could not be validated or is not valid

View Source
const RecipeMaxAttempts = 10

Variables

View Source
var (
	ErrWaitForAppResourceRestoreToComplete = errors.New("waiting for App resources to be restored")
	ErrWaitForVolSyncDestRepToComplete     = errors.New("waiting for VolSync RD to complete")
	ErrWaitForSourceCluster                = errors.New("waiting for primary to provide Protected PVCs")
	ErrWaitForVolSyncManifestWorkCreation  = errors.New("waiting for secondary ManifestWork to be created")
	ErrWaitForVolSyncRDInfoAvailability    = errors.New("waiting for VolSync RDInfo")
)
View Source
var (
	ErrVolumeCaptureNotSupported = errors.New("volume capture not supported")
	ErrVolumeRecoverNotSupported = errors.New("volume recover not supported")
)
View Source
var ErrInitialWaitTimeForDRPCPlacementRule = errors.New("waiting for DRPC Placement to produces placement decision")
View Source
var ErrWorkflowNotFound = fmt.Errorf("backup or restore workflow not found")

Functions

func AvailableS3Profiles

func AvailableS3Profiles(drClusters []rmn.DRCluster) []string

func CGEnabledMetricLabels

func CGEnabledMetricLabels(drpc *rmn.DRPlacementControl) prometheus.Labels

CGEnabled Metric reports information if consistency grouping is enabled for a DRPC

func ConfigMapGet

func ConfigMapGet(
	ctx context.Context,
	apiReader client.Reader,
) (configMap *corev1.ConfigMap, ramenConfig *ramendrv1alpha1.RamenConfig, err error)

func ConfigMapNew

func ConfigMapNew(
	namespaceName string,
	name string,
	ramenConfig *ramendrv1alpha1.RamenConfig,
) (*corev1.ConfigMap, error)

func ConvertToPlacement

func ConvertToPlacement(placementObj interface{}) *clrapiv1beta1.Placement

func ConvertToPlacementRule

func ConvertToPlacementRule(placementObj interface{}) *plrv1.PlacementRule

func CreateOrUpdateConfigMap

func CreateOrUpdateConfigMap(
	ctx context.Context,
	c client.Client,
	r client.Reader,
	defaultRamenConfig *ramendrv1alpha1.RamenConfig,
	log logr.Logger,
) (*ramendrv1alpha1.RamenConfig, error)

func DRClusterCIDRsMetricLabels

func DRClusterCIDRsMetricLabels(drc *rmn.DRCluster) prometheus.Labels

InvalidCIDRsDetected Metric reports if CIDRs configured are valid for fencing

func DRClusterPredicateFunc

func DRClusterPredicateFunc() predicate.Funcs

func DRClusterUpdateOfInterest

func DRClusterUpdateOfInterest(oldDRCluster, newDRCluster *rmn.DRCluster) bool

DRClusterUpdateOfInterest checks if the new DRCluster resource as compared to the older version requires any attention, it checks for the following updates:

  • If any maintenance mode is reported as activated
  • If drcluster was marked for deletion

TODO: Needs some logs for easier troubleshooting

func DRPCUpdateOfInterest

func DRPCUpdateOfInterest(oldDRPC, newDRPC *ramen.DRPlacementControl) bool

DRPCUpdateOfInterest returns a bool, which is true if the update to DRPC requires further processing

func DRPCsFailingOverToClusterForPolicy

func DRPCsFailingOverToClusterForPolicy(
	k8sclient client.Client,
	log logr.Logger,
	drpolicy *rmn.DRPolicy,
	drcluster string,
) ([]*rmn.DRPlacementControl, error)

DRPCsFailingOverToClusterForPolicy filters DRPC resources that reference the DRPolicy and are failing over to the target cluster passed in

func DRPCsUsingDRPolicy

func DRPCsUsingDRPolicy(
	k8sclient client.Client,
	log logr.Logger,
	drpolicy *rmn.DRPolicy,
) ([]*rmn.DRPlacementControl, error)

DRPCsUsingDRPolicy finds DRPC resources that reference the DRPolicy.

func DRPolicyPredicateFunc

func DRPolicyPredicateFunc() predicate.Funcs

func DRPolicySyncIntervalMetricLabels

func DRPolicySyncIntervalMetricLabels(drPolicy *rmn.DRPolicy) prometheus.Labels

dRPolicySyncInterval Metrics reports the value from schedulingInterval from DRPolicy

func DRProgressionStateMetricLabels

func DRProgressionStateMetricLabels(drpc *rmn.DRPlacementControl,
	state string,
) prometheus.Labels

func DefaultRamenConfig

func DefaultRamenConfig(controllerType ramendrv1alpha1.ControllerType) *ramendrv1alpha1.RamenConfig

func DeleteCGEnabledMetric

func DeleteCGEnabledMetric(labels prometheus.Labels) bool

func DeleteDRPCProgressionStateMetric

func DeleteDRPCProgressionStateMetric(labels prometheus.Labels) bool

func DeleteDRPolicySyncIntervalMetrics

func DeleteDRPolicySyncIntervalMetrics(labels prometheus.Labels) bool

func DeleteGlobalActionMetric

func DeleteGlobalActionMetric(labels prometheus.Labels) bool

func DeleteInvalidCIDRsDetectedMetric

func DeleteInvalidCIDRsDetectedMetric(labels prometheus.Labels) bool

func DeleteSyncDataBytesMetric

func DeleteSyncDataBytesMetric(labels prometheus.Labels) bool

func DeleteSyncDurationMetric

func DeleteSyncDurationMetric(labels prometheus.Labels) bool

func DeleteSyncTimeMetric

func DeleteSyncTimeMetric(labels prometheus.Labels) bool

func DeleteTypedObject

func DeleteTypedObject(s ObjectStorer, keyPrefix, keySuffix string, object interface{},
) error

func DeleteUndetectedCIDRsFoundMetric

func DeleteUndetectedCIDRsFoundMetric(labels prometheus.Labels) bool

func DeleteWorkloadProtectionStatusMetric

func DeleteWorkloadProtectionStatusMetric(labels prometheus.Labels) bool

func DeprecatedManagerOptionWarnings

func DeprecatedManagerOptionWarnings(ramenConfig *ramendrv1alpha1.RamenConfig, options *ctrl.Options) []string

DeprecatedManagerOptionWarnings returns a warning for each manager option still present in the RamenConfig that differs from the effective manager options. These RamenConfig fields are deprecated and ignored: the manager options are set only via command line flags.

func DownloadTypedObject

func DownloadTypedObject(s ObjectStorer, keyPrefix, keySuffix string, objectPointer interface{},
) error

func DownloadTypedObjects

func DownloadTypedObjects(s ObjectStorer, keyPrefix string, objectsPointer interface{},
) error

DownloadTypedObjects downloads all objects of the given type that have the given key prefix followed by the given object's type keyInfix.

  • Example key prefix: namespace/vrgName/ Example key infix: v1.PersistentVolumeClaim/ Example new key prefix: namespace/vrgName/v1.PersistentVolumeClaim/
  • Objects being downloaded should meet the decoding expectations of the DownloadObject() method.

func DownloadVRGs

func DownloadVRGs(s ObjectStorer, pvKeyPrefix string) (
	vrgList []ramen.VolumeReplicationGroup, err error,
)

func FindProtectedPVC

func FindProtectedPVC(vrg *ramen.VolumeReplicationGroup, pvcNamespaceName, pvcName string) *ramen.ProtectedPVC

func FindProtectedPvcAndIndex

func FindProtectedPvcAndIndex(
	vrg *ramen.VolumeReplicationGroup, pvcNamespaceName, pvcName string,
) (*ramen.ProtectedPVC, int)

func GetAvailableS3Profiles

func GetAvailableS3Profiles(ctx context.Context, client client.Client,
	drpc *rmn.DRPlacementControl, log logr.Logger,
) []string

func GetDRClusters

func GetDRClusters(ctx context.Context, client client.Client, drPolicy *rmn.DRPolicy) ([]rmn.DRCluster, error)

func GetDRPolicy

func GetDRPolicy(ctx context.Context, client client.Client,
	drpc *rmn.DRPlacementControl, log logr.Logger,
) (*rmn.DRPolicy, error)

func GetLastKnownVRGPrimaryFromS3

func GetLastKnownVRGPrimaryFromS3(
	ctx context.Context,
	apiReader client.Reader,
	s3ProfileNames []string,
	sourceVrgName string,
	sourceVrgNamespace string,
	objectStoreGetter ObjectStoreGetter,
	log logr.Logger,
) *rmn.VolumeReplicationGroup

func GetPVCSelector

func GetPVCSelector(ctx context.Context, reader client.Reader, vrg ramen.VolumeReplicationGroup,
	ramenConfig ramen.RamenConfig,
	log logr.Logger,
) (util.PvcSelector, error)

func GetRamenConfigS3StoreProfile

func GetRamenConfigS3StoreProfile(ctx context.Context, apiReader client.Reader, profileName string) (
	s3StoreProfile ramendrv1alpha1.S3StoreProfile, err error,
)

func GetS3Secret

func GetS3Secret(ctx context.Context, r client.Reader,
	secretRef corev1.SecretReference) (
	s3AccessID, s3SecretAccessKey []byte, err error,
)

func GetSClassesFromCluster

func GetSClassesFromCluster(
	log logr.Logger,
	m util.ManagedClusterViewGetter,
	drcConfig *ramen.DRClusterConfig,
	clusterName string,
) ([]*storagev1.StorageClass, error)

GetSClassesFromCluster gets StorageClasses that are claimed in the DRClusterConfig status

func GlobalActionLabels

func GlobalActionLabels(drpc *rmn.DRPlacementControl) prometheus.Labels

func GlobalVGRDRPCPredicateFunc

func GlobalVGRDRPCPredicateFunc() predicate.Funcs

func HasConflictingDRPolicy

func HasConflictingDRPolicy(
	match *ramen.DRPolicy,
	list ramen.DRPolicyList,
	drClusterIDsToNames map[string]string,
) error

If two drpolicies have common managed cluster(s) and at least one of them is a metro supported drpolicy, then fail.

func InitDRTelemetryMetrics

func InitDRTelemetryMetrics()

InitDRTelemetryMetrics initializes all DR telemetry metric label combinations to 0, so that a series being present with value 0 indicates Ramen is installed with no DR resources, as opposed to an absent series

func IsPreRelocateProgression

func IsPreRelocateProgression(status rmn.ProgressionStatus) bool

func LeaderElectionResourceName

func LeaderElectionResourceName(controllerType ramendrv1alpha1.ControllerType) string

LeaderElectionResourceName returns the leader election lease name for the given controller type.

func LoadControllerConfig

func LoadControllerConfig(log logr.Logger) (ramenConfig *ramendrv1alpha1.RamenConfig)

func MModesFromCSV

func MModesFromCSV(modes string) []ramendrv1alpha1.MMode

func ManagedClusterViewPredicateFunc

func ManagedClusterViewPredicateFunc() predicate.Funcs

func ManifestWorkPredicateFunc

func ManifestWorkPredicateFunc() predicate.Funcs

func MetricsServerOptions

func MetricsServerOptions(bindAddress string) metricsserver.Options

MetricsServerOptions returns the manager metrics server options for the given bind address. A bind address of "0" disables the metrics server.

func ParseDoubleSlash

func ParseDoubleSlash(input string) string

func ParseNetworkName

func ParseNetworkName(networkName string, vmNamespace string) (nadNamespace, nadName string)

func ParseRemoveSlashes

func ParseRemoveSlashes(input string) string

func ParseSingleSlash

func ParseSingleSlash(input string) string

func PlacementPredicateFunc

func PlacementPredicateFunc() predicate.Funcs

func PlacementRulePredicateFunc

func PlacementRulePredicateFunc() predicate.Funcs

func PruneAnnotations

func PruneAnnotations(annotations map[string]string) map[string]string

pruneAnnotations takes a map of annotations and removes the annotations where the key start with:

  • pv.kubernetes.io
  • replication.storage.openshift.io
  • volumereplicationgroups.ramendr.openshift.io
  • volsync.backube

Parameters:

annotations: the map of annotations to prune

Returns:

a new map containing only the remaining annotations

func RamenConfigS3StoreProfilePointerGet

func RamenConfigS3StoreProfilePointerGet(ramenConfig *ramendrv1alpha1.RamenConfig, profileName string,
) *ramendrv1alpha1.S3StoreProfile

func RamenOperandsNamespace

func RamenOperandsNamespace(config ramendrv1alpha1.RamenConfig) string

func RamenOperatorNamespace

func RamenOperatorNamespace() string

func RecipeElementsGet

func RecipeElementsGet(ctx context.Context, reader client.Reader, vrg ramen.VolumeReplicationGroup,
	ramenConfig ramen.RamenConfig, log logr.Logger,
) (util.RecipeElements, error)

func RecipeParametersExpand

func RecipeParametersExpand(ctx context.Context, recipe *recipev1.Recipe, parameters map[string][]string,
	log logr.Logger,
) error

func RequiresDRPCReconciliation

func RequiresDRPCReconciliation(oldDRPolicy, newDRPolicy *rmn.DRPolicy) bool

RequiresDRPCReconciliation determines if the updated DRPolicy resource, compared to the previous version, requires reconciliation of the DRPCs. Reconciliation is needed if the DRPolicy has been newly activated, or peerClasses have been updated in the DRPolicy status. This check helps avoid delays in reconciliation by ensuring timely updates when necessary.

func S3KeyPrefix

func S3KeyPrefix(namespacedName string) string

func SetDRActionsMetric

func SetDRActionsMetric(action string, value float64)

SetDRActionsMetric sets the cumulative count of DR actions for an action (ActionFailover or ActionRelocate)

func SetDRPolicyTypeMetric

func SetDRPolicyTypeMetric(drType string, value float64)

SetDRPolicyTypeMetric sets the count of DRPolicy resources for a DR type (DRTypeMetro, DRTypeRegional or DRTypeUnknown)

func SetDRProtectedAppsMetric

func SetDRProtectedAppsMetric(method string, value float64)

SetDRProtectedAppsMetric sets the count of DRPC resources for a management method (ManagementMethodDiscovered or ManagementMethodManaged)

func SubscriptionFromDrClusterManifestWork

func SubscriptionFromDrClusterManifestWork(
	mwu *util.MWUtil,
	clusterName string,
) (*operatorsv1alpha1.Subscription, error)

func SyncDataBytesMetricLabels

func SyncDataBytesMetricLabels(drPolicy *rmn.DRPolicy, drpc *rmn.DRPlacementControl) prometheus.Labels

lastSyncDataBytes Metric reports value from lastGroupSyncBytes taken from DRPC status

func SyncDurationMetricLabels

func SyncDurationMetricLabels(drPolicy *rmn.DRPolicy, drpc *rmn.DRPlacementControl) prometheus.Labels

lastSyncDuration Metrics reports value from lastGroupSyncDuration from DRPC status

func SyncTimeMetricLabels

func SyncTimeMetricLabels(drPolicy *rmn.DRPolicy, drpc *rmn.DRPlacementControl) prometheus.Labels

lastSyncTime metrics reports value from lastGrpupSyncTime taken from DRPC status

func TypedObjectKey

func TypedObjectKey(prefix, suffix string, object interface{}) string

func UpdateDRTelemetryMetrics

func UpdateDRTelemetryMetrics(ctx context.Context, c client.Client) error

UpdateDRTelemetryMetrics recomputes all DR telemetry metrics from the DRPolicy and DRPC resources in the cluster. Every series is Set on every call, so deletions and classification changes are reflected without any per-resource increment/decrement bookkeeping.

func UploadPV

func UploadPV(s ObjectStorer, pvKeyPrefix, pvKeySuffix string,
	pv corev1.PersistentVolume,
) error

UploadPV uploads the given PV to the bucket with a key of "<pvKeyPrefix><v1.PersistentVolume/><pvKeySuffix>". - pvKeyPrefix should have any required delimiters like '/' - OK to call UploadPV() concurrently from multiple goroutines safely.

func UploadPVC

func UploadPVC(s ObjectStorer, pvcKeyPrefix, pvcKeySuffix string,
	pvc corev1.PersistentVolumeClaim,
) error

UploadPVC uploads the given PVC to the bucket with a key of "<pvcKeyPrefix><v1.PersistentVolumeClaim/><pvcKeySuffix>". - pvcKeyPrefix should have any required delimiters like '/' - OK to call UploadPVC() concurrently from multiple goroutines safely.

func UploadVGR

func UploadVGR(s ObjectStorer, vgrKeyPrefix, vgrKeySuffix string,
	vgr volrep.VolumeGroupReplication,
) error

UploadVGR uploads the given VGR to the bucket with a key of "<vgrKeyPrefix><v1.VolumeGroupReplication/><vgrKeySuffix>". - vgrKeyPrefix should have any required delimiters like '/' - OK to call UploadVGR() concurrently from multiple goroutines safely.

func UploadVGRC

func UploadVGRC(s ObjectStorer, vgrcKeyPrefix, vgrcKeySuffix string,
	vgrc volrep.VolumeGroupReplicationContent,
) error

UploadVGRC uploads the given VGRC to the bucket with a key of "<vgrcKeyPrefix><v1.VolumeGroupReplicationContent/><vgrcKeySuffix>". - vgrcKeyPrefix should have any required delimiters like '/' - OK to call UploadVGRC() concurrently from multiple goroutines safely.

func VrgObjectProtect

func VrgObjectProtect(objectStorer ObjectStorer, vrg ramen.VolumeReplicationGroup) error

func VrgObjectUnprotect

func VrgObjectUnprotect(objectStorer ObjectStorer, vrg ramen.VolumeReplicationGroup) error

func VrgTidyForList

func VrgTidyForList(vrg *ramendrv1alpha1.VolumeReplicationGroup)

func WorkloadProtectionStatusLabels

func WorkloadProtectionStatusLabels(drpc *rmn.DRPlacementControl) prometheus.Labels

workloadProtectionStatus Metric reports information regarding workload protection condition from DRPC

Types

type CGEnabledMetrics

type CGEnabledMetrics struct {
	CGEnabled prometheus.Gauge
}

func NewCGEnabledMetric

func NewCGEnabledMetric(labels prometheus.Labels) CGEnabledMetrics

type CIDRMapping

type CIDRMapping struct {
	// DR1CIDR is the subnet on cluster dr1.
	DR1CIDR string
	// DR2CIDR is the subnet on cluster dr2.
	DR2CIDR string
	// contains filtered or unexported fields
}

CIDRMapping carries the two subnets for subnet-offset translation. Both subnets must have the same prefix length.

type CompiledRegexRule

type CompiledRegexRule struct {
	Pattern     string // original pattern string, kept for error messages
	Replacement string
	// contains filtered or unexported fields
}

CompiledRegexRule is a single pre-compiled regex-replacement rule.

type DRClusterConfigReconciler

type DRClusterConfigReconciler struct {
	client.Client
	Scheme             *runtime.Scheme
	APIReader          client.Reader
	Log                logr.Logger
	NadWatchRegistered bool
	RateLimiter        *workqueue.TypedRateLimiter[reconcile.Request]
}

DRClusterConfigReconciler reconciles a DRClusterConfig object

func (*DRClusterConfigReconciler) GetDRClusterConfig

func (r *DRClusterConfigReconciler) GetDRClusterConfig(ctx context.Context) (*ramen.DRClusterConfig, error)

func (*DRClusterConfigReconciler) Reconcile

func (*DRClusterConfigReconciler) SetupWithManager

func (r *DRClusterConfigReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

func (*DRClusterConfigReconciler) UpdateStatus

func (r *DRClusterConfigReconciler) UpdateStatus(
	ctx context.Context,
	drCConfig *ramen.DRClusterConfig,
) error

UpdateSupportedClasses updates DRClusterConfig status with a list of storage related classes that are marked for DR support. The list is sorted alphabetically to avoid out of order listing and status updates due to the same

type DRClusterReconciler

type DRClusterReconciler struct {
	client.Client
	APIReader         client.Reader
	Log               logr.Logger
	Scheme            *runtime.Scheme
	MCVGetter         util.ManagedClusterViewGetter
	ObjectStoreGetter ObjectStoreGetter
	RateLimiter       *workqueue.TypedRateLimiter[reconcile.Request]
}

DRClusterReconciler reconciles a DRCluster object

func (*DRClusterReconciler) Reconcile

func (r *DRClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*DRClusterReconciler) SetupWithManager

func (r *DRClusterReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type DRPCAndPolicy

type DRPCAndPolicy struct {
	// contains filtered or unexported fields
}

func DRPCsFailingOverToCluster

func DRPCsFailingOverToCluster(k8sclient client.Client, log logr.Logger, drcluster string) ([]DRPCAndPolicy, error)

DRPCsFailingOverToCluster lists DRPC resources that are failing over to the passed in drcluster

func DRPCsUsingDRCluster

func DRPCsUsingDRCluster(k8sclient client.Client, log logr.Logger, drcluster *rmn.DRCluster) ([]DRPCAndPolicy, error)

DRPCsUsingDRCluster finds DRPC resources using the DRcluster.

type DRPCInstance

type DRPCInstance struct {
	// contains filtered or unexported fields
}

func (*DRPCInstance) AppendOrUpdate

AppendOrUpdate adds rsSpec to the rsSpecList if not present, or updates the existing entry with the same PVCName.

func (*DRPCInstance) EnsureCleanup

func (d *DRPCInstance) EnsureCleanup(clusterToSkip string) error

func (*DRPCInstance) EnsureSecondaryReplicationSetup

func (d *DRPCInstance) EnsureSecondaryReplicationSetup(srcCluster string) error

func (*DRPCInstance) EnsureVolSyncReplicationSetup

func (d *DRPCInstance) EnsureVolSyncReplicationSetup(srcCluster string) error

func (*DRPCInstance) IsVolSyncReplicationRequired

func (d *DRPCInstance) IsVolSyncReplicationRequired(homeCluster string) (bool, error)

func (*DRPCInstance) ResetVMStaticIPSpecOnPrimary

func (d *DRPCInstance) ResetVMStaticIPSpecOnPrimary(clusterName string) error

ResetVMStaticIPSpecOnPrimary clears StaticIPTranslationSpec from the primary VRG once recovery completes or translation injection is no longer required. The translation spec is transient recovery metadata used during restore on secondary clusters and should not remain configured on the promoted primary after failover/relocation.

func (*DRPCInstance) ResetVolSyncRDOnPrimary

func (d *DRPCInstance) ResetVolSyncRDOnPrimary(clusterName string) error

func (*DRPCInstance) RunFailover

func (d *DRPCInstance) RunFailover() (bool, error)

RunFailover: 0. Check if failoverCluster is a valid target as Secondary (or already is a Primary) 1. If already failed over or in the process (VRG on failoverCluster is Primary), ensure failover is complete and then ensure cleanup 2. Else, if failover is initiated (VRG ManifestWork is create as Primary), then try again till VRG manifests itself on the failover cluster 3. Else, initiate failover to the desired failoverCluster (switchToFailoverCluster)

func (*DRPCInstance) RunInitialDeployment

func (d *DRPCInstance) RunInitialDeployment() (bool, error)

func (*DRPCInstance) RunRelocate

func (d *DRPCInstance) RunRelocate() (bool, error)

runRelocate checks if pre-conditions for relocation are met, and if so performs the relocation Pre-requisites for relocation are checked as follows:

  • The exists at least one VRG across clusters (there is no state where we do not have a VRG as primary or secondary once initial deployment is complete)
  • Ensures that there is only one primary, before further state transitions
  • If there are multiple primaries, wait for one of the primaries to transition to a secondary. This can happen if MCV reports older VRG state as MW is being applied to the cluster.
  • Check if peers are ready
  • If there are secondaries in flight, ensure they report secondary as the observed state before moving forward
  • preferredCluster should not report as Secondary, as it will never transition out of delete state in the future, as there would be no primary. This can happen, if in between relocate the preferred cluster was switched
  • User needs to recover by changing the preferredCluster back to the initial intent
  • Check if we already relocated to the preferredCluster, and ensure cleanup actions
  • Check if current primary (that is not the preferred cluster), is ready to switch over
  • Relocate!

type DRPCNetworkMappingManager

type DRPCNetworkMappingManager struct {
	// contains filtered or unexported fields
}

DRPCNetworkMappingManager reads and parses the network-mapping ConfigMap referenced by a DRPC annotation and performs IP translation.

func NewDRPCNetworkMappingManager

func NewDRPCNetworkMappingManager(c client.Client, log logr.Logger) *DRPCNetworkMappingManager

NewDRPCNetworkMappingManager constructs a manager bound to the given client.

func (*DRPCNetworkMappingManager) LoadNetworkMapping

func (m *DRPCNetworkMappingManager) LoadNetworkMapping(
	ctx context.Context,
	drpc *rmn.DRPlacementControl,
	drPolicy *rmn.DRPolicy,
) (*NetworkMappingRules, error)

LoadNetworkMapping returns the parsed NetworkMappingRules for the DRPC, or (nil, nil) if the DRPolicy does not define a networkMappingRef.

drPolicy is required to resolve cluster names from drpolicy.spec.drClusters.

type DRPlacementControlReconciler

type DRPlacementControlReconciler struct {
	client.Client
	APIReader client.Reader
	Log       logr.Logger
	MCVGetter rmnutil.ManagedClusterViewGetter
	Scheme    *runtime.Scheme
	Callback  ProgressCallback

	ObjStoreGetter ObjectStoreGetter
	RateLimiter    *workqueue.TypedRateLimiter[reconcile.Request]
	// contains filtered or unexported fields
}

DRPlacementControlReconciler reconciles a DRPlacementControl object

func (*DRPlacementControlReconciler) FilterDRCluster

func (r *DRPlacementControlReconciler) FilterDRCluster(drcluster *rmn.DRCluster) []ctrl.Request

FilterDRCluster filters for DRPC resources that should be reconciled due to a DRCluster watch event

func (*DRPlacementControlReconciler) FilterDRPCsForDRPolicyUpdate

func (r *DRPlacementControlReconciler) FilterDRPCsForDRPolicyUpdate(drpolicy *rmn.DRPolicy) []ctrl.Request

FilterDRPCsForDRPolicyUpdate filters and returns the DRPC resources that need reconciliation in response to a DRPolicy update event. This ensures that only relevant DRPCs are processed based on the changes in the associated DRPolicy.

func (*DRPlacementControlReconciler) FilterGlobalPeerDRPCs

func (r *DRPlacementControlReconciler) FilterGlobalPeerDRPCs(
	drpc *rmn.DRPlacementControl,
) []ctrl.Request

FilterGlobalPeerDRPCs enqueues all peer DRPCs that share the same global VGR label, so they reconcile when any one of them changes action or is deleted.

func (*DRPlacementControlReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the DRPlacementControl object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.7.0/pkg/reconcile

func (*DRPlacementControlReconciler) SetupWithManager

func (r *DRPlacementControlReconciler) SetupWithManager(mgr ctrl.Manager, ramenConfig *rmn.RamenConfig) error

SetupWithManager sets up the controller with the Manager.

type DRPolicyReconciler

type DRPolicyReconciler struct {
	client.Client
	APIReader         client.Reader
	Log               logr.Logger
	Scheme            *runtime.Scheme
	MCVGetter         util.ManagedClusterViewGetter
	ObjectStoreGetter ObjectStoreGetter
	RateLimiter       *workqueue.TypedRateLimiter[reconcile.Request]
}

DRPolicyReconciler reconciles a DRPolicy object

func (*DRPolicyReconciler) Reconcile

func (r *DRPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the DRPolicy object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.9.2/pkg/reconcile

func (*DRPolicyReconciler) SetupWithManager

func (r *DRPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type DRPolicySyncMetrics

type DRPolicySyncMetrics struct {
	DRPolicySyncInterval prometheus.Gauge
}

func NewDRPolicySyncIntervalMetrics

func NewDRPolicySyncIntervalMetrics(labels prometheus.Labels) DRPolicySyncMetrics

type DRProgressionStateMetrics

type DRProgressionStateMetrics struct {
	DRProgressionState prometheus.Gauge
}

func NewDRPCProgressionStateMetric

func NewDRPCProgressionStateMetric(labels prometheus.Labels) DRProgressionStateMetrics

type DRType

type DRType string

type ExplicitMappings

type ExplicitMappings struct {
	Forward map[string]string // dr1IP → dr2IP
	Reverse map[string]string // dr2IP → dr1IP
}

ExplicitMappings holds the forward and reverse lookup maps built from the explicitMappings YAML list. Both maps are populated together at parse time so lookup is O(1) in both directions.

Forward: dr1IP → dr2IP (failover, dr1→dr2) Reverse: dr2IP → dr1IP (failback, dr2→dr1)

type GlobalActionMetrics

type GlobalActionMetrics struct {
	GlobalActionStatus prometheus.Gauge
}

func NewGlobalActionMetric

func NewGlobalActionMetric(labels prometheus.Labels) GlobalActionMetrics

type InvalidCIDRsDetectedMetrics

type InvalidCIDRsDetectedMetrics struct {
	InvalidCIDRsDetected prometheus.Gauge
}

func NewInvalidCIDRsDetectedMetric

func NewInvalidCIDRsDetectedMetric(labels prometheus.Labels) InvalidCIDRsDetectedMetrics

type NADMissingEntry

type NADMissingEntry struct {
	NADName      string
	NADNamespace string
	MissingOnA   bool
	ClusterA     string
	MissingOnB   bool
	ClusterB     string
}

NADMissingEntry describes a NAD that is present on one cluster but absent from the other.

type NetworkMappingBlock

type NetworkMappingBlock struct {
	// NetworkRef scopes this block to a specific NAD.
	NetworkRef NetworkRef

	// ExplicitMappings holds the per-VM static IP table (highest priority).
	// Forward maps a dr1 IP to its dr2 IP; Reverse is the inverse.
	// Both maps are nil when explicitMappings is not configured.
	ExplicitMappings *ExplicitMappings

	// CIDRMapping is the subnet-offset translation (second priority).
	// nil when not configured.
	CIDRMapping *CIDRMapping

	// RegexRules is the directional regex fallback (lowest priority).
	// nil when not configured.
	RegexRules *RegexRules
}

NetworkMappingBlock is one resolved per-NAD translation block. All three rule sets are optional individually; at least one must be present. Evaluation order at runtime: ExplicitMappings → CIDRMapping → RegexRules.

type NetworkMappingRules

type NetworkMappingRules struct {
	// Version is the schema version read from the ConfigMap (e.g. "v1").
	Version string
	// DR1 is drpolicy.spec.drClusters[0].
	DR1 string
	// DR2 is drpolicy.spec.drClusters[1].
	DR2 string

	// Blocks is the ordered list of resolved per-NAD translation blocks.
	Blocks []NetworkMappingBlock
}

NetworkMappingRules is the normalised, direction-resolved form of the full ConfigMap.

func ParseNetworkMappingConfigMap

func ParseNetworkMappingConfigMap(cm *corev1.ConfigMap, dr1, dr2 string) (*NetworkMappingRules, error)

ParseNetworkMappingConfigMap parses a ConfigMap that follows the network-mapping format described at the top of this file.

dr1 = drpolicy.spec.drClusters[0], dr2 = drpolicy.spec.drClusters[1].

type NetworkMappingValidator

type NetworkMappingValidator struct {
	// contains filtered or unexported fields
}

NetworkMappingValidator handles network-mapping validation for DRPolicy. Its sole responsibility is NAD-pair validation: verifying that every NAD used by static-IP VMs under a policy is present on both clusters.

IP translation rules live in the per-DRPC network-mapping ConfigMap (drpc_networkmapping.go) and are never touched here.

func NewNetworkMappingValidator

func NewNetworkMappingValidator(c client.Client, mcvGetter util.ManagedClusterViewGetter,
	log logr.Logger,
) *NetworkMappingValidator

NewNetworkMappingValidator creates a new network mapping validator.

func (*NetworkMappingValidator) UpdateNADValidationCondition

func (v *NetworkMappingValidator) UpdateNADValidationCondition(u *drpolicyUpdater,
) (nadsValid bool, err error)

UpdateNADValidationCondition runs NAD validation and writes the result as a standard Kubernetes condition on DRPolicy.Status.Conditions (type NetworkAttachmentsValidated).

  • True — all NADs used by static-IP VMs are present on both clusters.
  • False — one or more NADs are missing; message lists each one.

Transient errors (for example, DRClusterConfig or ManagedClusterView not yet available) are logged and returned without modifying the existing NetworkAttachmentsValidated condition.

type NetworkRef

type NetworkRef struct {
	NADNamespace string `yaml:"nadNamespace" json:"nadNamespace"`
	NADName      string `yaml:"nadName"      json:"nadName"`
}

NetworkRef identifies the NAD (NetworkAttachmentDefinition) that a block applies to.

type ObjectStoreGetter

type ObjectStoreGetter interface {
	// ObjectStore returns an object that satisfies ObjectStorer interface
	ObjectStore(ctx context.Context, r client.Reader,
		s3Profile string, callerTag string, log logr.Logger,
	) (ObjectStorer, ramen.S3StoreProfile, error)
}

ObjectStoreGetter interface is exported because test clients use this interface.

func S3ObjectStoreGetter

func S3ObjectStoreGetter() ObjectStoreGetter

S3ObjectStoreGetter returns a concrete type that implements the ObjectStoreGetter interface, allowing the concrete type to be not exported.

type ObjectStorer

type ObjectStorer interface {
	HeadBucket() error
	UploadObject(key string, object interface{}) error
	DownloadObject(key string, objectPointer interface{}) error
	ListKeys(keyPrefix string) (keys []string, err error)
	DeleteObject(key string) error
	DeleteObjects(key ...string) error
	DeleteObjectsWithKeyPrefix(keyPrefix string) error
}

type Progress

type Progress int

type ProgressCallback

type ProgressCallback func(string, string)

ProgressCallback of function type

type ProtectedVolumeReplicationGroupListInstance

type ProtectedVolumeReplicationGroupListInstance struct {
	// contains filtered or unexported fields
}

func (*ProtectedVolumeReplicationGroupListInstance) GetItemsInReplicaStoreWithPrefix

func (s *ProtectedVolumeReplicationGroupListInstance) GetItemsInReplicaStoreWithPrefix(s3ProfileName string,
	lookupPrefix string,
) ([]string, error)

func (*ProtectedVolumeReplicationGroupListInstance) ParseResultListFromReplicaStore

func (s *ProtectedVolumeReplicationGroupListInstance) ParseResultListFromReplicaStore(
	s3ProfileName string, prefix string, parseFunc func(string) string,
) ([]string, error)

type ProtectedVolumeReplicationGroupListReconciler

type ProtectedVolumeReplicationGroupListReconciler struct {
	client.Client
	APIReader      client.Reader
	ObjStoreGetter ObjectStoreGetter
	Scheme         *runtime.Scheme
	RateLimiter    *workqueue.TypedRateLimiter[reconcile.Request]
	Log            logr.Logger
}

ProtectedVolumeReplicationGroupListReconciler reconciles a ProtectedVolumeReplicationGroupList object

func (*ProtectedVolumeReplicationGroupListReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the ProtectedVolumeReplicationGroupList object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.9.2/pkg/reconcile

func (*ProtectedVolumeReplicationGroupListReconciler) SetupWithManager

SetupWithManager sets up the controller with the Manager.

type PvcSelector

type PvcSelector struct {
	LabelSelector  metav1.LabelSelector
	NamespaceNames []string
}

type RegexRules

type RegexRules struct {
	// Forward rules applied during dr1→dr2.
	Forward []CompiledRegexRule
	// Reverse rules applied during dr2→dr1.
	Reverse []CompiledRegexRule
}

RegexRules holds the two ordered direction lists for regex-based translation.

type ReplicationGroupDestinationReconciler

type ReplicationGroupDestinationReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	Log    logr.Logger
}

ReplicationGroupDestinationReconciler reconciles a ReplicationGroupDestination object

func (*ReplicationGroupDestinationReconciler) Reconcile

func (*ReplicationGroupDestinationReconciler) SetupWithManager

func (r *ReplicationGroupDestinationReconciler) SetupWithManager(mgr ctrl.Manager,
	ramenConfig *ramendrv1alpha1.RamenConfig,
) error

SetupWithManager sets up the controller with the Manager.

type ReplicationGroupSourceReconciler

type ReplicationGroupSourceReconciler struct {
	client.Client
	APIReader client.Reader
	Scheme    *runtime.Scheme

	Log logr.Logger
	// contains filtered or unexported fields
}

ReplicationGroupSourceReconciler reconciles a ReplicationGroupSource object

func (*ReplicationGroupSourceReconciler) Reconcile

func (*ReplicationGroupSourceReconciler) SetupWithManager

func (r *ReplicationGroupSourceReconciler) SetupWithManager(mgr ctrl.Manager,
	ramenConfig *ramendrv1alpha1.RamenConfig,
) error

SetupWithManager sets up the controller with the Manager.

type RuleType

type RuleType string

RuleType identifies which rule produced a translation result (used in logs).

const (
	RuleTypeExplicit RuleType = "Explicit"
	RuleTypeCIDR     RuleType = "CIDR"
	RuleTypeRegex    RuleType = "Regex"
)

type SyncDataBytesMetrics

type SyncDataBytesMetrics struct {
	LastSyncDataBytes prometheus.Gauge
}

func NewSyncDataBytesMetric

func NewSyncDataBytesMetric(labels prometheus.Labels) SyncDataBytesMetrics

type SyncDurationMetrics

type SyncDurationMetrics struct {
	LastSyncDuration prometheus.Gauge
}

func NewSyncDurationMetric

func NewSyncDurationMetric(labels prometheus.Labels) SyncDurationMetrics

type SyncTimeMetrics

type SyncTimeMetrics struct {
	LastSyncTime prometheus.Gauge
}

func NewSyncTimeMetric

func NewSyncTimeMetric(labels prometheus.Labels) SyncTimeMetrics

type TranslationDirection

type TranslationDirection int

TranslationDirection controls which side (Forward = dr1→dr2, Reverse = dr2→dr1) of a mapping block is used.

const (
	TranslationDirectionForward TranslationDirection = iota // dr1 → dr2
	TranslationDirectionReverse                             // dr2 → dr1
)

type UndetectedCIDRsFoundMetrics

type UndetectedCIDRsFoundMetrics struct {
	UndetectedCIDRsFound prometheus.Gauge
}

func NewUndetectedCIDRsFoundMetric

func NewUndetectedCIDRsFoundMetric(labels prometheus.Labels) UndetectedCIDRsFoundMetrics

UndetectedCIDRsFound Metric reports if CIDRs configured in DRCluster are not detected by the storage provisioner

type VRGInstance

type VRGInstance struct {
	// contains filtered or unexported fields
}

func (*VRGInstance) CheckForVMConflictOnPrimary

func (v *VRGInstance) CheckForVMConflictOnPrimary() error

func (*VRGInstance) CheckForVMConflictOnSecondary

func (v *VRGInstance) CheckForVMConflictOnSecondary() error

func (*VRGInstance) CheckForVMNameConflictOnSecondary

func (v *VRGInstance) CheckForVMNameConflictOnSecondary(vmNamespaceList, vmList []string) error

func (*VRGInstance) GetVRGMoverConfig

func (v *VRGInstance) GetVRGMoverConfig(name, namespace string) *ramendrv1alpha1.MoverConfig

func (*VRGInstance) HandleSecondaryConflictsAndCleanup

func (v *VRGInstance) HandleSecondaryConflictsAndCleanup() bool

HandleSecondaryConflictsAndCleanup manages VM cleanup and conflict detection for VRG in secondary state. For VM-recipe protection, this function:

  1. Checks for cross-cluster resource conflicts (e.g., VMs running on multiple clusters)
  2. When no DR action is in progress, sets appropriate AutoCleanup conditions
  3. When DR action is in progress (relocate/failover), performs automated VM cleanup if feasible

Returns true if requeue is needed (VM cleanup in progress), false otherwise.

func (*VRGInstance) IsDRActionInProgress

func (v *VRGInstance) IsDRActionInProgress() bool

func (*VRGInstance) IsSecondaryVRG

func (v *VRGInstance) IsSecondaryVRG() bool

func (*VRGInstance) IsVMAutoCleanUpNotFeasible

func (v *VRGInstance) IsVMAutoCleanUpNotFeasible() bool

func (*VRGInstance) PriortizePrimaryClusterDataConflictCondition

func (v *VRGInstance) PriortizePrimaryClusterDataConflictCondition(
	vmConflictCondition, pvcConflictCondition *metav1.Condition,
) *metav1.Condition

func (*VRGInstance) ShouldCleanupVMForSecondary

func (v *VRGInstance) ShouldCleanupVMForSecondary() bool
  1. If VM resource cleanup is in progress, requeue for reconciliation
  2. If protected VMs are not found in protected NS, consider VM cleanup complete
  3. Validates if all protected VMs owns PVCs from the lis tof all the protected volumes directly or indirectly a) VM manifest has references to PVC through DataVolumeTemplate or DataVolume b) VM instance pod - virt-launcher-xxx is using the PVC, whose lifecycle management is independent of VM
  4. for step 3(b) VM ownership is set on the respective PVCs
  5. Deletes the VM using cascade foreground deletion API

func (*VRGInstance) UploadPVAndPVCtoS3

func (v *VRGInstance) UploadPVAndPVCtoS3(s3ProfileName string, objectStore ObjectStorer,
	pv *corev1.PersistentVolume, pvc *corev1.PersistentVolumeClaim,
) error

func (*VRGInstance) UploadPVandPVCtoS3Store

func (v *VRGInstance) UploadPVandPVCtoS3Store(s3ProfileName string, pvc *corev1.PersistentVolumeClaim,
	pv *corev1.PersistentVolume,
) error

func (*VRGInstance) UploadPVandPVCtoS3Stores

func (v *VRGInstance) UploadPVandPVCtoS3Stores(pvc *corev1.PersistentVolumeClaim,
	log logr.Logger,
) ([]string, error)

func (*VRGInstance) UploadVGRAndVGRCtoS3

func (v *VRGInstance) UploadVGRAndVGRCtoS3(s3ProfileName string, objectStore ObjectStorer,
	vgr *volrep.VolumeGroupReplication, vgrc *volrep.VolumeGroupReplicationContent,
) error

func (*VRGInstance) UploadVGRandVGRCtoS3Store

func (v *VRGInstance) UploadVGRandVGRCtoS3Store(s3ProfileName string, vgr *volrep.VolumeGroupReplication,
	vgrc *volrep.VolumeGroupReplicationContent,
) error

func (*VRGInstance) UploadVGRandVGRCtoS3Stores

func (v *VRGInstance) UploadVGRandVGRCtoS3Stores(vgr *volrep.VolumeGroupReplication,
	log logr.Logger,
) ([]string, error)

func (*VRGInstance) ValidateStaticIPNetworkMapping

func (v *VRGInstance) ValidateStaticIPNetworkMapping(
	vmList []string, vmNamespaceList []string,
) ([]util.VMStaticIPInfo, error)

type VolumeReplicationGroupReconciler

type VolumeReplicationGroupReconciler struct {
	client.Client
	APIReader      client.Reader
	Log            logr.Logger
	ObjStoreGetter ObjectStoreGetter
	Scheme         *runtime.Scheme

	RateLimiter *workqueue.TypedRateLimiter[reconcile.Request]
	// contains filtered or unexported fields
}

VolumeReplicationGroupReconciler reconciles a VolumeReplicationGroup object

func (*VolumeReplicationGroupReconciler) RDMapFunc

func (*VolumeReplicationGroupReconciler) RGDMapFunc

func (*VolumeReplicationGroupReconciler) RGSMapFunc

func (*VolumeReplicationGroupReconciler) RSMapFunc

func (*VolumeReplicationGroupReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the VolumeReplicationGroup object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.7.0/pkg/reconcile

func (*VolumeReplicationGroupReconciler) SetupWithManager

func (r *VolumeReplicationGroupReconciler) SetupWithManager(
	mgr ctrl.Manager, ramenConfig *ramendrv1alpha1.RamenConfig,
) error

SetupWithManager sets up the controller with the Manager.

nolint: funlen

func (*VolumeReplicationGroupReconciler) VGRMapFunc

func (*VolumeReplicationGroupReconciler) VRMapFunc

type WorkloadProtectionMetrics

type WorkloadProtectionMetrics struct {
	WorkloadProtectionStatus prometheus.Gauge
}

func NewWorkloadProtectionStatusMetric

func NewWorkloadProtectionStatusMetric(labels prometheus.Labels) WorkloadProtectionMetrics

Directories

Path Synopsis
NOTE: Added to skip creating shadow manifests for localSecret struct +kubebuilder:skip
NOTE: Added to skip creating shadow manifests for localSecret struct +kubebuilder:skip

Jump to

Keyboard shortcuts

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