-
Notifications
You must be signed in to change notification settings - Fork 175
Add support for a new Pod Deletion Policy #4162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1781,10 +1781,11 @@ var ( | |
| type NodeDownPodDeletionPolicy string | ||
|
|
||
| const ( | ||
| NodeDownPodDeletionPolicyDoNothing = NodeDownPodDeletionPolicy("do-nothing") // Kubernetes default behavior | ||
| NodeDownPodDeletionPolicyDeleteStatefulSetPod = NodeDownPodDeletionPolicy("delete-statefulset-pod") | ||
| NodeDownPodDeletionPolicyDeleteDeploymentPod = NodeDownPodDeletionPolicy("delete-deployment-pod") | ||
| NodeDownPodDeletionPolicyDeleteBothStatefulsetAndDeploymentPod = NodeDownPodDeletionPolicy("delete-both-statefulset-and-deployment-pod") | ||
| NodeDownPodDeletionPolicyDoNothing = NodeDownPodDeletionPolicy("do-nothing") // Kubernetes default behavior | ||
| NodeDownPodDeletionPolicyDeleteStatefulSetPod = NodeDownPodDeletionPolicy("delete-statefulset-pod") | ||
| NodeDownPodDeletionPolicyDeleteDeploymentPod = NodeDownPodDeletionPolicy("delete-deployment-pod") | ||
| NodeDownPodDeletionPolicyDeleteBothStatefulsetAndDeploymentPod = NodeDownPodDeletionPolicy("delete-both-statefulset-and-deployment-pod") | ||
| NodeDownPodDeletionPolicyDeleteBothStatefulsetAndDeploymentPodAndAnnotatedPods = NodeDownPodDeletionPolicy("delete-both-statefulset-and-deployment-pod-and-annotated-pods") | ||
|
Comment on lines
+1787
to
+1788
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we retain one? Given that the new policy is essentially a superset of the current one, Additionally, we might consider implementing this resilience for all pods managed by controllers, rather than exclusively for SS and DS workloads, as we currently do for the setting /controller/kubernetes_pod_controller.go#L634-L636 if ownerRef := metav1.GetControllerOf(pod); ownerRef == nil || kc.isControllerInBlacklist(ownerRef) {
return nil
}
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree with the proposal!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've checked, and both our CNPG Operator pods and our Strimzi PodSet pods both have that ownerReference correctly set, which makes me believe that using that GetControllerOf function would work properly. Does that mean it's no longer useful to have the annotation for pods for which the ownerReference is not explicitly set, and only support properly owned pods? I agree, but it's a bit of a reduction in functionality.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this code change be OK? SettingNameEnableDeletionOfControllerOwnedPods = SettingName("enable-deletion-of-controller-owned-pods")// Check if we are allowed to delete the pod regardless of its type because it's owned by a Controller.
deletePodsOwnedByControllers, err := kc.ds.GetSettingAsBool(types.SettingNameEnableDeletionOfControllerOwnedPods)
if err != nil {
return err
}
// Check if the pod has an owning Controller reference
shouldDeleteBecauseOwnedByController := false
if deletePodsOwnedByControllers {
if ownerRef := metav1.GetControllerOf(pod); ownerRef != nil && !kc.isControllerInBlacklist(ownerRef) {
shouldDeleteBecauseOwnedByController = true
}
}
// Check if the pod would be delted by a Policy
shouldDeleteBecauseOfPolicy := (deletionPolicy == types.NodeDownPodDeletionPolicyDeleteStatefulSetPod && isOwnedByStatefulSet(pod)) ||
(deletionPolicy == types.NodeDownPodDeletionPolicyDeleteDeploymentPod && isOwnedByDeployment(pod)) ||
(deletionPolicy == types.NodeDownPodDeletionPolicyDeleteBothStatefulsetAndDeploymentPod && (isOwnedByStatefulSet(pod) || isOwnedByDeployment(pod))) ||
(deletionPolicy == types.NodeDownPodDeletionPolicyDeleteBothStatefulsetAndDeploymentPodAndAnnotatedPods && (isOwnedByStatefulSet(pod) || isOwnedByDeployment(pod) || isAnnotatedWithDeletionAnnotation(pod)))
// If both checks fail to decide to delete the pod, don't do anything.
if !shouldDeleteBecauseOwnedByController && !shouldDeleteBecauseOfPolicy {
return nil
} |
||
| ) | ||
|
|
||
| type NodeDrainPolicy string | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.