github.com/openebs/api@v1.12.0/design/cstor/v1/cstorvolume.md (about)

     1  # Proposed v1 CStorVolumes and CStorVolumeReplica Schema
     2  
     3  ## Table of Contents
     4  
     5  * [Introduction](#introduction)
     6  * [Goals](#goals)
     7  * [CStor Volume Schema Proposal](#cstor-volume-schema-proposal)
     8  
     9  ## Introduction
    10  
    11  This proposal highlights the enhancements and migration of current `CStorVolumes` and `CStorVolumeReplicas` schema and
    12  proposes improvements.
    13  
    14  # Goals
    15  
    16  The major goal of this document is to freeze the APIs schema for `CStorVolumes` and `CStorVolumeReplica`,
    17  based on various learning and feedbacks from the user including various volume related day 2 operations.
    18  
    19  # CStor Volume Schema Proposal
    20  
    21  ## `CStorVolumes` APIs
    22  
    23  ```go
    24  // +genclient
    25  // +k8s:openapi-gen=true
    26  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    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  	VersionDetails    VersionDetails    `json:"versionDetails"`
    34  	Status            CStorVolumeStatus `json:"status"`
    35  }
    36  
    37  
    38  // CStorVolumeSpec is the spec for a CStorVolume resource
    39  type CStorVolumeSpec struct {
    40  	// Capacity represents the desired size of the underlying volume.
    41  	Capacity resource.Quantity `json:"capacity"`
    42  
    43  	// TargetIP IP of the iSCSI target service
    44  	TargetIP string `json:"targetIP"`
    45  
    46  	// iSCSI Target Port typically TCP ports 3260
    47  	TargetPort string `json:"targetPort"`
    48  
    49  	// Target iSCSI Qualified Name.combination of nodeBase
    50  	Iqn string `json:"iqn"`
    51  
    52  	// iSCSI Target Portal. The Portal is combination of IP:port (typically TCP ports 3260)
    53  	TargetPortal string `json:"targetPortal"`
    54  
    55  	// ReplicationFactor represents number of volume replica created during volume
    56  	// provisioning connect to the target
    57  	ReplicationFactor int `json:"replicationFactor"`
    58  
    59  	// ConsistencyFactor is minimum number of volume replicas i.e. `RF/2 + 1`
    60  	// has to be connected to the target for write operations. Basically more then
    61  	// 50% of replica has to be connected to target.
    62  	ConsistencyFactor int `json:"consistencyFactor"`
    63  
    64  	// DesiredReplicationFactor represents maximum number of replicas
    65  	// that are allowed to connect to the target. Required for scale operations
    66  	DesiredReplicationFactor int `json:"desiredReplicationFactor"`
    67  
    68  	//ReplicaDetails refers to the trusty replica information
    69  	ReplicaDetails CStorVolumeReplicaDetails `json:"replicaDetails,omitempty"`
    70  }
    71  
    72  // ReplicaID is to hold replicaID information
    73  type ReplicaID string
    74  
    75  // CStorVolumePhase is to hold result of action.
    76  type CStorVolumePhase string
    77  
    78  // CStorVolumeStatus is for handling status of cvr.
    79  type CStorVolumeStatus struct {
    80  	Phase           CStorVolumePhase `json:"phase"`
    81  	ReplicaStatuses []ReplicaStatus  `json:"replicaStatuses,omitempty"`
    82  	// Represents the actual resources of the underlying volume.
    83  	Capacity resource.Quantity `json:"capacity,omitempty"`
    84  	// LastTransitionTime refers to the time when the phase changes
    85  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
    86  	// LastUpdateTime refers to the time when last status updated due to any
    87  	// operations
    88  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
    89  	// A human-readable message indicating details about why the volume is in this state.
    90  	Message string `json:"message,omitempty"`
    91  	// Current Condition of cstorvolume. If underlying persistent volume is being
    92  	// resized then the Condition will be set to 'ResizePending'.
    93  	// +optional
    94  	// +patchMergeKey=type
    95  	// +patchStrategy=merge
    96  	Conditions []CStorVolumeCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
    97  	// ReplicaDetails refers to the trusty replica information which are
    98  	// connected at given time
    99  	ReplicaDetails CStorVolumeReplicaDetails `json:"replicaDetails,omitempty"`
   100  }
   101  
   102  // CStorVolumeReplicaDetails contains trusty replica inform which will be
   103  // updated by target
   104  type CStorVolumeReplicaDetails struct {
   105  	// KnownReplicas represents the replicas that target can trust to read data
   106  	KnownReplicas map[ReplicaID]string `json:"knownReplicas,omitempty"`
   107  }
   108  
   109  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   110  
   111  // CStorVolumeList is a list of CStorVolume resources
   112  type CStorVolumeList struct {
   113  	metav1.TypeMeta `json:",inline"`
   114  	metav1.ListMeta `json:"metadata"`
   115  
   116  	Items []CStorVolume `json:"items"`
   117  }
   118  
   119  // CVStatusResponse stores the response of istgt replica command output
   120  // It may contain several volumes
   121  type CVStatusResponse struct {
   122  	CVStatuses []CVStatus `json:"volumeStatus"`
   123  }
   124  
   125  // CVStatus stores the status of a CstorVolume obtained from response
   126  type CVStatus struct {
   127  	Name            string          `json:"name"`
   128  	Status          string          `json:"status"`
   129  	ReplicaStatuses []ReplicaStatus `json:"replicaStatus"`
   130  }
   131  
   132  
   133  // ReplicaStatus stores the status of replicas
   134  type ReplicaStatus struct {
   135  	// ID is replica unique identifier
   136  	ID string `json:"replicaId"`
   137  	// Mode represents replica status i.e. Healthy, Degraded
   138  	Mode string `json:"mode"`
   139  	// Represents IO number of replicas persisted on the disk
   140  	CheckpointedIOSeq string `json:"checkpointedIOSeq"`
   141  	// Ongoing reads I/O from target to replica
   142  	InflightRead string `json:"inflightRead"`
   143  	// ongoing writes I/O from target to replica
   144  	InflightWrite string `json:"inflightWrite"`
   145  	// Ongoing sync I/O from target to replica
   146  	InflightSync string `json:"inflightSync"`
   147  	// time since the replica connected to target
   148  	UpTime int `json:"upTime"`
   149  	// Quorum indicates wheather data wrtitten to the replica
   150  	// is lost or exists.
   151  	// "0" means: data has been lost( might be ephimeral case)
   152  	// and will recostruct data from other Healthy replicas in a write-only
   153  	// mode
   154  	// 1 means: written data is exists on replica
   155  	Quorum string `json:"quorum"`
   156  }
   157  
   158  // CStorVolumeCondition contains details about state of cstorvolume
   159  type CStorVolumeCondition struct {
   160  	// Type is a different valid value of CStorVolumeCondition
   161  	Type   CStorVolumeConditionType `json:"type"`
   162  	
   163  	Status ConditionStatus `json:"status"`
   164  	// Last time we probed the condition.
   165  	// +optional
   166  	LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
   167  	// Last time the condition transitioned from one status to another.
   168  	// +optional
   169  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
   170  	// Unique, this should be a short, machine understandable string that gives the reason
   171  	// for condition's last transition. If it reports "ResizePending" that means the underlying
   172  	// cstorvolume is being resized.
   173  	// +optional
   174  	Reason string `json:"reason,omitempty"`
   175  	// Human-readable message indicating details about last transition.
   176  	// +optional
   177  	Message string `json:"message,omitempty"`
   178  }
   179  
   180  // CStorVolumeConditionType is a valid value of CStorVolumeCondition.Type
   181  type CStorVolumeConditionType string
   182  
   183  const (
   184  	// CStorVolumeResizing - a user trigger resize of pvc has been started
   185  	CStorVolumeResizing CStorVolumeConditionType = "Resizing"
   186  )
   187  
   188  // ConditionStatus states in which state condition is present
   189  type ConditionStatus string
   190  
   191  // These are valid condition statuses. "ConditionInProgress" means corresponding
   192  // condition is inprogress. "ConditionSuccess" means corresponding condition is success
   193  const (
   194  	// ConditionInProgress states resize of underlying volumes are in progress
   195  	ConditionInProgress ConditionStatus = "InProgress"
   196  	// ConditionSuccess states resizing underlying volumes are successful
   197  	ConditionSuccess ConditionStatus = "Success"
   198  )
   199  ```
   200  
   201  ## CStorVolumeReplicas APIs
   202  
   203  ```go
   204  
   205  // +genclient
   206  // +genclient:noStatus
   207  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   208  // +resource:path=cstorvolumereplica
   209  
   210  // CStorVolumeReplica describes a cstor volume resource created as custom resource
   211  type CStorVolumeReplica struct {
   212  	metav1.TypeMeta   `json:",inline"`
   213  	metav1.ObjectMeta `json:"metadata,omitempty"`
   214  	Spec              CStorVolumeReplicaSpec   `json:"spec"`
   215  	Status            CStorVolumeReplicaStatus `json:"status"`
   216  	VersionDetails    VersionDetails           `json:"versionDetails"`
   217  }
   218  
   219  
   220  // CStorVolumeReplicaSpec is the spec for a CStorVolumeReplica resource
   221  type CStorVolumeReplicaSpec struct {
   222  	// TargetIP represents iscsi target IP through which replica cummunicates
   223  	// IO workloads and other volume operations like snapshot and resize requests
   224  	TargetIP string `json:"targetIP"`
   225  	//Represents the actual capacity of the underlying volume
   226  	Capacity string `json:"capacity"`
   227  	// ZvolWorkers represents number of threads that executes client IOs
   228  	ZvolWorkers string `json:"zvolWorkers"`
   229  	// ReplicaID is unique number to identify the replica
   230  	ReplicaID string `json:"replicaid"`
   231  	// Controls the compression algorithm used for this volumes
   232  	// examples: on|off|gzip|gzip-N|lz4|lzjb|zle
   233  	Compression string `json:"compression"`
   234  	// BlockSize is the logical block size in multiple of 512 bytes
   235  	// BlockSize specifies the block size of the volume. The blocksize
   236  	// cannot be changed once the volume has been written, so it should be
   237  	// set at volume creation time. The default blocksize for volumes is 4 Kbytes.
   238  	// Any power of 2 from 512 bytes to 128 Kbytes is valid.
   239  	BlockSize uint32 `json:"blockSize"`
   240  }
   241  
   242  
   243  // CStorVolumeReplicaPhase is to hold result of action.
   244  type CStorVolumeReplicaPhase string
   245  
   246  // Status written onto CStorVolumeReplica objects.
   247  const (
   248  
   249  	// CVRStatusEmpty describes CVR resource is created but not yet monitored by
   250  	// controller(i.e resource is just created)
   251  	CVRStatusEmpty CStorVolumeReplicaPhase = ""
   252  
   253  	// CVRStatusOnline describes volume replica is Healthy and data existing on
   254  	// the healthy replica is up to date
   255  	CVRStatusOnline CStorVolumeReplicaPhase = "Healthy"
   256  
   257  	// CVRStatusOffline describes volume replica is created but not yet connected
   258  	// to the target
   259  	CVRStatusOffline CStorVolumeReplicaPhase = "Offline"
   260  
   261  	// CVRStatusDegraded describes volume replica is connected to the target and
   262  	// rebuilding from other replicas is not yet started but ready for serving
   263  	// IO's
   264  	CVRStatusDegraded CStorVolumeReplicaPhase = "Degraded"
   265  
   266  	// CVRStatusNewReplicaDegraded describes replica is recreated (due to pool
   267  	// recreation[underlying disk got changed]/volume replica scaleup cases) and
   268  	// just connected to the target. Volume replica has to start reconstructing
   269  	// entire data from another available healthy replica. Until volume replica
   270  	// becomes healthy whatever data written to it is lost(NewReplica also not part
   271  	// of any quorum decision)
   272  	CVRStatusNewReplicaDegraded CStorVolumeReplicaPhase = "NewReplicaDegraded"
   273  
   274  	// CVRStatusRebuilding describes volume replica has missing data and it
   275  	// started rebuilding missing data from other replicas
   276  	CVRStatusRebuilding CStorVolumeReplicaPhase = "Rebuilding"
   277  
   278  	// CVRStatusReconstructingNewReplica describes volume replica is recreated
   279  	// and it started reconstructing entire data from other healthy replica
   280  	CVRStatusReconstructingNewReplica CStorVolumeReplicaPhase = "ReconstructingNewReplica"
   281  
   282  	// CVRStatusError describes either volume replica is not exist in cstor pool
   283  	CVRStatusError CStorVolumeReplicaPhase = "Error"
   284  
   285  	// CVRStatusDeletionFailed describes volume replica deletion is failed
   286  	CVRStatusDeletionFailed CStorVolumeReplicaPhase = "DeletionFailed"
   287  
   288  	// CVRStatusInvalid ensures invalid resource(currently not honoring)
   289  	CVRStatusInvalid CStorVolumeReplicaPhase = "Invalid"
   290  
   291  	// CVRStatusInit describes CVR resource is newly created but it is not yet
   292  	// created zfs dataset
   293  	CVRStatusInit CStorVolumeReplicaPhase = "Init"
   294  
   295  	// CVRStatusRecreate describes the volume replica is recreated due to pool
   296  	// recreation/scaleup
   297  	CVRStatusRecreate CStorVolumeReplicaPhase = "Recreate"
   298  )
   299  
   300  // CStorVolumeReplicaStatus is for handling status of cvr.
   301  type CStorVolumeReplicaStatus struct {
   302  	// CStorVolumeReplicaPhase is to holds different phases of replica
   303  	Phase CStorVolumeReplicaPhase `json:"phase"`
   304  	// CStorVolumeCapacityDetails represents capacity info of replica
   305  	Capacity CStorVolumeReplicaCapacityDetails `json:"capacity"`
   306  	// LastTransitionTime refers to the time when the phase changes
   307  	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
   308  	// The last updated time
   309  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
   310  	// A human readable message indicating details about the transition.
   311  	Message string `json:"message,omitempty"`
   312  
   313  	// Snapshots contains list of snapshots, and their properties,
   314  	// created on CVR
   315  	Snapshots map[string]CStorSnapshotInfo `json:"snapshots,omitempty"`
   316  
   317  	// PendingSnapshots contains list of pending snapshots that are not yet
   318  	// available on this replica
   319  	PendingSnapshots map[string]CStorSnapshotInfo `json:"pendingSnapshots,omitempty"`
   320  }
   321  
   322  // CStorSnapshotInfo represents the snapshot information related to particular
   323  // snapshot
   324  type CStorSnapshotInfo struct {
   325  	// LogicalReferenced describes the amount of space that is "logically"
   326  	// accessable by this snapshot. This logical space ignores the
   327  	// effect of the compression and copies properties, giving a quantity
   328  	// closer to the amount of data that application see. It also includes
   329  	// space consumed by metadata.
   330  	LogicalReferenced uint64 `json:"logicalReferenced"`
   331  
   332  	// Used is the used bytes for given snapshot
   333  	// Used uint64 `json:"used"`
   334  }
   335  
   336  
   337  // CStorVolumeReplicaCapacityDetails represents capacity information related to volume
   338  // replica
   339  type CStorVolumeReplicaCapacityDetails struct {
   340  	// The amount of space consumed by this volume replica and all its descendants
   341  	Total string `json:"total"`
   342  	// The amount of space that is "logically" accessible by this dataset. The logical
   343  	// space ignores the effect of the compression and copies properties, giving a
   344  	// quantity closer to the amount of data that applications see.  However, it does
   345  	// include space consumed by metadata
   346  	Used string `json:"used"`
   347  }
   348  
   349  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   350  // +resource:path=cstorvolumereplicas
   351  
   352  // CStorVolumeReplicaList is a list of CStorVolumeReplica resources
   353  type CStorVolumeReplicaList struct {
   354  	metav1.TypeMeta `json:",inline"`
   355  	metav1.ListMeta `json:"metadata"`
   356  
   357  	Items []CStorVolumeReplica `json:"items"`
   358  }
   359  
   360  ```