Skip to content

Commit

Permalink
update to match interlink v0.3.0-rc5
Browse files Browse the repository at this point in the history
  • Loading branch information
ttedeschi authored Jul 8, 2024
1 parent e083303 commit 55457f6
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,21 @@ def SubmitHandler():
print("Job was submitted with cluster id: ", out_jid)
handle_jid(out_jid, pod)

resp = {
"PodUID": [],
"PodJID": []
}

try:
with open(
InterLinkConfigInst["DataRootFolder"] +
pod["metadata"]["name"] + "-" + pod["metadata"]["uid"] + ".jid",
"r",
) as f:
f.read()
return "Job submitted successfully", 200
resp["PodUID"] = pod["metadata"]["uid"]
resp["PodJID"] = out_jid
return json.dumps(resp), 200
except Exception as e:
logging.error(f"Unable to read JID from file:{e}")
return "Something went wrong in job submission", 500
Expand Down Expand Up @@ -560,19 +567,25 @@ def StatusHandler():
# READ THE REQUEST #####################
logging.info("ARC Sidecar: received GetStatus call")
request_data_string = request.data.decode("utf-8")
req = json.loads(request_data_string)[0]
#print(req)
if req is None or not isinstance(req, dict):
print("Invalid status request body is: ", req)
req_list = json.loads(request_data_string)
if req_list is None or not isinstance(req_list, list):
logging.error("Invalid request data")
logging.error(f"STATUS REQUEST DATA IS THE FOLLOWING: {req_list}")
return "Invalid request data for getting status", 400
if isinstance(req_list, list):
if len(req_list) == 0:
logging.error("Invalid request data")
logging.error(f"STATUS REQUEST DATA IS THE FOLLOWING: {req_list}")
return "Invalid request data for getting status", 400
req = req_list[0]

# ELABORATE RESPONSE #################
resp = [
{
"name": [],
"uid": [],
"UID": [],
"namespace": [],
"JID": [],
"containers": []
}
]
Expand All @@ -588,7 +601,8 @@ def StatusHandler():
poduid = req["metadata"]["uid"]
resp[0]["name"] = podname
resp[0]["namespace"] = podnamespace
resp[0]["uid"] = poduid
resp[0]["UID"] = poduid
resp[0]["JID"] = jid_job
#print(f"arcstat {jid_job} --json")
process = os.popen(f"export BEARER_TOKEN=$(cat {token_path}) && arcstat {jid_job} --json")
preprocessed = process.read()
Expand Down

0 comments on commit 55457f6

Please sign in to comment.