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 <klaskosk@redhat.com>
This commit is contained in:
Kirsten Laskoski
2025-11-29 17:05:12 -05:00
parent 61c629cc57
commit 7022a62660

View File

@@ -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())