Skip to content

Commit 88eff69

Browse files
committed
Address comments
1 parent c88f491 commit 88eff69

File tree

1 file changed

+23
-21
lines changed
  • keps/sig-api-machinery/5080-ordered-namespace-deletion

1 file changed

+23
-21
lines changed

keps/sig-api-machinery/5080-ordered-namespace-deletion/README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
- [User Stories (Optional)](#user-stories-optional)
1111
- [Story 1 - Pod VS NetworkPolicy](#story-1---pod-vs-networkpolicy)
1212
- [Story 2 - having finalizer conflicts with deletion order](#story-2---having-finalizer-conflicts-with-deletion-order)
13-
- [Story 2 - having ownerReference conflicts with deletion order](#story-2---having-ownerreference-conflicts-with-deletion-order)
1413
- [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional)
14+
- [Having ownerReference conflicts with deletion order](#having-ownerreference-conflicts-with-deletion-order)
1515
- [Risks and Mitigations](#risks-and-mitigations)
1616
- [Dependency cycle](#dependency-cycle)
1717
- [Instance from same resources want different deletion order](#instance-from-same-resources-want-different-deletion-order)
@@ -106,17 +106,15 @@ providing a solid foundation for managing resource cleanup in complex environmen
106106

107107
### Goals
108108

109-
1. Introduce an Opinionated Deletion Order: Implement a mechanism while namespace deletion to prioritize the deletion of certain resource types before others based on logical dependencies and security considerations (e.g., Pods deleted before NetworkPolicies).
109+
1. Introduce an Opinionated Deletion Order: Implement a mechanism while namespace deletion to prioritize the deletion of certain resource types before others based on logical dependencies and security considerations (e.g., Pods deleted before NetworkPolicies).2
110110

111-
2. Enhance Security During Namespace Deletion: Ensure that critical security resources (e.g., NetworkPolicies, RoleBindings) remain in place until all their dependent resources are safely deleted, thereby eliminating windows of vulnerability.
111+
2. Maintain Predictability and Consistency: Provide a more deterministic deletion process to improve user confidence and debugging during namespace cleanup.
112112

113-
3. Maintain Predictability and Consistency: Provide a more deterministic deletion process to improve user confidence and debugging during namespace cleanup.
113+
3. Integrate with Existing Kubernetes Concepts: Build on the namespace deletion’s current architecture without introducing breaking changes to existing APIs or workflows.
114114

115-
4. Integrate with Existing Kubernetes Concepts: Build on the namespace deletion’s current architecture without introducing breaking changes to existing APIs or workflows.
115+
4. Be safe - don’t introduce unresolvable deadlocks.
116116

117-
5. Be safe - don’t introduce unresolvable deadlocks.
118-
119-
6. Make the most common dependency - workloads and the policies that govern them - safe by default for all types of policies, including CRDs, unless specifically opted out.
117+
5. Make the most common dependency - workloads and the policies that govern them - safe by default for all types of policies, including CRDs, unless specifically opted out.
120118

121119

122120
### Non-Goals
@@ -195,21 +193,25 @@ avoid the above security concern.
195193

196194
#### Story 2 - having finalizer conflicts with deletion order
197195

198-
E.g. the NetworkPolicy deletion priority would be set lower than the pod and we could expect the Pod be deleted
196+
E.g. the NetworkPolicy deletion order would be set lower than the pod and we could expect the Pod be deleted
199197
before NetworkPolicy. However, if even one pod has a finalizer which is waiting for network policies (which is opaque to Kubernetes),
200198
it will cause dependency loops and block the deletion process.
201199

202200
Refer to the section `Handling Cyclic Dependencies`.
203201

204-
#### Story 2 - having ownerReference conflicts with deletion order
202+
### Notes/Constraints/Caveats (Optional)
205203

206-
When deciding the deletion priority for resources, it should take ownerReference into consideration.
207-
E.g. the deployment VS pod. However, it should not matter much in terms of namespace deletion.
208-
Namespace deletion specifically uses `metav1.DeletePropagationBackground` and all resources would be deleted and the ownerReference
209-
dependencies would be handled by the garbage collection.
204+
#### Having ownerReference conflicts with deletion order
210205

206+
When deciding the deletion priority for resources, it should take ownerReference into consideration.
207+
E.g. the deployment VS pod. However, it should not matter much in terms of namespace deletion.
208+
Namespace deletion specifically uses `metav1.DeletePropagationBackground` and all resources would be deleted and the ownerReference
209+
dependencies would be handled by the garbage collection.
211210

212-
### Notes/Constraints/Caveats (Optional)
211+
In Kubernetes, `ownerReferences` define a parent-child relationship where child resources are automatically deleted when the parent is removed.
212+
This is mostly handled by garbage collection. While namespace deletion, the `ownerReferences` is not part of the consideration and
213+
`NamespaceDeletionOrder` group will be honored while deleting resources as what it is currently. The garbage collector controller will make sure
214+
no child resources still existing after the parent resource deleted.
213215

214216

215217
### Risks and Mitigations
@@ -226,7 +228,7 @@ When a lack of progress detected(maybe caused by the dependency cycle described
226228

227229
- Return error after retry.
228230
- Pros: Make sure the security concern being addressed by always honor the deletion order
229-
- Cons: Could cause surprising behavior or break the existing user
231+
- Cons: Block namespace deletion if dependency cycle exists.
230232

231233
Mitigation: A proper fallback mechanism would be introduced to make sure the namespace deletion process would not be
232234
hanging forever because of potential dependency cycle.
@@ -307,18 +309,18 @@ In this case, the finalizers set would conflict with the `NamespaceDeletionOrder
307309

308310
To address this, the system will:
309311

310-
- Attempt to honor the DeletionOrderPriority for resource deletion.
312+
- Attempt to honor the `NamespaceDeletionOrder` for resource deletion.
311313

312314
- Monitor the deletion process for each `NamespaceDeletionOrder`. If the process hangs beyond a predefined timeout (e.g., 5 minutes),
313315
it will detect the stall and trigger the deletion attempt for the next `NamespaceDeletionOrder` group.
314316

315-
- If the resources from the next `NamespaceDeletionOrder` group are deleted successfully, retry with the ordered namespace deletion mechanism. If the process hangs again, wait for a predefined timeout and retry.
317+
- After moving on to the next NamespaceDeletionOrder group, the system will attempt to delete all resources under this group. At this stage, deletion is considered successful only when all resources from the current and previous groups have been fully removed.
316318

317-
- If the retry fails over a certain number or the process hangs for too long(an overall timeout), it falls into the fallback mechanism.
319+
- If the deletion of all resources from previous groups is not completed within the timeout period, the system will proceed to the next NamespaceDeletionOrder group, deleting those resources while waiting for any remaining resources from previous groups to be cleaned up.
318320

319-
- The fallback mechanism will ignore the `NamespaceDeletionOrder` and proceed with the existing unordered deletion process.
321+
- After looping through all NamespaceDeletionOrder groups, if there is still process blocking resources from being deleted, the system will behave same as the current mechanism.
320322

321-
By introducing a timeout and fallback, the system ensures that cyclic dependencies do not block namespace deletion indefinitely while still striving for an ordered deletion whenever possible.
323+
By introducing a controlled timeout mechanism, the system ensures that cyclic dependencies do not block namespace deletion indefinitely while still striving for an ordered deletion whenever possible.
322324

323325

324326
### Configure DeletionOrderPriority For CRD

0 commit comments

Comments
 (0)