mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
Merge pull request #128779 from alexey-gavrilov-flant/fix/kubectl-drain
kubectl: drain daemonSetFilter with other APIVersion
This commit is contained in:
@@ -171,6 +171,12 @@ func hasLocalStorage(pod corev1.Pod) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func isControllerRefDaemonSet(workloadRef *metav1.OwnerReference) bool {
|
||||
// find if workloadRef is daemonSet
|
||||
daemonSetAPIVersion, daemonSetKind := appsv1.SchemeGroupVersion.WithKind("DaemonSet").ToAPIVersionAndKind()
|
||||
return workloadRef.Kind == daemonSetKind && workloadRef.APIVersion == daemonSetAPIVersion
|
||||
}
|
||||
|
||||
func (d *Helper) daemonSetFilter(pod corev1.Pod) PodDeleteStatus {
|
||||
// Note that we return false in cases where the pod is DaemonSet managed,
|
||||
// regardless of flags.
|
||||
@@ -179,7 +185,7 @@ func (d *Helper) daemonSetFilter(pod corev1.Pod) PodDeleteStatus {
|
||||
// management resource - including DaemonSet - is not found).
|
||||
// Such pods will be deleted if --force is used.
|
||||
controllerRef := metav1.GetControllerOf(&pod)
|
||||
if controllerRef == nil || controllerRef.Kind != appsv1.SchemeGroupVersion.WithKind("DaemonSet").Kind {
|
||||
if controllerRef == nil || !isControllerRefDaemonSet(controllerRef) {
|
||||
return MakePodDeleteStatusOkay()
|
||||
}
|
||||
// Any finished pod can be removed.
|
||||
|
||||
Reference in New Issue
Block a user