From 7022a626607be602b2e3577cef5882933f42a516 Mon Sep 17 00:00:00 2001 From: Kirsten Laskoski Date: Sat, 29 Nov 2025 17:05:12 -0500 Subject: [PATCH] kubectl: remove context.TODO from daemonSetFilter Replace the context.TODO with getContext to prefer the Helper's context when it is set. This is consistent with the rest of the package now. Since contextual logging or timeouts may be included as part of the Helper's context, using context.TODO will silently ignore these features, producing unexpected behaviors. Signed-off-by: Kirsten Laskoski --- staging/src/k8s.io/kubectl/pkg/drain/filters.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/drain/filters.go b/staging/src/k8s.io/kubectl/pkg/drain/filters.go index 1edec35ffa3..6653e83244c 100644 --- a/staging/src/k8s.io/kubectl/pkg/drain/filters.go +++ b/staging/src/k8s.io/kubectl/pkg/drain/filters.go @@ -17,7 +17,6 @@ limitations under the License. package drain import ( - "context" "fmt" "strings" "time" @@ -193,7 +192,7 @@ func (d *Helper) daemonSetFilter(pod corev1.Pod) PodDeleteStatus { return MakePodDeleteStatusOkay() } - if _, err := d.Client.AppsV1().DaemonSets(pod.Namespace).Get(context.TODO(), controllerRef.Name, metav1.GetOptions{}); err != nil { + if _, err := d.Client.AppsV1().DaemonSets(pod.Namespace).Get(d.getContext(), controllerRef.Name, metav1.GetOptions{}); err != nil { // remove orphaned pods with a warning if --force is used if apierrors.IsNotFound(err) && d.Force { return MakePodDeleteStatusWithWarning(true, err.Error())