Fix issue
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
@@ -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):
