mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-27 05:43:02 +00:00
Fix k8s_drain runs into timeout with pods from stateful sets. (#793)
SUMMARY Fixes #792 . The function wait_for_pod_deletion in k8s_drain never checks on which node a pod is actually running: try: response = self._api_instance.read_namespaced_pod( namespace=pod[0], name=pod[1] ) if not response: pod = None time.sleep(wait_sleep) This means that if a pod is successfully evicted and restarted with the same name on a new node, k8s_drain does not notice and thinks that the original pod is still running. This is the case for pods which are part of a stateful set. ISSUE TYPE Bugfix Pull Request COMPONENT NAME k8s_drain Reviewed-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- k8s_drain - Fix k8s_drain runs into a timeout when evicting a pod which is part of a stateful set (https://github.com/ansible-collections/kubernetes.core/issues/792).
|
||||||
@@ -77,7 +77,6 @@ def write_temp_kubeconfig(server, validate_certs=True, ca_cert=None, kubeconfig=
|
|||||||
|
|
||||||
|
|
||||||
class AnsibleHelmModule(object):
|
class AnsibleHelmModule(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
An Ansible module class for Kubernetes.core helm modules
|
An Ansible module class for Kubernetes.core helm modules
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -299,7 +299,9 @@ class K8sDrainAnsible(object):
|
|||||||
response = self._api_instance.read_namespaced_pod(
|
response = self._api_instance.read_namespaced_pod(
|
||||||
namespace=pod[0], name=pod[1]
|
namespace=pod[0], name=pod[1]
|
||||||
)
|
)
|
||||||
if not response:
|
if not response or response.spec.node_name != self._module.params.get(
|
||||||
|
"name"
|
||||||
|
):
|
||||||
pod = None
|
pod = None
|
||||||
del pods[-1]
|
del pods[-1]
|
||||||
time.sleep(wait_sleep)
|
time.sleep(wait_sleep)
|
||||||
|
|||||||
Reference in New Issue
Block a user