From bd707cb8cb19c9e2fe2d08513dcaf1daeeba5832 Mon Sep 17 00:00:00 2001 From: SungHun Hwang Date: Mon, 27 Feb 2017 10:01:10 +0900 Subject: [PATCH] [BuildMonitor] revert add 'ORDER BY id desc LIMIT 1' revet add 'ORDER BY id desc LIMIT 1' patch this is not a root cause =========================================================================== add 'ORDER BY id desc(ending) LIMIT 1' when selecting the build_snapshot_id to prevent getting the wrong build_snapshot_id =========================================================================== Change-Id: I131c06b8e9a6c3eea92711ae7de5573110b49ec4 Signed-off-by: SungHun Hwang --- job_buildmonitor.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/job_buildmonitor.py b/job_buildmonitor.py index dc6a7af..79fb766 100644 --- a/job_buildmonitor.py +++ b/job_buildmonitor.py @@ -280,7 +280,7 @@ def package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, buildmonitor_db.do_query(query, query_data) # get build_snapshot_id for deleting build_snapshot_package & build_image - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (pre_build_project_id,) build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) @@ -387,7 +387,7 @@ def start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_d # % (__file__, pre_info_project_id, pre_build_project_id) ### to check duplicate build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (pre_build_project_id,) pre_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) ### for build_snapshot @@ -453,7 +453,7 @@ def create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arc # % (__file__, pre_info_project_id, pre_build_project_id) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (pre_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) @@ -570,7 +570,7 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime): ### build_image : update fail status for [pre] image creation # get pre_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (curr_build_project_id,) pre_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) @@ -619,7 +619,7 @@ def create_image_for_build_image(fields, bm_start_datetime, # % (__file__, bm_repository, bm_device_name, bm_status, bm_url) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s" query_data = (build_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) @@ -661,7 +661,7 @@ def end_create_image_for_sr_stage(bm_start_datetime, project): curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (curr_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get multi_build_image_status @@ -696,7 +696,7 @@ def end_create_image_for_sr_stage(bm_start_datetime, project): curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (curr_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get multi_build_image_status @@ -1011,7 +1011,7 @@ def create_snapshot_packages_for_post_build_snapshot_package(project, bm_repo, b build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) @@ -1273,7 +1273,7 @@ def TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, buildmonitor_db.do_query(query, query_data) # get build_snapshot_id for deleting build_snapshot_package & build_image - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (trbs_build_project_id,) build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) @@ -1380,7 +1380,7 @@ def TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_st # % (__file__, pre_info_project_id, trbs_build_project_id) ### to check duplicate build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (trbs_build_project_id,) trbs_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) @@ -1447,7 +1447,7 @@ def TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, b # % (__file__, trbs_info_project_id, trbs_build_project_id) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (trbs_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) @@ -1564,7 +1564,7 @@ def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime): ### build_image : update fail status for [trbs] image creation # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (curr_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) @@ -1605,7 +1605,7 @@ def TRBS_end_create_image_for_sr_stage(bm_start_datetime, project): curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s ORDER BY id desc LIMIT 1" + query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (curr_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get multi_build_image_status -- 2.7.4