Skip to content

Commit 6fefe5b

Browse files
committed
Update field names
1 parent 267d78d commit 6fefe5b

File tree

1 file changed

+30
-31
lines changed
  • keps/sig-apps/1847-autoremove-statefulset-pvcs

1 file changed

+30
-31
lines changed

keps/sig-apps/1847-autoremove-statefulset-pvcs/README.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
- [Design Details](#design-details)
2020
- [Objects Associated with the StatefulSet](#objects-associated-with-the-statefulset)
2121
- [Volume delete policy for the StatefulSet created PVCs](#volume-delete-policy-for-the-statefulset-created-pvcs)
22-
- [<code>OnScaleDown</code> policy of <code>Delete</code>.](#-policy-of-)
23-
- [<code>OnSetDeletion</code> policy of <code>Delete</code>.](#-policy-of--1)
22+
- [<code>whenScaled</code> policy of <code>Delete</code>.](#-policy-of-)
23+
- [<code>whenDeleted</code> policy of <code>Delete</code>.](#-policy-of--1)
2424
- [Non-Cascading Deletion](#non-cascading-deletion)
25-
- [Mutating <code>PersistentVolumeClaimPolicy</code>](#mutating-)
25+
- [Mutating <code>PersistentVolumeClaimRetentionPolicy</code>](#mutating-)
2626
- [Cluster role change for statefulset controller](#cluster-role-change-for-statefulset-controller)
2727
- [Test Plan](#test-plan)
2828
- [Graduation Criteria](#graduation-criteria)
@@ -86,7 +86,7 @@ delete the PVC.
8686
### Non-Goals
8787

8888
This proposal does not plan to address how the underlying PVs are treated on PVC deletion.
89-
That functionality will continue to be governed by the ReclaimPolicy of the storage class.
89+
That functionality will continue to be governed by the reclaim policy of the storage class.
9090

9191
## Proposal
9292

@@ -102,10 +102,10 @@ delete the PVCs created by the controller from the StatefulSet's VolumeClaimTemp
102102

103103
The following changes are required:
104104

105-
1. Add `PersistentVolumeClaimPolicy` to the StatefulSet spec with the following fields.
106-
* `OnSetDeletion` - specifies if the VolumeClaimTemplate PVCs are deleted when
105+
1. Add `persistentVolumeClaimRetentionPolicy` to the StatefulSet spec with the following fields.
106+
* `whenDeleted` - specifies if the VolumeClaimTemplate PVCs are deleted when
107107
their StatefulSet is deleted.
108-
* `OnScaleDown` - specifies if VolumeClaimTemplate PVCs are deleted when
108+
* `whenScaled` - specifies if VolumeClaimTemplate PVCs are deleted when
109109
their corresponding pod is deleted on a StatefulSet scale-down, that is,
110110
when the number of pods in a StatefulSet is reduced via the Replicas field.
111111

@@ -122,7 +122,7 @@ The following changes are required:
122122

123123
#### Story 0
124124
The user is happy with legacy behavior of a stateful set. They leave all fields
125-
of `PersistentVolumeClaimPolicy` to `Retain`. Nothing traditional
125+
of `PersistentVolumeClaimRetentionPolicy` to `Retain`. Nothing traditional
126126
StatefulSet behavior changes neither on set deletion nor on scale-down.
127127

128128
#### Story 1
@@ -133,7 +133,7 @@ so that scale-up can leverage the existing volumes. When the application is fini
133133
volumes created by the StatefulSet are no longer needed and can be automatically
134134
reclaimed.
135135

136-
The user would set `PersistentVolumeClaimPolicy.OnSetDeletion` to `Delete, which
136+
The user would set `persistentVolumeClaimRetentionPolicy.whenDeleted` to `Delete, which
137137
would ensure that the PVCs created automatically during the StatefulSet
138138
activation is deleted once the StatefulSet is deleted.
139139

@@ -143,8 +143,8 @@ scale-down, because scaling events are rare, and volume data can be
143143
reconstructed, albeit slowly, during a scale up. However, it is necessary to
144144
bring down the StatefulSet temporarily by deleting it, and then bring it back up
145145
by reusing the volumes. This is accomplished by setting
146-
`PersistentVolumeClaimPolicy.OnScaleDown` to `Delete`, and leaving
147-
`PersistentVolumeClaimPolicy.OnSetDeletion` at `Retain`.
146+
`persistentVolumeClaimRetentionPolicy.whenScaled` to `Delete`, and leaving
147+
`persistentVolumeClaimRetentionPolicy.whenDeleted` at `Retain`.
148148

149149
#### Story 3
150150
User is very cost conscious, and can sustain slower scale-up speeds even after a
@@ -156,8 +156,8 @@ recreated, like a rolling update or node disruptions, the data on volumes is
156156
persisted. This is a key property that ephemeral storage, like emptyDir, cannot
157157
provide.
158158

159-
User would set the `PersistentVolumeClaimPolicy.OnScaleDown` as well as
160-
`PersistentVolumeClaimPolicy.OnSetDeletion` to `Delete`, ensuring PVCs are
159+
User would set the `persistentVolumeClaimRetentionPolicy.whenScaled` as well as
160+
`persistentVolumeClaimRetentionPolicy.whenDeleted` to `Delete`, ensuring PVCs are
161161
deleted when corresponding Pods are deleted. New Pods created during scale-up
162162
followed by a scale-down will wait for freshly created PVCs. PVCs are deleted as
163163
well when the set is deleted, reclaiming volumes as quickly as possible and
@@ -175,7 +175,7 @@ VolumeClaimTemplate it will be deleted according to the deletion policy.
175175
### Risks and Mitigations
176176

177177
Currently the PVCs created by StatefulSet are not deleted automatically. Using
178-
`OnScaleDown` or `OnSetDeletion` set to `Delete` would delete the PVCs
178+
`whenScaled` or `whenDeleted` set to `Delete` would delete the PVCs
179179
automatically. Since this involves persistent data being deleted, users should
180180
take appropriate care using this feature. Having the `Retain` behaviour as
181181
default will ensure that the PVCs remain intact by default and only a conscious
@@ -211,13 +211,13 @@ are affected.
211211

212212
### Volume delete policy for the StatefulSet created PVCs
213213

214-
A new field named `PersistentVolumeClaimPolicy` of the type
215-
`StatefulSetPersistentVolumeClaimPolicy` will be added to the StatefulSet. This
214+
A new field named `PersistentVolumeClaimRetentionPolicy` of the type
215+
`StatefulSetPersistentVolumeClaimRetentionPolicy` will be added to the StatefulSet. This
216216
will represent the user indication for which circumstances the associated PVCs
217217
can be automatically deleted or not, as described above. The default policy
218218
would be to retain PVCs in all cases.
219219

220-
The `PersistentVolumeClaimPolicy` object will be mutable. The deletion
220+
The `PersistentVolumeClaimRetentionPolicy` object will be mutable. The deletion
221221
mechanism will be based on reconciliation, so as long as the field is changed
222222
far from StatefulSet deletion or scale-down, the policy will work as
223223
expected. Mutability does introduce race conditions if it is changed while a
@@ -230,9 +230,9 @@ manually deleting PVCs. The latter case will result in lost data, but only in
230230
PVCs that were originally declared to have been deleted. Life does not always
231231
have an undo button.
232232

233-
#### `OnScaleDown` policy of `Delete`.
233+
#### `whenScaled` policy of `Delete`.
234234

235-
If `PersistentVolumeClaimPolicy.OnScaleDown` is set to `Delete`, the Pod will be
235+
If `persistentVolumeClaimRetentionPolicy.whenScaled` is set to `Delete`, the Pod will be
236236
set as the owner of the PVCs created from the `VolumeClaimTemplates` just before
237237
the scale-down is performed by the StatefulSet controller. When a Pod is
238238
deleted, the PVC owned by the Pod is also deleted.
@@ -247,17 +247,17 @@ the PVC was referred to by the deleted Pod and is in the process of getting
247247
deleted. The controller will skip the reconcile loop until PVC deletion finishes, avoiding
248248
a race condition.
249249

250-
#### `OnSetDeletion` policy of `Delete`.
250+
#### `whenDeleted` policy of `Delete`.
251251

252-
When `PersistentVolumeClaimPolicy.OnSetDeletion` is set to `Delete`, when a
252+
When `persistentVolumeClaimRetentionPolicy.whenDeleted` is set to `Delete`, when a
253253
VolumeClaimTemplate PVC is created, an owner reference in PVC will be added to
254254
point to the StatefulSet. When a scale-up or scale-down occurs, the PVC is
255255
unchanged. PVCs previously in use before scale-down will be used again when the
256256
scale-up occurs.
257257

258258
In the existing StatefulSet reconcile loop, the associated VolumeClaimTemplate
259259
PVCs will be checked to see if the ownerRef is correct according to the
260-
`PersistentVolumeClaimPolicy` and updated accordingly. This includes PVCs
260+
`persistentVolumeClaimRetentionPolicy` and updated accordingly. This includes PVCs
261261
that have been manually provisioned. It will be most consistent and easy
262262
to reason about if all VolumeClaimTemplate PVCs are treated uniformly rather
263263
than trying to guess at their provenance.
@@ -279,7 +279,7 @@ When StatefulSet is deleted without cascading, eg `kubectl delete --cascade=fals
279279
existing behavior is retained and no PVC will be deleted. Only the StatefulSet resource
280280
will be affected.
281281

282-
#### Mutating `PersistentVolumeClaimPolicy`
282+
#### Mutating `PersistentVolumeClaimRetentionPolicy`
283283

284284
Recall that as defined above, the PVCs associated with a StatefulSet are found
285285
by the StatefulSet volumeClaimTemplate static naming scheme. The Pods associated
@@ -308,7 +308,7 @@ In order to update the PVC ownerReference, the `buildControllerRoles` will be up
308308
1. Unit tests
309309

310310
1. e2e/integration tests
311-
- With `Delete` policies for `OnSetDeletion` and `OnScaleDown`
311+
- With `Delete` policies for `whenScaled` and `whenDeleted`
312312
1. Create 2 pod statefulset, scale to 1 pod, confirm PVC deleted
313313
1. Create 2 pod statefulset, add data to PVs, scale to 1 pod, scale back to 2, confirm PV empty.
314314
1. Create 2 pod statefulset, delete stateful set, confirm PVCs deleted.
@@ -317,7 +317,7 @@ In order to update the PVC ownerReference, the `buildControllerRoles` will be up
317317
1. Create 2 pod statefulset, add data to PVs, manually delete one pod, immediately scale down to one pod, confirm PVC is deleted.
318318
1. Create 2 pod statefulset, add data to PVs, manually delete one pod, immediately scale down to one pod, scale back to two pods, confirm PV is empty.
319319
1. Create 2 pod statefulset, add data to PVs, perform rolling confirm PVC don't get deleted and PV contents remain intact and useful in the updated pods.
320-
- With `Delete` policy for `OnSetDeletion` only
320+
- With `Delete` policy for `whenDeleted` only
321321
1. Create 2 pod statefulset, scale to 1 pod, confirm PVC still exists,
322322
1. Create 2 pod statefulset, add data to PVs, scale to 1 pod, scale back to 2, confirm PV has data (PVC not deleted).
323323
1. Create 2 pod statefulset, delete stateful set, confirm PVCs deleted
@@ -350,7 +350,7 @@ In order to update the PVC ownerReference, the `buildControllerRoles` will be up
350350
This features adds a new field to the StatefulSet. The default value for the new field
351351
maintains the existing behavior of StatefulSets.
352352

353-
On a downgrade, the `PersistentVolumeClaimPolicy` field will be hidden on
353+
On a downgrade, the `PersistentVolumeClaimRetentionPolicy` field will be hidden on
354354
any StatefulSets. The behavior in this case will be identical to mutating they
355355
policy field to `Retain`, as described above, including the edge cases
356356
introduced if this is done during a scale-down or StatefulSet deletion.
@@ -382,9 +382,8 @@ are not involved so there is no version skew between nodes and the control plane
382382
Yes. Disabling the feature gate will cause the new field to be ignored. If the feature
383383
gate is re-enabled, the new behavior will start working.
384384

385-
When the `PersistentVolumeClaimDeletePolicy` is set to
386-
`DeleteOnStatefulSetDeletion`, then VolumeClaimTemplate PVCs ownerRefs must be
387-
removed.
385+
When the `PersistentVolumeClaimRetentionPolicy` has `WhenDeleted` set to
386+
`Delete`, then VolumeClaimTemplate PVCs ownerRefs must be removed.
388387

389388
There are new corner cases here. For example, if a StatefulSet deletion is in
390389
process when the feature is disabled or enabled, the appropriate ownerRefs
@@ -394,8 +393,8 @@ are not involved so there is no version skew between nodes and the control plane
394393

395394
* **What happens if we reenable the feature if it was previously rolled back?**
396395
In the simple case of reenabling the feature without concurrent StatefulSet
397-
deletion or scale-down, nothing needs to be done when the deletion policy is
398-
`DeleteOnScaleDown`. On a policy of `DeleteOnStatefulSetDeletion`, the
396+
deletion or scale-down, nothing needs to be done when the deletion policy has
397+
`whenScaled` set to `Delete`. When the policy has `whenDeleted` set to `Delete`, the
399398
VolumeClaimTemplate PVC ownerRefs must be set to the StatefulSet.
400399

401400
As above, if there is a concurrent scale-down or StatefulSet deletion, more

0 commit comments

Comments
 (0)