[BuildMonitor] fix the snapshot running issue 97/152097/1
authorSungHun Hwang <sh0924.hwang@samsung.com>
Mon, 25 Sep 2017 05:24:03 +0000 (14:24 +0900)
committerSungHun Hwang <sh0924.hwang@samsung.com>
Mon, 25 Sep 2017 05:24:03 +0000 (14:24 +0900)
PROBLEM&REASON:
  snapshot status stays 'running' without any SR(Submit Request)

SOLUTION:
  add exception code to skip inserting the SR

Change-Id: I53ad35cb34fe856894836a3ad5f7cdf4a6297723
Signed-off-by: SungHun Hwang <sh0924.hwang@samsung.com>
job_buildmonitor.py

index 55169b6..a5df4e0 100644 (file)
@@ -665,6 +665,10 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot
         for each_sr_status_id in multi_sr_status_id:
             print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
 
+            if each_sr_status_id == 0:
+                print 'each_sr_status_id is zero!! skip updating the sr_stage\n'
+                break
+
             ### [POST_IMAGE] stage : update fail status for [post] image creation
             info_stage_id = POST_IMAGE
             query = "UPDATE sr_stage SET stage_start_time = %s, stage_end_time = %s, stage_status = %s " \
@@ -742,7 +746,7 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name):
         isFailed = 0
         for each_build_image_status in multi_build_image_status:
             #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status)
-            if each_build_image_status[0] == 'F':
+            if each_build_image_status and each_build_image_status[0] == 'F':
                 isFailed = 1
                 print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed)
 
@@ -774,7 +778,7 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name):
         isFailed = 0
         for each_build_image_status in multi_build_image_status:
             #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status)
-            if each_build_image_status[0] == 'F':
+            if each_build_image_status and each_build_image_status[0] == 'F':
                 isFailed = 1
                 print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed)
 
@@ -790,6 +794,10 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name):
             for each_sr_status_id in multi_sr_status_id:
                 print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
 
+                if each_sr_status_id == 0:
+                    print 'each_sr_status_id is zero!! skip updating the sr_stage\n'
+                    break
+
                 info_stage_id = POST_SNAP
                 query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \
                         "WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
@@ -1028,6 +1036,10 @@ def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name):
         for each_sr_status_id in multi_sr_status_id:
             print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
 
+            if each_sr_status_id == 0:
+                print 'each_sr_status_id is zero!! skip updating the sr_stage\n'
+                break
+
             ### [POST_SNAP] stage end : update 'S' status
             info_stage_id = POST_SNAP
             query = "UPDATE sr_stage SET stage_end_time = NOW(), stage_status = %s " \
@@ -1051,6 +1063,10 @@ def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name):
         for each_sr_status_id in multi_sr_status_id:
             print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
 
+            if each_sr_status_id == 0:
+                print 'each_sr_status_id is zero!! skip updating the sr_stage\n'
+                break
+
             ### [POST_SNAP] stage end : update 'F' status
             info_stage_id = POST_SNAP
             query = "UPDATE sr_stage SET stage_end_time = NOW(), stage_status = %s " \
@@ -1105,6 +1121,11 @@ def start_create_snapshot_for_sr_stage(project, bm_start_datetime):
     ### [POST_BUILD] end / [POST_SNAP/POST_IMAGE] start : [post] snapshot creation
     for each_sr_status_id in multi_sr_status_id:
         print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
+
+        if each_sr_status_id == 0:
+            print 'each_sr_status_id is zero!! skip updating the sr_stage\n'
+            break
+
         info_stage_id = POST_BUILD
         bm_end_datetime = datetime.now()
         query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \
@@ -1227,6 +1248,10 @@ def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name,
     for each_sr_status_id in multi_sr_status_id:
         print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
 
+        if each_sr_status_id == 0:
+            print 'each_sr_status_id is zero!! skip updating the sr_stage\n'
+            break
+
         ### [POST_SNAP] stage end : update 'S' status
         sr_stage_status = 'S'
         info_stage_id = POST_SNAP
@@ -1868,7 +1893,7 @@ def TRBS_end_create_image_for_sr_stage(bm_start_datetime, project):
         isFailed = 0
         for each_build_image_status in multi_build_image_status:
             #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status)
-            if each_build_image_status[0] == 'F':
+            if each_build_image_status and each_build_image_status[0] == 'F':
                 isFailed = 1
                 print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed)