fix: set `replicated` to true if controller ref is set to `true`
- forgot to add this in the last commit Signed-off-by: vadasambar <surajrbanakar@gmail.com>
This commit is contained in:
parent
144a64a402
commit
f8f458295d
|
@ -22,7 +22,6 @@ import (
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
policyv1 "k8s.io/api/policy/v1"
|
policyv1 "k8s.io/api/policy/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes"
|
kube_util "k8s.io/autoscaler/cluster-autoscaler/utils/kubernetes"
|
||||||
|
@ -106,35 +105,16 @@ func GetPodsForDeletionOnNodeDrain(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
isDaemonSetPod := false
|
|
||||||
replicated := false
|
replicated := false
|
||||||
safeToEvict := hasSafeToEvictAnnotation(pod)
|
safeToEvict := hasSafeToEvictAnnotation(pod)
|
||||||
terminal := isPodTerminal(pod)
|
terminal := isPodTerminal(pod)
|
||||||
|
|
||||||
controllerRef := ControllerRef(pod)
|
controllerRef := ControllerRef(pod)
|
||||||
refKind := ""
|
|
||||||
if controllerRef != nil {
|
if controllerRef != nil {
|
||||||
refKind = controllerRef.Kind
|
replicated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, owner controller must be in the same namespace as the pod
|
|
||||||
// so OwnerReference doesn't have its own Namespace field
|
|
||||||
controllerNamespace := pod.Namespace
|
|
||||||
|
|
||||||
if pod_util.IsDaemonSetPod(pod) {
|
if pod_util.IsDaemonSetPod(pod) {
|
||||||
isDaemonSetPod = true
|
|
||||||
// don't have listener for other DaemonSet kind
|
|
||||||
// TODO: we should use a generic client for checking the reference.
|
|
||||||
if checkReferences && refKind == "DaemonSet" {
|
|
||||||
_, err := listers.DaemonSetLister().DaemonSets(controllerNamespace).Get(controllerRef.Name)
|
|
||||||
if apierrors.IsNotFound(err) {
|
|
||||||
return []*apiv1.Pod{}, []*apiv1.Pod{}, &BlockingPod{Pod: pod, Reason: ControllerNotFound}, fmt.Errorf("daemonset for %s/%s is not present, err: %v", pod.Namespace, pod.Name, err)
|
|
||||||
} else if err != nil {
|
|
||||||
return []*apiv1.Pod{}, []*apiv1.Pod{}, &BlockingPod{Pod: pod, Reason: UnexpectedError}, fmt.Errorf("error when trying to get daemonset for %s/%s , err: %v", pod.Namespace, pod.Name, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if isDaemonSetPod {
|
|
||||||
daemonSetPods = append(daemonSetPods, pod)
|
daemonSetPods = append(daemonSetPods, pod)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue