Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add volume group replication controller code #610

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
VolumeGroupReplicationNameAnnotation = "replication.storage.openshift.io/volume-group-replication-name"
)

// VolumeGroupReplicationSpec defines the desired state of VolumeGroupReplication
type VolumeGroupReplicationSpec struct {
// volumeGroupReplicationClassName is the volumeGroupReplicationClass name for this VolumeGroupReplication resource
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationClassName is immutable"
VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"`

// volumeReplicationClassName is the volumeReplicationClass name for VolumeReplication object
// volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object
// created for this volumeGroupReplication
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumReplicationClassName is immutable"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationClassName is immutable"
VolumeReplicationClassName string `json:"volumeReplicationClassName"`

// Name of the VolumeReplication object created for this volumeGroupReplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
VolumeGroupReplicationContentNameAnnotation = "replication.storage.openshift.io/volumegroupreplication-content-name"
)

// VolumeGroupReplicationContentSpec defines the desired state of VolumeGroupReplicationContent
type VolumeGroupReplicationContentSpec struct {
// VolumeGroupreplicationRef specifies the VolumeGroupReplication object to which this
// VolumeGroupReplicationContent object is bound.
// VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to
// this VolumeGroupReplicationContent's name for the bidirectional binding to be valid.
// For a pre-existing VolumeGroupReplicationContent object, name and namespace of the
// VolumeGroupReplication object MUST be provided for binding to happen.
// This field is immutable after creation.
// Required.
// +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace must be set"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationRef is immutable"
VolumeGroupReplicationRef corev1.ObjectReference `json:"volumeGroupReplicationRef"`
// +kubebuilder:validation:XValidation:rule="self != null ? has(self.name) && has(self.__namespace__) && has(self.uid) : true",message="volumeGroupReplicationRef.name, volumeGroupReplicationRef.namespace and volumeGroupReplicationRef.uid must be set if volumeGroupReplicationRef is defined"
// +optional
VolumeGroupReplicationRef *corev1.ObjectReference `json:"volumeGroupReplicationRef,omitempty"`

// VolumeGroupReplicationHandle is a unique id returned by the CSI driver
// to identify the VolumeGroupReplication on the storage system.
Expand All @@ -49,12 +49,11 @@ type VolumeGroupReplicationContentSpec struct {

// VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from
// which this group replication was (or will be) created.
// +optional
// Required.
VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"`

// Source specifies whether the snapshot is (or should be) dynamically provisioned
// Source specifies whether the volume is (or should be) dynamically provisioned
Nikhil-Ladha marked this conversation as resolved.
Show resolved Hide resolved
// or already exists, and just requires a Kubernetes object representation.
// This field is immutable after creation.
// Required.
Source VolumeGroupReplicationContentSource `json:"source"`
}
Expand All @@ -68,7 +67,7 @@ type VolumeGroupReplicationContentSource struct {

// VolumeGroupReplicationContentStatus defines the status of VolumeGroupReplicationContent
type VolumeGroupReplicationContentStatus struct {
// PersistentVolumeRefList is the list of of PV for the group replication
// PersistentVolumeRefList is the list of PV for the group replication
// The maximum number of allowed PV in the group is 100.
// +optional
PersistentVolumeRefList []corev1.LocalObjectReference `json:"persistentVolumeRefList,omitempty"`
Expand Down
6 changes: 5 additions & 1 deletion api/replication.storage/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ func main() {
os.Exit(1)
}
if err = (&replicationController.VolumeGroupReplicationContentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Connpool: connPool,
Timeout: defaultTimeout,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "VolumeGroupReplicationContent")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ spec:
type: string
source:
description: |-
Source specifies whether the snapshot is (or should be) dynamically provisioned
Source specifies whether the volume is (or should be) dynamically provisioned
or already exists, and just requires a Kubernetes object representation.
This field is immutable after creation.
Required.
properties:
volumeHandles:
Expand All @@ -71,6 +70,7 @@ spec:
description: |-
VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from
which this group replication was (or will be) created.
Required.
type: string
volumeGroupReplicationHandle:
description: |-
Expand All @@ -83,10 +83,6 @@ spec:
VolumeGroupReplicationContent object is bound.
VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to
this VolumeGroupReplicationContent's name for the bidirectional binding to be valid.
For a pre-existing VolumeGroupReplicationContent object, name and namespace of the
VolumeGroupReplication object MUST be provided for binding to happen.
This field is immutable after creation.
Required.
properties:
apiVersion:
description: API version of the referent.
Expand Down Expand Up @@ -129,24 +125,24 @@ spec:
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace
must be set
rule: has(self.name) && has(self.__namespace__)
- message: volumeGroupReplicationRef is immutable
rule: self == oldSelf
- message: volumeGroupReplicationRef.name, volumeGroupReplicationRef.namespace
and volumeGroupReplicationRef.uid must be set if volumeGroupReplicationRef
is defined
rule: 'self != null ? has(self.name) && has(self.__namespace__)
&& has(self.uid) : true'
required:
- provisioner
- source
- volumeGroupReplicationClassName
- volumeGroupReplicationHandle
- volumeGroupReplicationRef
type: object
status:
description: VolumeGroupReplicationContentStatus defines the status of
VolumeGroupReplicationContent
properties:
persistentVolumeRefList:
description: |-
PersistentVolumeRefList is the list of of PV for the group replication
PersistentVolumeRefList is the list of PV for the group replication
The maximum number of allowed PV in the group is 100.
items:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ spec:
- message: volumeGroupReplicationContentName is immutable
rule: self == oldSelf
volumeReplicationClassName:
description: volumeReplicationClassName is the volumeReplicationClass
name for VolumeReplication object
description: |-
volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object
created for this volumeGroupReplication
type: string
x-kubernetes-validations:
- message: volumReplicationClassName is immutable
- message: volumeReplicationClassName is immutable
rule: self == oldSelf
volumeReplicationName:
description: Name of the VolumeReplication object created for this
Expand Down
35 changes: 31 additions & 4 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rules:
- ""
resources:
- namespaces
- persistentvolumes
- pods
verbs:
- get
Expand All @@ -30,6 +29,15 @@ rules:
- persistentvolumeclaims/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- get
- list
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
Expand Down Expand Up @@ -82,11 +90,19 @@ rules:
- get
- patch
- update
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationclasses
- volumereplicationclasses
verbs:
- get
- list
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumegroupreplicationcontents
- volumegroupreplications
verbs:
- create
- delete
Expand All @@ -101,7 +117,6 @@ rules:
- volumegroupreplicationcontents/finalizers
- volumegroupreplications/finalizers
- volumereplications/finalizers
- volumereplications/status
verbs:
- update
- apiGroups:
Expand All @@ -116,20 +131,32 @@ rules:
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplicationclasses
- volumegroupreplications
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- replication.storage.openshift.io
resources:
- volumereplications/status
verbs:
- get
- list
- update
- apiGroups:
- storage.k8s.io
resources:
Expand Down
29 changes: 13 additions & 16 deletions deploy/controller/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1414,9 +1414,8 @@ spec:
type: string
source:
description: |-
Source specifies whether the snapshot is (or should be) dynamically provisioned
Source specifies whether the volume is (or should be) dynamically provisioned
or already exists, and just requires a Kubernetes object representation.
This field is immutable after creation.
Required.
properties:
volumeHandles:
Expand All @@ -1433,6 +1432,7 @@ spec:
description: |-
VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from
which this group replication was (or will be) created.
Required.
type: string
volumeGroupReplicationHandle:
description: |-
Expand All @@ -1445,10 +1445,6 @@ spec:
VolumeGroupReplicationContent object is bound.
VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to
this VolumeGroupReplicationContent's name for the bidirectional binding to be valid.
For a pre-existing VolumeGroupReplicationContent object, name and namespace of the
VolumeGroupReplication object MUST be provided for binding to happen.
This field is immutable after creation.
Required.
properties:
apiVersion:
description: API version of the referent.
Expand Down Expand Up @@ -1491,24 +1487,24 @@ spec:
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace
must be set
rule: has(self.name) && has(self.__namespace__)
- message: volumeGroupReplicationRef is immutable
rule: self == oldSelf
- message: volumeGroupReplicationRef.name, volumeGroupReplicationRef.namespace
and volumeGroupReplicationRef.uid must be set if volumeGroupReplicationRef
is defined
rule: 'self != null ? has(self.name) && has(self.__namespace__)
&& has(self.uid) : true'
required:
- provisioner
- source
- volumeGroupReplicationClassName
- volumeGroupReplicationHandle
- volumeGroupReplicationRef
type: object
status:
description: VolumeGroupReplicationContentStatus defines the status of
VolumeGroupReplicationContent
properties:
persistentVolumeRefList:
description: |-
PersistentVolumeRefList is the list of of PV for the group replication
PersistentVolumeRefList is the list of PV for the group replication
The maximum number of allowed PV in the group is 100.
items:
description: |-
Expand Down Expand Up @@ -1666,11 +1662,12 @@ spec:
- message: volumeGroupReplicationContentName is immutable
rule: self == oldSelf
volumeReplicationClassName:
description: volumeReplicationClassName is the volumeReplicationClass
name for VolumeReplication object
description: |-
volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object
created for this volumeGroupReplication
type: string
x-kubernetes-validations:
- message: volumReplicationClassName is immutable
- message: volumeReplicationClassName is immutable
rule: self == oldSelf
volumeReplicationName:
description: Name of the VolumeReplication object created for this
Expand Down
Loading
Loading