diff --git a/changelogs/fragments/295-fix-k8s-drain-variable-declaration.yaml b/changelogs/fragments/295-fix-k8s-drain-variable-declaration.yaml new file mode 100644 index 0000000000..c56d386360 --- /dev/null +++ b/changelogs/fragments/295-fix-k8s-drain-variable-declaration.yaml @@ -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). diff --git a/plugins/modules/k8s_drain.py b/plugins/modules/k8s_drain.py index dd4f96413b..abde846969 100644 --- a/plugins/modules/k8s_drain.py +++ b/plugins/modules/k8s_drain.py @@ -183,6 +183,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