mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #100439 from srm09/add-context-to-drainer
Adds actual context to node drainer code
This commit is contained in:
commit
710865511e
@ -151,7 +151,7 @@ func (d *Helper) DeletePod(pod corev1.Pod) error {
|
|||||||
return err
|
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
|
// 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
|
// 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,
|
// 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}
|
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(),
|
LabelSelector: labelSelector.String(),
|
||||||
FieldSelector: fields.SelectorFromSet(fields.Set{"spec.nodeName": nodeName}).String()})
|
FieldSelector: fields.SelectorFromSet(fields.Set{"spec.nodeName": nodeName}).String()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -239,7 +239,7 @@ func (d *Helper) DeleteOrEvictPods(pods []corev1.Pod) error {
|
|||||||
|
|
||||||
// TODO(justinsb): unnecessary?
|
// TODO(justinsb): unnecessary?
|
||||||
getPodFn := func(namespace, name string) (*corev1.Pod, error) {
|
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 {
|
if !d.DisableEviction {
|
||||||
|
Loading…
Reference in New Issue
Block a user