This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Introduce v1beta1 CRD for replication objects. #132
Open
humblec
wants to merge
4
commits into
csi-addons:main
Choose a base branch
from
humblec:update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
960be74
add go build tag and also rebase to latest dependency versions.
humblec caf40c2
use latest controller-gen v0.9.0 in the build
humblec cee3406
Add v1beta1 CRD version for replication* types
humblec 5c36b7a
disable hughParam check of gocritic for the reconciler object
humblec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2022. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package v1beta1 contains API Schema definitions for the replication v1beta1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=replication.storage.openshift.io | ||
package v1beta1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects. | ||
GroupVersion = schema.GroupVersion{Group: "replication.storage.openshift.io", Version: "v1beta1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
Copyright 2022. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// ReplicationState represents the replication operations to be performed on the volume. | ||
// +kubebuilder:validation:Enum=primary;secondary;resync | ||
type ReplicationState string | ||
|
||
const ( | ||
// Primary ReplicationState enables mirroring and promotes the volume to primary. | ||
Primary ReplicationState = "primary" | ||
|
||
// Secondary ReplicationState demotes the volume to secondary and resyncs the volume if out of sync. | ||
Secondary ReplicationState = "secondary" | ||
|
||
// Resync option resyncs the volume. | ||
Resync ReplicationState = "resync" | ||
) | ||
|
||
// State captures the latest state of the replication operation. | ||
type State string | ||
|
||
const ( | ||
// PrimaryState represents the Primary replication state. | ||
PrimaryState State = "Primary" | ||
|
||
// SecondaryState represents the Secondary replication state. | ||
SecondaryState State = "Secondary" | ||
|
||
// UnknownState represents the Unknown replication state. | ||
UnknownState State = "Unknown" | ||
) | ||
|
||
// VolumeReplicationSpec defines the desired state of VolumeReplication. | ||
type VolumeReplicationSpec struct { | ||
// VolumeReplicationClass is the VolumeReplicationClass name for this VolumeReplication resource | ||
// +kubebuilder:validation:Required | ||
VolumeReplicationClass string `json:"volumeReplicationClass"` | ||
|
||
// ReplicationState represents the replication operation to be performed on the volume. | ||
// Supported operations are "primary", "secondary" and "resync" | ||
// +kubebuilder:validation:Required | ||
ReplicationState ReplicationState `json:"replicationState"` | ||
|
||
// DataSource represents the object associated with the volume | ||
// +kubebuilder:validation:Required | ||
DataSource corev1.TypedLocalObjectReference `json:"dataSource"` | ||
|
||
// replicationHandle represents an existing (but new) replication id | ||
// +kubebuilder:validation:Optional | ||
ReplicationHandle string `json:"replicationHandle"` | ||
} | ||
|
||
// VolumeReplicationStatus defines the observed state of VolumeReplication. | ||
type VolumeReplicationStatus struct { | ||
State State `json:"state,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
// Conditions are the list of conditions and their status. | ||
Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
// observedGeneration is the last generation change the operator has dealt with | ||
// +optional | ||
ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"` | ||
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date | ||
// +kubebuilder:printcolumn:JSONPath=".spec.volumeReplicationClass",name=volumeReplicationClass,type=string | ||
// +kubebuilder:printcolumn:JSONPath=".spec.dataSource.name",name=pvcName,type=string | ||
// +kubebuilder:printcolumn:JSONPath=".spec.replicationState",name=desiredState,type=string | ||
// +kubebuilder:printcolumn:JSONPath=".status.state",name=currentState,type=string | ||
// +kubebuilder:resource:shortName=vr | ||
|
||
// VolumeReplication is the Schema for the volumereplications API. | ||
type VolumeReplication struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec VolumeReplicationSpec `json:"spec,omitempty"` | ||
Status VolumeReplicationStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// VolumeReplicationList contains a list of VolumeReplication. | ||
type VolumeReplicationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []VolumeReplication `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&VolumeReplication{}, &VolumeReplicationList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright 2022. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// VolumeReplicationClassSpec specifies parameters that an underlying storage system uses | ||
// when creating a volume replica. A specific VolumeReplicationClass is used by specifying | ||
// its name in a VolumeReplication object. | ||
type VolumeReplicationClassSpec struct { | ||
// Provisioner is the name of storage provisioner | ||
// +kubebuilder:validation:Required | ||
Provisioner string `json:"provisioner"` | ||
// Parameters is a key-value map with storage provisioner specific configurations for | ||
// creating volume replicas | ||
// +kubebuilder:validation:Optional | ||
Parameters map[string]string `json:"parameters,omitempty"` | ||
} | ||
|
||
// VolumeReplicationClassStatus defines the observed state of VolumeReplicationClass. | ||
type VolumeReplicationClassStatus struct{} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:scope=Cluster,shortName=vrc | ||
// +kubebuilder:printcolumn:JSONPath=".spec.provisioner",name=provisioner,type=string | ||
|
||
// VolumeReplicationClass is the Schema for the volumereplicationclasses API. | ||
type VolumeReplicationClass struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec VolumeReplicationClassSpec `json:"spec,omitempty"` | ||
Status VolumeReplicationClassStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// VolumeReplicationClassList contains a list of VolumeReplicationClass. | ||
type VolumeReplicationClassList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []VolumeReplicationClass `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&VolumeReplicationClass{}, &VolumeReplicationClassList{}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we are ready for beta yet!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Madhu-1 any thoughts from your end ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes as discussed we are planning to move volRep to csiaddons, we aren't ready to move to beta Yet.