github.com/openebs/api@v1.12.0/pkg/apis/cstor/v1/cstorvolume.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 "k8s.io/apimachinery/pkg/api/resource" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 ) 23 24 // +genclient 25 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 // +resource:path=cstorvolume 27 28 // CStorVolume describes a cstor volume resource created as custom resource 29 type CStorVolume struct { 30 metav1.TypeMeta `json:",inline"` 31 metav1.ObjectMeta `json:"metadata,omitempty"` 32 Spec CStorVolumeSpec `json:"spec"` 33 Status CStorVolumeStatus `json:"status"` 34 VersionDetails VersionDetails `json:"versionDetails"` 35 } 36 37 // CStorVolumeSpec is the spec for a CStorVolume resource 38 type CStorVolumeSpec struct { 39 // Capacity represents the desired size of the underlying volume. 40 Capacity resource.Quantity `json:"capacity"` 41 42 // TargetIP IP of the iSCSI target service 43 TargetIP string `json:"targetIP"` 44 45 // iSCSI Target Port typically TCP ports 3260 46 TargetPort string `json:"targetPort"` 47 48 // Target iSCSI Qualified Name.combination of nodeBase 49 Iqn string `json:"iqn"` 50 51 // iSCSI Target Portal. The Portal is combination of IP:port (typically TCP ports 3260) 52 TargetPortal string `json:"targetPortal"` 53 54 // ReplicationFactor represents number of volume replica created during volume 55 // provisioning connect to the target 56 ReplicationFactor int `json:"replicationFactor"` 57 58 // ConsistencyFactor is minimum number of volume replicas i.e. `RF/2 + 1` 59 // has to be connected to the target for write operations. Basically more then 60 // 50% of replica has to be connected to target. 61 ConsistencyFactor int `json:"consistencyFactor"` 62 63 // DesiredReplicationFactor represents maximum number of replicas 64 // that are allowed to connect to the target. Required for scale operations 65 DesiredReplicationFactor int `json:"desiredReplicationFactor"` 66 67 //ReplicaDetails refers to the trusty replica information 68 ReplicaDetails CStorVolumeReplicaDetails `json:"replicaDetails,omitempty"` 69 } 70 71 // ReplicaID is to hold replicaID information 72 type ReplicaID string 73 74 // CStorVolumePhase is to hold result of action. 75 type CStorVolumePhase string 76 77 // CStorVolumeStatus is for handling status of cvr. 78 type CStorVolumeStatus struct { 79 Phase CStorVolumePhase `json:"phase"` 80 ReplicaStatuses []ReplicaStatus `json:"replicaStatuses,omitempty"` 81 // Represents the actual capacity of the underlying volume. 82 Capacity resource.Quantity `json:"capacity,omitempty"` 83 // LastTransitionTime refers to the time when the phase changes 84 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 85 // LastUpdateTime refers to the time when last status updated due to any 86 // operations 87 LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` 88 // A human-readable message indicating details about why the volume is in this state. 89 Message string `json:"message,omitempty"` 90 // Current Condition of cstorvolume. If underlying persistent volume is being 91 // resized then the Condition will be set to 'ResizePending'. 92 // +optional 93 // +patchMergeKey=type 94 // +patchStrategy=merge 95 Conditions []CStorVolumeCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,4,rep,name=conditions"` 96 // ReplicaDetails refers to the trusty replica information 97 ReplicaDetails CStorVolumeReplicaDetails `json:"replicaDetails,omitempty"` 98 } 99 100 // CStorVolumeReplicaDetails contains trusty replica inform which will be 101 // updated by target 102 type CStorVolumeReplicaDetails struct { 103 // KnownReplicas represents the replicas that target can trust to read data 104 KnownReplicas map[ReplicaID]string `json:"knownReplicas,omitempty"` 105 } 106 107 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 108 // +resource:path=cstorvolume 109 110 // CStorVolumeList is a list of CStorVolume resources 111 type CStorVolumeList struct { 112 metav1.TypeMeta `json:",inline"` 113 metav1.ListMeta `json:"metadata"` 114 115 Items []CStorVolume `json:"items"` 116 } 117 118 // CVStatusResponse stores the reponse of istgt replica command output 119 // It may contain several volumes 120 type CVStatusResponse struct { 121 CVStatuses []CVStatus `json:"volumeStatus"` 122 } 123 124 // CVStatus stores the status of a CstorVolume obtained from response 125 type CVStatus struct { 126 Name string `json:"name"` 127 Status string `json:"status"` 128 ReplicaStatuses []ReplicaStatus `json:"replicaStatus"` 129 } 130 131 // ReplicaStatus stores the status of replicas 132 type ReplicaStatus struct { 133 // ID is replica unique identifier 134 ID string `json:"replicaId"` 135 // Mode represents replica status i.e. Healthy, Degraded 136 Mode string `json:"mode"` 137 // Represents IO number of replica persisted on the disk 138 CheckpointedIOSeq string `json:"checkpointedIOSeq"` 139 // Ongoing reads I/O from target to replica 140 InflightRead string `json:"inflightRead"` 141 // ongoing writes I/O from target to replica 142 InflightWrite string `json:"inflightWrite"` 143 // Ongoing sync I/O from target to replica 144 InflightSync string `json:"inflightSync"` 145 // time since the replica connected to target 146 UpTime int `json:"upTime"` 147 // Quorum indicates wheather data wrtitten to the replica 148 // is lost or exists. 149 // "0" means: data has been lost( might be ephimeral case) 150 // and will recostruct data from other Healthy replicas in a write-only 151 // mode 152 // 1 means: written data is exists on replica 153 Quorum string `json:"quorum"` 154 } 155 156 // CStorVolumeCondition contains details about state of cstorvolume 157 type CStorVolumeCondition struct { 158 Type CStorVolumeConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CStorVolumeConditionType"` 159 Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"` 160 // Last time we probed the condition. 161 // +optional 162 LastProbeTime metav1.Time `json:"lastProbeTime,omitempty" protobuf:"bytes,3,opt,name=lastProbeTime"` 163 // Last time the condition transitioned from one status to another. 164 // +optional 165 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"` 166 // Unique, this should be a short, machine understandable string that gives the reason 167 // for condition's last transition. If it reports "ResizePending" that means the underlying 168 // cstorvolume is being resized. 169 // +optional 170 Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"` 171 // Human-readable message indicating details about last transition. 172 // +optional 173 Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"` 174 } 175 176 // CStorVolumeConditionType is a valid value of CStorVolumeCondition.Type 177 type CStorVolumeConditionType string 178 179 const ( 180 // CStorVolumeResizing - a user trigger resize of pvc has been started 181 CStorVolumeResizing CStorVolumeConditionType = "Resizing" 182 ) 183 184 // ConditionStatus states in which state condition is present 185 type ConditionStatus string 186 187 // These are valid condition statuses. "ConditionInProgress" means corresponding 188 // condition is inprogress. "ConditionSuccess" means corresponding condition is success 189 const ( 190 // ConditionInProgress states resize of underlying volumes are in progress 191 ConditionInProgress ConditionStatus = "InProgress" 192 // ConditionSuccess states resizing underlying volumes are successfull 193 ConditionSuccess ConditionStatus = "Success" 194 )