aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Williams <neil.williams@linaro.org>2018-07-31 09:22:07 +0100
committerRemi Duraffort <remi.duraffort@linaro.org>2018-08-02 05:02:01 +0000
commitd9196acd269b91fae14e9fffcc49425c4908aedc (patch)
treec204668ca81e12f9c7efdf66e07341934d6d7883
parent55c52bb6d17bd779b15be5f87fa8d230249d8a52 (diff)
LAVA-1397 - fix crash in callback data
Fix logical error for test jobs which have not started and therefore have no job.output_dir into which to try to write the job_data.gz Change-Id: I8552a5a9ec7e18e41b10a80573ec69f825fad67a
-rw-r--r--lava_scheduler_app/models.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/lava_scheduler_app/models.py b/lava_scheduler_app/models.py
index 9070f9508..f1f587f2b 100644
--- a/lava_scheduler_app/models.py
+++ b/lava_scheduler_app/models.py
@@ -2310,9 +2310,13 @@ class NotificationCallback(models.Model):
token=self.token, output=output, results=results)
# store callback_data for later retrieval & triage
job_data_file = os.path.join(self.notification.test_job.output_dir, 'job_data.gz')
- if callback_data and not os.path.exists(job_data_file):
- with gzip.open(job_data_file, 'wb') as output:
- output.write(simplejson.dumps(callback_data).encode('utf-8'))
+ if callback_data:
+ # allow for jobs cancelled in submitted state
+ utils.mkdir(self.notification.test_job.output_dir)
+ # only write the file once
+ if not os.path.exists(job_data_file):
+ with gzip.open(job_data_file, 'wb') as output:
+ output.write(simplejson.dumps(callback_data).encode('utf-8'))
headers = {}
if callback_data: