create_job function was not printing the current status of the job. Modified the create_job function to call read_namespaced_job_status in order to get the current job status
This commit is contained in:
Prabha 2021-04-18 16:14:24 +05:30 committed by GitHub
parent b313b5e74f
commit 7bb0851217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,8 @@ from os import path
import yaml
from time import sleep
from kubernetes import client, config
JOB_NAME = "pi"
@ -53,7 +55,16 @@ def create_job(api_instance, job):
api_response = api_instance.create_namespaced_job(
body=job,
namespace="default")
print("Job created. status='%s'" % str(api_response.status))
# Need to wait for a second for the job status to update
sleep(1)
print("Job created. status='%s'" % str(get_job_status(api_instance)))
def get_job_status(api_instance):
api_response = api_instance.read_namespaced_job_status(
name=JOB_NAME,
namespace="default")
return api_response.status
def update_job(api_instance, job):