Add an attempt to remove armada using force parameter
Sometimes the attempt to remove the armada pods get stuck due another starlingx resources. This commit added to the armada script an attempt to remove the pods when the previous attempts fails. Test Plan: PASS: AIO-DX stx-8 install PASS: upgrade stx-8 to master and observe if script 01 was executed with success during activate process. PASS: Edit script 01 making the normal attempts to remove the pod fails and check if the script successfully force the pod remove. Closes-Bug: 2092404 Change-Id: I28fa0fe4171a6e13bb24228b65caaccfdd7f2ae5 Signed-off-by: Edson Dias <edson.dias@windriver.com>
This commit is contained in:
parent
b6728eb607
commit
41d23b0685
@ -202,6 +202,28 @@ def is_armada_required():
|
||||
return False
|
||||
|
||||
|
||||
@test_k8s_health
|
||||
def force_delete_pods(pod_name):
|
||||
try:
|
||||
LOG.info(f"Trying to force the deletion of {pod_name}.")
|
||||
cmd = "kubectl delete pod %s --request-timeout=%s --timeout=%s -n %s \
|
||||
--grace-period=%s --force --kubeconfig %s" \
|
||||
% (pod_name,
|
||||
REQUEST_TIMEOUT_KUBECTL,
|
||||
TIMEOUT_KUBECTL,
|
||||
ARMADA_NS,
|
||||
GRACE_PERIOD_TIME,
|
||||
KUBERNETES_ADMIN_CONF)
|
||||
result, err = run_cmd(cmd)
|
||||
if 'force deleted' in result:
|
||||
return True
|
||||
elif err:
|
||||
raise Exception(err)
|
||||
except Exception as e:
|
||||
LOG.error(f"Failed to delete pod {pod_name} after forced attempt: {e}")
|
||||
return False
|
||||
|
||||
|
||||
@test_k8s_health
|
||||
def delete_armada_pods():
|
||||
"""
|
||||
@ -251,9 +273,9 @@ def delete_armada_pods():
|
||||
LOG.warning("Attempt %d to delete pod %s failed: %s"
|
||||
% (attempt, pod_name, e))
|
||||
if attempt == retries:
|
||||
LOG.error("Failed to delete pod %s after %d attempts."
|
||||
% (pod_name, retries))
|
||||
result = False
|
||||
LOG.warning("Failed to delete pod %s after %d attempts"
|
||||
% (pod_name, retries))
|
||||
result = force_delete_pods(pod_name)
|
||||
else:
|
||||
LOG.info("Retrying...")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user