Skip to content

Commit e6ac4bd

Browse files
authored
Merge pull request #4298 from sunnylovestiramisu/kep-3751
Update ControllerModifyVolume Status API
2 parents c63ac8e + 3b80df9 commit e6ac4bd

File tree

3 files changed

+42
-53
lines changed

3 files changed

+42
-53
lines changed

keps/sig-storage/3751-volume-attributes-class/README.md

+42-53
Original file line numberDiff line numberDiff line change
@@ -172,27 +172,49 @@ type PersistentVolumeClaimSpec struct {
172172
...
173173
}
174174
175+
// Add the PersistentVolumeClaimModifyVolume condition to existing PersistentVolumeClaimConditionType
176+
// Condition is used to document the last error controller sees
177+
const (
178+
...
179+
// Applying the target VolumeAttributesClass encountered an error
180+
PersistentVolumeClaimVolumeModifyVolumeError PersistentVolumeClaimConditionType = "ModifyVolumeError"
181+
// Volume is being modified
182+
PersistentVolumeClaimVolumeModifyingVolume PersistentVolumeClaimConditionType = "ModifyingVolume"
183+
...
184+
)
185+
186+
175187
// PersistentVolumeClaimStatus represents the status of PV claim
176188
type PersistentVolumeClaimStatus struct {
177189
...
178-
// The VolumeAttributesClassName string cannot be empty
179-
VolumeAttributesClassName string
180-
ModifyVolumeStatus *PersistentVolumeClaimModifyVolumeStatus
190+
// CurrentVolumeAttributesClassName is the current name of the VolumeAttributesClass the PVC is using
191+
CurrentVolumeAttributesClassName *string
192+
// ModifyVolumeStatus represents the status object of ControllerModifyVolume operation
193+
ModifyVolumeStatus *ModifyVolumeStatus
181194
...
182195
}
183196
197+
// ModifyVolumeStatus represents the status object of ControllerModifyVolume operation
198+
type ModifyVolumeStatus struct {
199+
// TargetVolumeAttributesClassName is the name of the VolumeAttributesClass the PVC currently being reconciled
200+
TargetVolumeAttributesClassName string
201+
// Status is the status of the ControllerModifyVolume operation
202+
Status PersistentVolumeClaimModifyVolumeStatus
203+
}
204+
184205
// +enum
206+
// New statuses can be added in the future. Consumers should check for unknown statuses and fail appropriately
185207
type PersistentVolumeClaimModifyVolumeStatus string
186208
187209
const (
188-
// When modify volume is complete, the empty string is set by modify volume controller.
189-
PersistentVolumeClaimNoModifyVolumeInProgress PersistentVolumeClaimModifyVolumeStatus = ""
190-
// State set when modify volume controller starts modifying the volume in control-plane
191-
PersistentVolumeClaimControllerModifyVolumeInProgress PersistentVolumeClaimModifyVolumeStatus = "ControllerModifyVolumeInProgress"
192-
// State set when modify volume has failed in modify volume controller with a terminal error.
193-
// Transient errors such as timeout should not set this status and should leave ModifyVolumeStatus
194-
// unmodified, so as modify volume controller can resume the volume modification.
195-
PersistentVolumeClaimControllerModifyVolumeFailed PersistentVolumeClaimModifyVolumeStatus = "ControllerModifyVolumeFailed"
210+
// Pending indicates that the PersistentVolumeClaim cannot be modified due to unmet requirements, such as
211+
// the specified VolumeAttributesClass not existing
212+
PersistentVolumeClaimModifyVolumePending PersistentVolumeClaimModifyVolumeStatus = "Pending"
213+
// InProgress indicates that the volume is being modified
214+
PersistentVolumeClaimModifyVolumeInProgress PersistentVolumeClaimModifyVolumeStatus = "InProgress"
215+
// Infeasible indicates that the request has been rejected as invalid by the CSI driver. To
216+
// resolve the error, a valid VolumeAttributesClass needs to be specified
217+
PersistentVolumeClaimModifyVolumeInfeasible PersistentVolumeClaimModifyVolumeStatus = "Infeasible"
196218
)
197219
198220
```
@@ -204,37 +226,6 @@ Cluster administrators can use K8s quota to specify how many PVCs can use a spec
204226
### CSI API
205227
The CSI create request will be extended to add mutable parameters. A new ControllerModifyVolume RPC will be added. More details in [CSI Spec PR](https://github.com/container-storage-interface/spec/pull/544).
206228

207-
```
208-
// ControllerServer is the server API for Controller service.
209-
type ControllerServer interface {
210-
...
211-
rpc ControllerModifyVolume (ModifyVolumeRequest)
212-
returns (ModifyVolumeResponse) {
213-
option (alpha_method) = true;
214-
}
215-
...
216-
}
217-
218-
message ModifyVolumeRequest {
219-
// Contains identity information for the existing volume.
220-
// This field is REQUIRED.
221-
string volume_id = 1
222-
// This field is OPTIONAL.This allows the CO to specify the
223-
// mutable parameters to apply.
224-
map<string, string> mutable_parameters = 2;
225-
}
226-
message ModifyVolumeResponse {}
227-
228-
message CreateVolumeRequest {
229-
...
230-
// See CreateVolumeRequest.parameters.
231-
// This field is OPTIONAL.
232-
map<string, string> parameters = 4;
233-
// This field is OPTIONAL. This allows the CO to specify the
234-
// volume attributes class parameters to apply.
235-
map<string, string> mutable_parameters = 8;
236-
}
237-
```
238229

239230
### User Stories (Optional)
240231

@@ -275,6 +266,7 @@ apiVersion: storage.k8s.io/v1alpha1
275266
kind: VolumeAttributesClass
276267
metadata:
277268
name: silver
269+
driverName: pd.csi.storage.gke.io
278270
parameters:
279271
iops: "500"
280272
throughput: "50MiB/s"
@@ -318,6 +310,7 @@ apiVersion: storage.k8s.io/v1alpha1
318310
kind: VolumeAttributesClass
319311
metadata:
320312
name: silver
313+
driverName: pd.csi.storage.gke.io
321314
parameters:
322315
iops: "500"
323316
throughput: "50MiB/s"
@@ -345,6 +338,7 @@ apiVersion: storage.k8s.io/v1alpha1
345338
kind: VolumeAttributesClass
346339
metadata:
347340
name: gold
341+
driverName: pd.csi.storage.gke.io
348342
parameters:
349343
iops: "1000"
350344
throughput: "100MiB/s"
@@ -408,15 +402,8 @@ The resource quota controller is the only component capable of monitoring and re
408402

409403
### 3. Add new statuses in PVC API to indicate changes of VolumeAttributesClass and the status of the ModifyVolume operation.
410404

411-
```
412-
type VolumeAttributesClassStatus string
405+
Please see session "Kubernetes API" above.
413406

