From 4c2b56d5db10bcdbe812c632f81b861d8fa1db3b Mon Sep 17 00:00:00 2001 From: hyokeun Date: Wed, 23 Aug 2017 10:41:12 +0900 Subject: [PATCH] TPE-184 Save Snapshot() variables to local storage Problem: Release ID was replaced unexpectedly if another snapshot request is comming while running the same. Fix: Save required vairables to local storage. Change-Id: I934a9e65027962ded6fe009ee94411277d4b9cc6 --- job_create_snapshot.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/job_create_snapshot.py b/job_create_snapshot.py index e601877..0ccfca4 100644 --- a/job_create_snapshot.py +++ b/job_create_snapshot.py @@ -110,20 +110,33 @@ def make_repo(project, backenddb, base_path, live_repo_base): try: snapshot = Snapshot(backenddb, base_path, obs_project=project) + + # Increment snapshot + snapshot.inc() + + # Store variables into local rather than accessing Snapshot() instance. + local_build_id = snapshot.build_id + local_targets = snapshot.targets + local_path = snapshot.path + local_dir = snapshot.dir + + # Delete Snapshot() instance. + del snapshot + + print 'We are working on:' + print '\t%s\n\t%s\n\t%s\n\t%s\n\n' % (local_build_id, local_targets, local_path, local_dir) + sys.stdout.flush() except SnapshotError, err: raise LocalError("Error getting snapshot info: %s" % str(err)) - # Increment snapshot - snapshot.inc() - - targets = snapshot.targets + targets = local_targets live_repo_path = os.path.join(live_repo_base, project.replace(':', ':/')) repos = {} imagedatas = {} if buildmonitor_enabled: - bm_snapshot_name = snapshot.build_id + bm_snapshot_name = local_build_id #buildmonitor.start_create_snapshot_for_post_build_snapshot(project, # bm_snapshot_name, # bm_start_datetime) @@ -137,7 +150,7 @@ def make_repo(project, backenddb, base_path, live_repo_base): # Convert live repo to download structure for repo in targets: - repomaker = RepoMaker(snapshot.build_id, snapshot.path) + repomaker = RepoMaker(local_build_id, local_path) # Get specific repo buildconf from OBS, put the buildconf together with # repo-md @@ -159,11 +172,11 @@ def make_repo(project, backenddb, base_path, live_repo_base): #buildmonitor.update_fail_create_snapshot_for_sr_stage(bm_project) bm_stage = 'Post_Snap_Fail' bm_data = {"bm_stage" : bm_stage, - "bm_snapshot_name" : snapshot.build_id, + "bm_snapshot_name" : local_build_id, } trigger_next("BUILD-MONITOR-5-%s" % bm_stage, bm_data) raise LocalError("Image configuration not found in %s" % - snapshot.path) + local_path) repos.update(repomaker.repos) imagedatas[repo['Name']] = repomaker.imagedata @@ -174,7 +187,7 @@ def make_repo(project, backenddb, base_path, live_repo_base): if bm_arch == 'ia32': bm_arch = 'i686' - bm_repo_dir = os.path.join(snapshot.path, "repos", bm_repo, "packages") + bm_repo_dir = os.path.join(local_path, "repos", bm_repo, "packages") #print '[%s] snapshot.path(%s), bm_repo(%s), bm_arch(%s)\n' \ # % (__file__, snapshot.path, bm_repo, bm_arch) #print '[%s] bm_repo_dir(%s), os.listdir(bm_repo_dir)(%s)\n' \ @@ -272,15 +285,15 @@ def make_repo(project, backenddb, base_path, live_repo_base): duplicated = set([x for x in path_list if path_list.count(x) > 1]) if len(duplicated) >= 1: prepare_mail('error_report_manifest.env', \ - 'Snapshot %s have duplicated packages' % (snapshot.build_id), \ + 'Snapshot %s have duplicated packages' % (local_build_id), \ '\nDuplicated items: %s' % duplicated, \ os.getenv('NOREPLY_EMAIL_SENDER'), \ os.getenv('MAILINGLIST_SYSTEM').split(',')) return {'project': project, 'repo': repos, - 'repo_path': os.path.join(snapshot.dir, snapshot.build_id), - 'build_id': snapshot.build_id, + 'repo_path': os.path.join(local_dir, local_build_id), + 'build_id': local_build_id, 'imagedata': imagedatas } @@ -407,3 +420,4 @@ if __name__ == '__main__': except LocalError, error: print error sys.exit(1) + -- 2.7.4