Skip to content

Commit

Permalink
Fix k8s_drain failing when pod has local storage (ansible-collections…
Browse files Browse the repository at this point in the history
…#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 ansible-collections#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>
(cherry picked from commit ef46c35)
  • Loading branch information
gravesm committed Jan 13, 2022
1 parent d8538ff commit e0e6e56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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).
1 change: 1 addition & 0 deletions plugins/modules/k8s_drain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e0e6e56

Please sign in to comment.