From 5626029894d57d45eac56c48bad4f3c94dfc45a9 Mon Sep 17 00:00:00 2001 From: Ignacio Heredia Date: Wed, 20 Nov 2024 15:47:41 +0100 Subject: [PATCH] fix: more accurate deployment status --- ai4papi/nomad/common.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ai4papi/nomad/common.py b/ai4papi/nomad/common.py index 38dd515..87e8d65 100644 --- a/ai4papi/nomad/common.py +++ b/ai4papi/nomad/common.py @@ -212,13 +212,13 @@ def get_deployment( info['datacenter'] = Nomad.node.get_node(a['NodeID'])['Datacenter'] # Replace Nomad status with a more user-friendly status - if a['ClientStatus'] == 'pending': - info['status'] = 'starting' - elif a['ClientStatus'] == 'unknown': - info['status'] = 'down' - else: - # This status can be for example: "complete", "failed" - info['status'] = a['ClientStatus'] + # Final list includes: starting, down, running, complete, failed, ... + status = a['TaskStates']['main']['State'] # more relevant than a['ClientStatus'] + status_map = { # nomad: papi + 'pending': 'starting', + 'unknown': 'down', + } + info['status'] = status_map.get(status, status) # if not mapped, then return original status # Add error messages if needed if info['status'] == 'failed':