Fix k8s_drain failing when pod has local storage (#295)

Fix k8s_drain failing when pod has local storage

SUMMARY

The module fails to define the pod_names variable before using it for
pods with local storage.

Fixes #292
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_drain
ADDITIONAL INFORMATION

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: None <None>
Reviewed-by: None <None>
This commit is contained in:
Mike Graves
2021-11-30 04:07:08 -05:00
committed by GitHub
parent a62c42782f
commit ef46c352d0
2 changed files with 4 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
---
bugfixes:
- k8s_drain - fix error caused by accessing an undefined variable when pods have local storage (https://github.com/ansible-collections/kubernetes.core/issues/292).

View File

@@ -197,6 +197,7 @@ def filter_pods(pods, force, ignore_daemonset):
# local storage
if localStorage:
pod_names = ",".join([pod[0] + "/" + pod[1] for pod in localStorage])
errors.append("cannot delete Pods with local storage: {0}.".format(pod_names))
# DaemonSet managed Pods