From 92ede36c64cc18e8636e5ddbaf25443742b80d1c Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Mon, 20 Aug 2012 10:35:00 -0700 Subject: [PATCH] Log start/stop times of gerrit user sync script. Add rudimentary logging to the gerrit user sync script. Log the start and stop times of script runs. Also modify timeout in the cronjob to allow the job to run for up to 8 hours in order to get better log data. Change-Id: I193911e2d4dcd6448ef8a61360e6fc9fff287c1a Reviewed-on: https://review.openstack.org/11658 Reviewed-by: James E. Blair Approved: James E. Blair Tested-by: Jenkins --- modules/launchpad_sync/files/update_gerrit_users.py | 7 +++++++ modules/launchpad_sync/manifests/init.pp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/launchpad_sync/files/update_gerrit_users.py b/modules/launchpad_sync/files/update_gerrit_users.py index 41332f1dd8..dd0bf25511 100755 --- a/modules/launchpad_sync/files/update_gerrit_users.py +++ b/modules/launchpad_sync/files/update_gerrit_users.py @@ -52,6 +52,10 @@ except IOError: # another instance is running sys.exit(0) +log_file = '/home/gerrit2/lp_sync_log' +log_fp = open(log_file, 'a') +log_fp.write('sync start ' + str(datetime.now()) + '\n') + parser = argparse.ArgumentParser() parser.add_argument('user', help='The gerrit admin user') parser.add_argument('ssh_key', help='The gerrit admin SSH key file') @@ -409,3 +413,6 @@ os.system("ssh -i %s -p29418 %s@localhost gerrit flush-caches" % (GERRIT_SSH_KEY, GERRIT_USER)) conn.commit() + +log_fp.write('sync stop ' + str(datetime.now()) + '\n') +log_fp.close() diff --git a/modules/launchpad_sync/manifests/init.pp b/modules/launchpad_sync/manifests/init.pp index da72144214..72d966719c 100644 --- a/modules/launchpad_sync/manifests/init.pp +++ b/modules/launchpad_sync/manifests/init.pp @@ -29,7 +29,7 @@ class launchpad_sync( cron { "sync_launchpad_users": user => $user, minute => "*/15", - command => "sleep $((RANDOM\\%60+60)) && timeout -k 5m 65m python /usr/local/bin/update_gerrit_users.py ${script_user} ${script_key_file} ${site} ${root_team}", + command => "sleep $((RANDOM\\%60+60)) && timeout -k 5m 8h python /usr/local/bin/update_gerrit_users.py ${script_user} ${script_key_file} ${site} ${root_team}", require => File['/usr/local/bin/update_gerrit_users.py'], }