Skip to content

Commit 7bb0851

Browse files
authored
Fix issue #1395
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
1 parent b313b5e commit 7bb0851

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

examples/job_crud.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import yaml
2222

23+
from time import sleep
24+
2325
from kubernetes import client, config
2426

2527
JOB_NAME = "pi"
@@ -53,7 +55,16 @@ def create_job(api_instance, job):
5355
api_response = api_instance.create_namespaced_job(
5456
body=job,
5557
namespace="default")
56-
print("Job created. status='%s'" % str(api_response.status))
58+
# Need to wait for a second for the job status to update
59+
sleep(1)
60+
print("Job created. status='%s'" % str(get_job_status(api_instance)))
61+
62+
63+
def get_job_status(api_instance):
64+
api_response = api_instance.read_namespaced_job_status(
65+
name=JOB_NAME,
66+
namespace="default")
67+
return api_response.status
5768

5869

5970
def update_job(api_instance, job):

0 commit comments

Comments
 (0)