Skip to content

Commit 3c2988d

Browse files
authored
Merge pull request #4375 from mattcary/oref
KEP-1847: ownerRef controller update
2 parents bf66604 + a381e9f commit 3c2988d

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

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

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,29 @@ are the only PVCs modified with an ownerRef. Other PVCs referenced by the Statef
234234
template are not affected by this behavior.
235235

236236
OwnerReferences are used to manage PVC deletion. All such references used for
237-
this feature will set the controller field to the StatefulSet. This will be used
238-
to distinguish references added by the controller from, for example,
239-
user-created owner references. When ownerRefs is removed, it is understood that
240-
only those ownerRefs whose controller field matches the StatefulSet in question
241-
are affected.
237+
this feature will set the controller field to the StatefulSet or Pod as
238+
appropriate. This will be used to distinguish references added by the controller
239+
from, for example, user-created owner references. When ownerRefs is removed, it
240+
is understood that only those ownerRefs whose controller field matches the
241+
StatefulSet or Pod in question are affected.
242+
243+
The controller flag will be set for these references. If there is already a
244+
different (non-StatefulSet) controller set for a PVC, an ownerRef will not be
245+
added. This will mean that the autodelete functionality will not be operative. An
246+
event will be created to reflect this.
247+
248+
To summarize,
249+
250+
**If the StatefulSet is a controller owner**,
251+
* the PVC lifecycle will be full managed by the StatefulSet controller
252+
* old owner references will be updated with `controller=false` to `controller=true`
253+
(see Upgrade / Downgrade Strategy, below).
254+
* remove itself as the owner and controller when the retain policy is specified in the StatefulSet.
255+
256+
**If someone else is the controller**,
257+
* the PVC lifecycle will not be touched by the StatefulSet controller. The PVC
258+
will stay when the delete policy is specified in the StatefulSet.
259+
* old StatefulSet owner references will be removed.
242260

243261
### Volume delete policy for the StatefulSet created PVCs
244262

@@ -394,10 +412,25 @@ This features adds a new field to the StatefulSet. The default value for the new
394412
maintains the existing behavior of StatefulSets.
395413

396414
On a downgrade, the `PersistentVolumeClaimRetentionPolicy` field will be hidden on
397-
any StatefulSets. The behavior in this case will be identical to mutating they
415+
any StatefulSets. The behavior in this case will be identical to mutating the
398416
policy field to `Retain`, as described above, including the edge cases
399417
introduced if this is done during a scale-down or StatefulSet deletion.
400418

419+
The initial beta version did not set the controller flag in the owner
420+
reference. This was fixed in later versions, so that the controller flag is
421+
set. The behavior is then as follows.
422+
423+
* If the StatefulSet or one of its Pods is a controller, owner references are
424+
updated as specified by the retention policy.
425+
* If the StatefulSet or one of its Pods is an owner but not a controller,
426+
* if there is no other controller, the StatefulSet or Pod owners will be set
427+
as controller (ie, they are assumed to be from the initial beta version and
428+
updated).
429+
* The controller will be updated as specified by the retention policy.
430+
* If there is another resource that is a controller,
431+
* any (non-controler) StatefulSet or Pod owner reference is removed.
432+
* The retention policy is ignored.
433+
401434
### Version Skew Strategy
402435
There are only kube-controller-manager changes involved (in addition to the
403436
apiserver changes for dealing with the new StatefulSet field). Node components
@@ -590,6 +623,7 @@ stateful set controller lives) should be examined and/or restarted.
590623
- 1.21, KEP created.
591624
- 1.23, alpha implementation.
592625
- 1.27, graduation to beta.
626+
- 1.31, fix controller references.
593627

594628
## Drawbacks
595629
The StatefulSet field update is required.

keps/sig-apps/1847-autoremove-statefulset-pvcs/kep.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ approvers:
2020

2121
stage: beta
2222

23-
latest-milestone: "v1.27"
23+
latest-milestone: "v1.31"
2424

2525
milestone:
2626
alpha: "v1.23"
2727
beta: "v1.27"
28-
stable: "v1.28"
28+
stable: "v1.32"
2929

3030
feature-gates:
3131
- name: StatefulSetAutoDeletePVC

0 commit comments

Comments
 (0)