Skip to content

Commit

Permalink
add cg controllers for cephfs (RamenDR#1484)
Browse files Browse the repository at this point in the history
Add Consistency Group (CG) support for cephfs-related workload. The implementation follows the design
in this document RamenDR#1356.

Signed-off-by: youhangwang <youhangwang@foxmail.com>
(cherry picked from commit aefe73f)
  • Loading branch information
youhangwang authored and raghavendra-talur committed Jul 30, 2024
1 parent a6e83af commit a6b3720
Show file tree
Hide file tree
Showing 45 changed files with 6,953 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ ramenctl/build

# Generated disk images
*.qcow2
*.iso
*.iso
18 changes: 18 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,22 @@ resources:
kind: DRClusterConfig
path: github.com/ramendr/ramen/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: ramendr
kind: ReplicationGroupDestination
path: github.com/ramendr/ramen/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: ramendr
kind: ReplicationGroupSource
path: github.com/ramendr/ramen/api/v1alpha1
version: v1alpha1
version: "3"
6 changes: 6 additions & 0 deletions api/v1alpha1/drpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ type DRPolicySpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="volumeSnapshotClassSelector is immutable"
VolumeSnapshotClassSelector metav1.LabelSelector `json:"volumeSnapshotClassSelector"`

// Label selector to identify the VolumeGroupSnapshotClass resources
// that are scanned to select an appropriate VolumeGroupSnapshotClass
// for the VolumeGroupSnapshot resource when using VolSync.
//+optional
VolumeGroupSnapshotClassSelector metav1.LabelSelector `json:"volumeGroupSnapshotClassSelector,omitempty"`

// List of DRCluster resources that are governed by this policy
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="size(self) == 2", message="drClusters requires a list of 2 clusters"
Expand Down
75 changes: 75 additions & 0 deletions api/v1alpha1/replicationgroupdestination_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-FileCopyrightText: The RamenDR authors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ReplicationGroupDestinationSpec defines the desired state of ReplicationGroupDestination
type ReplicationGroupDestinationSpec struct {
// Label selector to identify the VolumeSnapshotClass resources
// that are scanned to select an appropriate VolumeSnapshotClass
// for the VolumeReplication resource when using VolSync.
//+optional
VolumeSnapshotClassSelector metav1.LabelSelector `json:"volumeSnapshotClassSelector,omitempty"`

RDSpecs []VolSyncReplicationDestinationSpec `json:"rdSpecs,omitempty"`
}

// ReplicationGroupDestinationStatus defines the observed state of ReplicationGroupDestination
type ReplicationGroupDestinationStatus struct {
// lastSyncTime is the time of the most recent successful synchronization.
//+optional
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
// lastSyncStartTime is the time the most recent synchronization started.
//+optional
LastSyncStartTime *metav1.Time `json:"lastSyncStartTime,omitempty"`
// lastSyncDuration is the amount of time required to send the most recent
// update.
//+optional
LastSyncDuration *metav1.Duration `json:"lastSyncDuration,omitempty"`
// nextSyncTime is the time when the next volume synchronization is
// scheduled to start (for schedule-based synchronization).
//+optional
NextSyncTime *metav1.Time `json:"nextSyncTime,omitempty"`
// conditions represent the latest available observations of the
// source's state.
Conditions []metav1.Condition `json:"conditions,omitempty"`
// latestImage in the object holding the most recent consistent replicated
// image.
//+optional
LatestImages map[string]*corev1.TypedLocalObjectReference `json:"latestImage,omitempty"`
// Created ReplicationDestinations by this ReplicationGroupDestination
ReplicationDestinations []*corev1.ObjectReference `json:"replicationDestinations,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Last sync",type="string",format="date-time",JSONPath=`.status.lastSyncTime`
// +kubebuilder:printcolumn:name="Duration",type="string",JSONPath=`.status.lastSyncDuration`
// +kubebuilder:printcolumn:name="Last sync start",type="string",format="date-time",JSONPath=`.status.lastSyncStartTime`

// ReplicationGroupDestination is the Schema for the replicationgroupdestinations API
type ReplicationGroupDestination struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ReplicationGroupDestinationSpec `json:"spec,omitempty"`
Status ReplicationGroupDestinationStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ReplicationGroupDestinationList contains a list of ReplicationGroupDestination
type ReplicationGroupDestinationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ReplicationGroupDestination `json:"items"`
}

func init() {
SchemeBuilder.Register(&ReplicationGroupDestination{}, &ReplicationGroupDestinationList{})
}
96 changes: 96 additions & 0 deletions api/v1alpha1/replicationgroupsource_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// SPDX-FileCopyrightText: The RamenDR authors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ReplicationGroupSourceSpec defines the desired state of ReplicationGroupSource
type ReplicationGroupSourceSpec struct {
Trigger *ReplicationSourceTriggerSpec `json:"trigger,omitempty"`

// +required
VolumeGroupSnapshotClassName string `json:"volumeGroupSnapshotClassName,omitempty"`

// +required
VolumeGroupSnapshotSource *metav1.LabelSelector `json:"volumeGroupSnapshotSource,omitempty"`
}

// ReplicationSourceTriggerSpec defines when a volume will be synchronized with
// the destination.
type ReplicationSourceTriggerSpec struct {
// schedule is a cronspec (https://en.wikipedia.org/wiki/Cron#Overview) that
// can be used to schedule replication to occur at regular, time-based
// intervals.
// nolint:lll
//+kubebuilder:validation:Pattern=`^(@(annually|yearly|monthly|weekly|daily|hourly))|((((\d+,)*\d+|(\d+(\/|-)\d+)|\*(\/\d+)?)\s?){5})$`
//+optional
Schedule *string `json:"schedule,omitempty"`
// manual is a string value that schedules a manual trigger.
// Once a sync completes then status.lastManualSync is set to the same string value.
// A consumer of a manual trigger should set spec.trigger.manual to a known value
// and then wait for lastManualSync to be updated by the operator to the same value,
// which means that the manual trigger will then pause and wait for further
// updates to the trigger.
//+optional
Manual string `json:"manual,omitempty"`
}

// ReplicationGroupSourceStatus defines the observed state of ReplicationGroupSource
type ReplicationGroupSourceStatus struct {
// lastSyncTime is the time of the most recent successful synchronization.
//+optional
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
// lastSyncStartTime is the time the most recent synchronization started.
//+optional
LastSyncStartTime *metav1.Time `json:"lastSyncStartTime,omitempty"`
// lastSyncDuration is the amount of time required to send the most recent
// update.
//+optional
LastSyncDuration *metav1.Duration `json:"lastSyncDuration,omitempty"`
// nextSyncTime is the time when the next volume synchronization is
// scheduled to start (for schedule-based synchronization).
//+optional
NextSyncTime *metav1.Time `json:"nextSyncTime,omitempty"`
// lastManualSync is set to the last spec.trigger.manual when the manual sync is done.
//+optional
LastManualSync string `json:"lastManualSync,omitempty"`
// conditions represent the latest available observations of the
// source's state.
Conditions []metav1.Condition `json:"conditions,omitempty"`
// Created ReplicationSources by this ReplicationGroupSource
ReplicationSources []*corev1.ObjectReference `json:"replicationSources,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Last sync",type="string",format="date-time",JSONPath=`.status.lastSyncTime`
// +kubebuilder:printcolumn:name="Duration",type="string",JSONPath=`.status.lastSyncDuration`
// +kubebuilder:printcolumn:name="Next sync",type="string",format="date-time",JSONPath=`.status.nextSyncTime`
// +kubebuilder:printcolumn:name="Source",type="string",JSONPath=`.spec.volumeGroupSnapshotSource`
// +kubebuilder:printcolumn:name="Last sync start",type="string",format="date-time",JSONPath=`.status.lastSyncStartTime`

// ReplicationGroupSource is the Schema for the replicationgroupsources API
type ReplicationGroupSource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ReplicationGroupSourceSpec `json:"spec,omitempty"`
Status ReplicationGroupSourceStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ReplicationGroupSourceList contains a list of ReplicationGroupSource
type ReplicationGroupSourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ReplicationGroupSource `json:"items"`
}

func init() {
SchemeBuilder.Register(&ReplicationGroupSource{}, &ReplicationGroupSourceList{})
}
6 changes: 6 additions & 0 deletions api/v1alpha1/volumereplicationgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ type VRGAsyncSpec struct {
//+optional
VolumeSnapshotClassSelector metav1.LabelSelector `json:"volumeSnapshotClassSelector,omitempty"`

// Label selector to identify the VolumeGroupSnapshotClass resources
// that are scanned to select an appropriate VolumeGroupSnapshotClass
// for the VolumeGroupSnapshot resource when using VolSync.
//+optional
VolumeGroupSnapshotClassSelector metav1.LabelSelector `json:"volumeGroupSnapshotClassSelector,omitempty"`

// scheduling Interval for replicating Persistent Volume
// data to a peer cluster. Interval is typically in the
// form <num><m,h,d>. Here <num> is a number, 'm' means
Expand Down
Loading

0 comments on commit a6b3720

Please sign in to comment.