Adds actual context to node drainer code

Signed-off-by: Sagar Muchhal <muchhals@vmware.com>

Kubernetes-commit: 2e01560fd0c1fc6eec607c5a01022384feda67d6
This commit is contained in:
Sagar Muchhal 2021-03-21 18:11:50 -07:00 committed by Kubernetes Publisher
parent b1f90b3f6c
commit 27325b0861
1 changed files with 4 additions and 4 deletions

View File

@ -151,7 +151,7 @@ func (d *Helper) DeletePod(pod corev1.Pod) error {
return err
}
}
return d.Client.CoreV1().Pods(pod.Namespace).Delete(context.TODO(), pod.Name, d.makeDeleteOptions())
return d.Client.CoreV1().Pods(pod.Namespace).Delete(d.getContext(), pod.Name, d.makeDeleteOptions())
}
// EvictPod will evict the give pod, or return an error if it couldn't
@ -176,7 +176,7 @@ func (d *Helper) EvictPod(pod corev1.Pod, policyGroupVersion string) error {
}
// Remember to change change the URL manipulation func when Eviction's version change
return d.Client.PolicyV1beta1().Evictions(eviction.Namespace).Evict(context.TODO(), eviction)
return d.Client.PolicyV1beta1().Evictions(eviction.Namespace).Evict(d.getContext(), eviction)
}
// GetPodsForDeletion receives resource info for a node, and returns those pods as PodDeleteList,
@ -189,7 +189,7 @@ func (d *Helper) GetPodsForDeletion(nodeName string) (*PodDeleteList, []error) {
return nil, []error{err}
}
podList, err := d.Client.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{
podList, err := d.Client.CoreV1().Pods(metav1.NamespaceAll).List(d.getContext(), metav1.ListOptions{
LabelSelector: labelSelector.String(),
FieldSelector: fields.SelectorFromSet(fields.Set{"spec.nodeName": nodeName}).String()})
if err != nil {
@ -239,7 +239,7 @@ func (d *Helper) DeleteOrEvictPods(pods []corev1.Pod) error {
// TODO(justinsb): unnecessary?
getPodFn := func(namespace, name string) (*corev1.Pod, error) {
return d.Client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
return d.Client.CoreV1().Pods(namespace).Get(d.getContext(), name, metav1.GetOptions{})
}
if !d.DisableEviction {