You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Please refer sig-storage-lib-external-provisioner/controller/controller.go for the full code.
152
152
```
153
153
154
-
The fix applies to both csi driver volumes and in-tree plugin volumes.
154
+
The fix applies to both csi driver volumes and in-tree plugin volumes each either statically or dynamically provisioned.
155
155
156
156
The main approach in fixing the issue for csi driver volumes involves using an existing finalizer already implemented in sig-storage-lib-external-provisioner. It is `external-provisioner.volume.kubernetes.io/finalizer` which is added on the Persistent Volume. Currently, it is applied only during provisioning if the feature is enabled. The proposal is to not only add this finalizer to newly provisioned PVs, but also to extend the library to add the finalizer to existing PVs. Adding the finalizer prevents the PV from being removed from the API server. The finalizer will be removed only after the physical volume on the storage system is deleted.
157
157
@@ -160,13 +160,18 @@ The main approach in fixing the issue for in-tree volumes involves introducing a
160
160
When the PVC is deleted, the PV is moved into `Released` state and following checks are made:
161
161
162
162
1. In-Tree Volumes:
163
-
`DeletionTimestamp` checks can be ignored, instead volume being in a `Released` state is sufficient criteria. The existing `DeletionTimestamp` check incorrectly assumes that the PV cannot be deleted prior to deleting the PVC. On deleting a PV, a `DeletionTimestamp` is set on the PV, when the PVC is deleted, an explicit sync on the PV is triggered, the existing `DeletionTimestamp` check assumes that the volume is already under deletion and skips calling the plugin to delete the volume from underlying storage.
163
+
`DeletionTimestamp` checks can be ignored, instead volume being in a `Released` state is sufficient criteria. The existing `DeletionTimestamp` check incorrectly assumes that the PV cannot be deleted prior to deleting the PVC. On deleting a PV, a `DeletionTimestamp` is set on the PV, when the PVC is deleted, an explicit sync on the PV is triggered, the existing `DeletionTimestamp` check assumes that the volume is already under deletion and skips calling the plugin to delete the volume from underlying storage.
164
164
165
165
2. CSI driver
166
166
167
167
If when processing the PV update it is observed that it has `external-provisioner.volume.kubernetes.io/finalizer` finalizer and
168
168
`DeletionTimestamp` set, then the volume deletion request is forwarded to the driver, provided other pre-defined conditions are met.
169
169
170
+
When a PV with `Delete` reclaim policy is not associated with a PVC:
171
+
172
+
Under the event that the PV is not associated with a PVC, either finalizers `kubernetes.io/pv-controller` or `external-provisioner.volume.kubernetes.io/finalizer` are not added to the PV.
173
+
If such a PV is deleted the reclaim workflow is not executed, this is the current behavior and will be retained.
174
+
170
175
### Risks and Mitigations
171
176
172
177
The primary risk is volume deletion to a user that expect the current behavior, i.e, they do not expect the volume to be
@@ -197,6 +202,10 @@ Once the volume is deleted from the backend, the finalizer can be removed. This
197
202
198
203
Note: This feature should work with CSI Migration disabled or enabled.
199
204
205
+
Statically provisioned volumes would behave the same as dynamically provisioned volumes except in cases where the PV is not associated with a PVC, in such cases finalizer `external-provisioner.volume.kubernetes.io/finalizer` is not added.
206
+
207
+
If at any point a statically provisioned PV is `Bound` to a PVC, then the finalizer `external-provisioner.volume.kubernetes.io/finalizer` gets added by the external-provisioner.
208
+
200
209
### In-Tree Plugin volumes
201
210
202
211
A new finalizer `kubernetes.io/pv-controller` will be introduced. The finalizer will be added to newly created in-tree volumes as well as existing in-tree volumes. The finalizer will only be removed after the plugin successfully deletes the in-tree volume.
@@ -248,6 +257,11 @@ The pv-controller is also expected to add the finalizer to all existing in-tree
248
257
249
258
The pv-controller would also be responsible to add or remove the finalizer based on CSI Migration being disabled or enabled respectively.
250
259
260
+
261
+
Statically provisioned volumes would behave the same as dynamically provisioned volumes except in cases where the PV is not associated with a PVC, in such cases finalizer `kubernetes.io/pv-controller` is not added.
262
+
263
+
If at any point a statically provisioned PV is `Bound` to a PVC, then the finalizer `kubernetes.io/pv-controller` gets added by the pv-controller.
264
+
251
265
### Test Plan
252
266
253
267
#### E2E tests
@@ -268,23 +282,16 @@ An e2e test to exercise deletion of PV prior to deletion of PVC for a `Bound` PV
268
282
* Deployed in production and have gone through at least one K8s upgrade.
269
283
270
284
### Upgrade / Downgrade Strategy
271
-
* Upgrade from old Kubernetes(1.22) to new Kubernetes(1.23) with `HonorPVReclaimPolicy` flag enabled
285
+
286
+
* Upgrade from old Kubernetes(1.25) to new Kubernetes(1.26) with `HonorPVReclaimPolicy` flag enabled
272
287
273
288
In the above scenario, the upgrade will cause change in default behavior as described in the current KEP. Additionally,
274
289
if there are PVs that have a valid associated PVC and deletion timestamp set, then a finalizer is added to the PV.
275
290
276
-
* Downgrade from new Kubernetes(1.23) to old Kubernetes(1.22).
291
+
* Downgrade from new Kubernetes(1.26) to old Kubernetes(1.25).
277
292
278
293
In this case, there may be PVs with the deletion finalizer that the older Kubernetes does not remove. Such PVs will be in the API server forever unless if the user manually removes them.
279
294
280
-
* Upgrade from old Kubernetes(1.23) to new Kubernetes(1.24) with `HonorPVReclaimPolicy` flag enabled
281
-
282
-
On Kubernetes(1.23) with `HonorPVReclaimPolicy` flag enabled, in-tree plugin volumes still exhibited the issue described in the kep. On upgrading to Kubernetes(1.24) with `HonorPVReclaimPolicy` flag enabled, the in-tree plugin volumes will exhibit the new behavior described in this kep.
283
-
284
-
* Downgrade from new Kubernetes(1.24) to old Kubernetes(1.23).
285
-
286
-
In this case, the in-tree plugin volume PVs will have the newly introduced finalizer, such PVs cannot be removed from the API server unless the user manually removes the finalizer.
287
-
288
295
### Version Skew Strategy
289
296
The fix is part of `kube-controller-manager` and `external-provisioner`.
290
297
@@ -382,8 +389,7 @@ No.
382
389
383
390
## Implementation History
384
391
385
-
1.23: Alpha
386
-
1.24: Beta
392
+
1.26: Alpha
387
393
388
394
## Drawbacks
389
395
None. The current behavior could be considered as a drawback, the KEP presents the fix to the drawback. The current
0 commit comments