github.com/openebs/api@v1.12.0/pkg/apis/cstor/v1/cstorvolumereplica.go (about) 1 /* 2 Copyright 2020 The OpenEBS Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // CVRKey represents the properties of a cstorvolumereplica 24 type CVRKey string 25 26 const ( 27 // CloneEnableKEY is used to enable/disable cloning for a cstorvolumereplica 28 CloneEnableKEY CVRKey = "openebs.io/cloned" 29 30 // SourceVolumeKey stores the name of source volume whose snapshot is used to 31 // create this cvr 32 SourceVolumeKey CVRKey = "openebs.io/source-volume" 33 34 // SnapshotNameKey stores the name of the snapshot being used to restore this replica 35 SnapshotNameKey CVRKey = "openebs.io/snapshot" 36 ) 37 38 // +genclient 39 // +genclient:noStatus 40 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 41 // +resource:path=cstorvolumereplica 42 43 // CStorVolumeReplica describes a cstor volume resource created as custom resource 44 type CStorVolumeReplica struct { 45 metav1.TypeMeta `json:",inline"` 46 metav1.ObjectMeta `json:"metadata,omitempty"` 47 Spec CStorVolumeReplicaSpec `json:"spec"` 48 Status CStorVolumeReplicaStatus `json:"status"` 49 VersionDetails VersionDetails `json:"versionDetails"` 50 } 51 52 // CStorVolumeReplicaSpec is the spec for a CStorVolumeReplica resource 53 type CStorVolumeReplicaSpec struct { 54 // TargetIP represents iscsi target IP through which replica cummunicates 55 // IO workloads and other volume operations like snapshot and resize requests 56 TargetIP string `json:"targetIP"` 57 //Represents the actual capacity of the underlying volume 58 Capacity string `json:"capacity"` 59 // ZvolWorkers represents number of threads that executes client IOs 60 ZvolWorkers string `json:"zvolWorkers"` 61 // ReplicaID is unique number to identify the replica 62 ReplicaID string `json:"replicaid"` 63 // Controls the compression algorithm used for this volumes 64 // examples: on|off|gzip|gzip-N|lz4|lzjb|zle 65 Compression string `json:"compression"` 66 // BlockSize is the logical block size in multiple of 512 bytes 67 // BlockSize specifies the block size of the volume. The blocksize 68 // cannot be changed once the volume has been written, so it should be 69 // set at volume creation time. The default blocksize for volumes is 4 Kbytes. 70 // Any power of 2 from 512 bytes to 128 Kbytes is valid. 71 BlockSize uint32 `json:"blockSize"` 72 } 73 74 // CStorVolumeReplicaPhase is to hold result of action. 75 type CStorVolumeReplicaPhase string 76 77 // Status written onto CStorVolumeReplica objects. 78 const ( 79 80 // CVRStatusEmpty describes CVR resource is created but not yet monitored by 81 // controller(i.e resource is just created) 82 CVRStatusEmpty CStorVolumeReplicaPhase = "" 83 84 // CVRStatusOnline describes volume replica is Healthy and data existing on 85 // the healthy replica is up to date 86 CVRStatusOnline CStorVolumeReplicaPhase = "Healthy" 87 88 // CVRStatusOffline describes volume replica is created but not yet connected 89 // to the target 90 CVRStatusOffline CStorVolumeReplicaPhase = "Offline" 91 92 // CVRStatusDegraded describes volume replica is connected to the target and 93 // rebuilding from other replicas is not yet started but ready for serving 94 // IO's 95 CVRStatusDegraded CStorVolumeReplicaPhase = "Degraded" 96 97 // CVRStatusNewReplicaDegraded describes replica is recreated (due to pool 98 // recreation[underlying disk got changed]/volume replica scaleup cases) and 99 // just connected to the target. Volume replica has to start reconstructing 100 // entier data from another available healthy replica. Until volume replica 101 // becomes healthy whatever data written to it is lost(NewReplica also not part 102 // of any quorum decision) 103 CVRStatusNewReplicaDegraded CStorVolumeReplicaPhase = "NewReplicaDegraded" 104 105 // CVRStatusRebuilding describes volume replica has missing data and it 106 // started rebuilding missing data from other replicas 107 CVRStatusRebuilding CStorVolumeReplicaPhase = "Rebuilding" 108 109 // CVRStatusReconstructingNewReplica describes volume replica is recreated 110 // and it started reconstructing entier data from other healthy replica 111 CVRStatusReconstructingNewReplica CStorVolumeReplicaPhase = "ReconstructingNewReplica" 112 113 // CVRStatusError describes either volume replica is not exist in cstor pool 114 CVRStatusError CStorVolumeReplicaPhase = "Error" 115 116 // CVRStatusDeletionFailed describes volume replica deletion is failed 117 CVRStatusDeletionFailed CStorVolumeReplicaPhase = "DeletionFailed" 118 119 // CVRStatusInvalid ensures invalid resource(currently not honoring) 120 CVRStatusInvalid CStorVolumeReplicaPhase = "Invalid" 121 122 // CVRStatusInit describes CVR resource is newly created but it is not yet 123 // created zfs dataset 124 CVRStatusInit CStorVolumeReplicaPhase = "Init" 125 126 // CVRStatusRecreate describes the volume replica is recreated due to pool 127 // recreation/scaleup 128 CVRStatusRecreate CStorVolumeReplicaPhase = "Recreate" 129 ) 130 131 // CStorVolumeReplicaStatus is for handling status of cvr. 132 type CStorVolumeReplicaStatus struct { 133 // CStorVolumeReplicaPhase is to holds different phases of replica 134 Phase CStorVolumeReplicaPhase `json:"phase"` 135 136 // CStorVolumeCapacityDetails represents capacity info of replica 137 Capacity CStorVolumeReplicaCapacityDetails `json:"capacity"` 138 139 // LastTransitionTime refers to the time when the phase changes 140 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 141 142 // The last updated time 143 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` 144 145 // A human readable message indicating details about the transition. 146 Message string `json:"message,omitempty"` 147 148 // Snapshots contains list of snapshots, and their properties, 149 // created on CVR 150 Snapshots map[string]CStorSnapshotInfo `json:"snapshots,omitempty"` 151 152 // PendingSnapshots contains list of pending snapshots that are not yet 153 // available on this replica 154 PendingSnapshots map[string]CStorSnapshotInfo `json:"pendingSnapshots,omitempty"` 155 } 156 157 // CStorSnapshotInfo represents the snapshot information related to particular 158 // snapshot 159 type CStorSnapshotInfo struct { 160 // LogicalReferenced describes the amount of space that is "logically" 161 // accessable by this snapshot. This logical space ignores the 162 // effect of the compression and copies properties, giving a quantity 163 // closer to the amount of data that application see. It also includes 164 // space consumed by metadata. 165 LogicalReferenced uint64 `json:"logicalReferenced"` 166 167 // TODO: We will revisit when we are working on rebuild estimates 168 // Used is the used bytes for given snapshot 169 // Used uint64 `json:"used"` 170 } 171 172 // CStorVolumeReplicaCapacityDetails represents capacity information releated to volume 173 // replica 174 type CStorVolumeReplicaCapacityDetails struct { 175 // The amount of space consumed by this volume replica and all its descendents 176 Total string `json:"total"` 177 // The amount of space that is "logically" accessible by this dataset. The logical 178 // space ignores the effect of the compression and copies properties, giving a 179 // quantity closer to the amount of data that applications see. However, it does 180 // include space consumed by metadata 181 Used string `json:"used"` 182 } 183 184 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 185 // +resource:path=cstorvolumereplicas 186 187 // CStorVolumeReplicaList is a list of CStorVolumeReplica resources 188 type CStorVolumeReplicaList struct { 189 metav1.TypeMeta `json:",inline"` 190 metav1.ListMeta `json:"metadata"` 191 192 Items []CStorVolumeReplica `json:"items"` 193 }