414-
const (
415-
PersistentVolumeClaimControllerModifyVolumeProgress VolumeAttributesClassStatus = "ControllerModifyVolumeInProgress"
416-
PersistentVolumeClaimControllerModifyVolumePending VolumeAttributesClassStatus = "ControllerModifyVolumePending"
417-
PersistentVolumeClaimControllerModifyVolumeFailed VolumeAttributesClassStatus = "ControllerModifyVolumeFailed"
418-
)
419-
```
420407
### 4. Add new CSI API ControllerModifyVolume, when there is a change of VolumeAttributesClass in PVC, external-resizer triggers a ControllerModifyVolume operation against a CSI endpoint. A Controller Plugin MUST implement this RPC call if it has MODIFY_VOLUME capability.
421408

422409
### 5. Add new operation metrics for ModifyVolume operations
@@ -454,7 +441,7 @@ There are a few conditions that will trigger add/remove pvc finalizers in the Vo
454441
1. PVC created with a VolumeAttributesClass
455442

456443
The **VACObjectInUseProtection admission controller**:
457-
* Check if the VolumeAttributesClass exists. If not, the PVC will enter the PENDING state because we do not want to impose ordering on object creation
444+
* Check if the VolumeAttributesClass exists. If not, the PVC will enter the INPROGRESS state because we do not want to impose ordering on object creation
458445
* Check if this VolumeAttributesClass already has a protection finalizer
459446
* Add the finalizer to the VolumeAttributesClass if there is none
460447
2. PVC created with a VolumeAttributesClass being deleted
@@ -480,7 +467,7 @@ For unbound PVs referencing a VAC:
480467

481468
1. Unbound PV created with a VolumeAttributesClass
482469
The **VACObjectInUseProtection admission controller**:
483-
* Check if the VolumeAttributesClass exists. If not, the PV will enter the PENDING state because we do not want to impose ordering on object creation
470+
* Check if the VolumeAttributesClass exists. If not, the PV will enter the INPROGRESS state because we do not want to impose ordering on object creation
484471
* Check if this VolumeAttributesClass already has a protection finalizer
485472
* Add the finalizer to the VolumeAttributesClass if there is none
486473
2. PV has a VolumeAttributesClass and this PV is deleted
@@ -496,6 +483,7 @@ apiVersion: storage.k8s.io/v1alpha1
496483
kind: VolumeAttributesClass
497484
metadata:
498485
name: silver
486+
driverName: pd.csi.storage.gke.io
499487
parameters:
500488
iops: "500"
501489
throughput: "50MiB/s"
@@ -569,6 +557,7 @@ apiVersion: storage.k8s.io/v1alpha1
569557
kind: VolumeAttributesClass
570558
metadata:
571559
name: gold
560+
driverName: pd.csi.storage.gke.io
572561
parameters:
573562
iops: "1000"
574563
throughput: "100MiB/s"
@@ -593,7 +582,7 @@ spec:
593582

594583
ModifyVolume is only allowed on bound PVCs. Under the ModifyVolume call, it will pass in the mutable parameters and do the update operation based on the `VolumeAttributesClass` parameters.
595584

596-
![ModifyVolume Flow Diagram](./VolumeAttributesClass-ModifyVolume-Flow.png)
585+
![ModifyVolume Flow Diagram](./VolumeAttributesClass-ModifyVolume-Flow-v3.png)
597586

598587
### Implementation & Handling Failure
599588

0 commit comments

Comments
 (0)