def DrainWorkloadNodesFromOtherPods(
    workload: base.K8sWorkload, cordon: bool = True) -> None:
  """Drains a workload's nodes from non-workload pods.

  Args:
    workload (base.K8sWorkload): The workload for which nodes
        must be drained from pods that are not covered by the workload.
    cordon (bool): Optional. Whether or not to cordon the nodes before draining,
        to prevent pods from appearing on the nodes again as it will be marked
        as unschedulable. Defaults to True.
  """
  nodes = workload.GetCoveredNodes()
  if cordon:
    for node in nodes:
      node.Cordon()
  for node in nodes:
    node.Drain(lambda pod: not workload.IsCoveringPod(pod))
Drains a workload's nodes from non-workload pods.

Args:
workload (base.K8sWorkload): The workload for which nodes
must be drained from pods that are not covered by the workload.
cordon (bool): Optional. Whether or not to cordon the nodes before draining,
to prevent pods from appearing on the nodes again as it will be marked
as unschedulable. Defaults to True.
libcloudforensics/providers/kubernetes/mitigation.py