Merge lp:~danilo/charms/trusty/glance-simplestreams-sync/next-lock-fix into lp:~openstack-charmers/charms/trusty/glance-simplestreams-sync/next

Proposed by Данило Шеган
Status: Merged
Merged at revision: 58
Proposed branch: lp:~danilo/charms/trusty/glance-simplestreams-sync/next-lock-fix
Merge into: lp:~openstack-charmers/charms/trusty/glance-simplestreams-sync/next
Diff against target: 16 lines (+1/-2)
1 file modified
scripts/glance-simplestreams-sync.py (+1/-2)
To merge this branch: bzr merge lp:~danilo/charms/trusty/glance-simplestreams-sync/next-lock-fix
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+291634@code.launchpad.net

This proposal supersedes a proposal from 2016-04-12.

Description of the change

Only remove the lock file on exit if it was acquired in the first place. Stop it from hitting races and downloading same images multiple times.

See bug for details. Without this fix, the log had things like:

  http://paste.ubuntu.com/15789872/

which resulted in 2 xenial images and 1 trusty image.

With the fix, the result is a more reasonable

  http://paste.ubuntu.com/15789914/

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote : Posted in a previous version of this proposal

We've started off with next charm, and this issue does not seem to affect trunk :/

What's the current situation with this charm? What is the latest and greatest to use? Landscape Autopilot is using it, and we do need some changes on top of it for now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'scripts/glance-simplestreams-sync.py'
--- scripts/glance-simplestreams-sync.py 2015-09-08 16:25:57 +0000
+++ scripts/glance-simplestreams-sync.py 2016-04-12 14:17:41 +0000
@@ -366,11 +366,10 @@
366366
367 log.info("glance-simplestreams-sync started.")367 log.info("glance-simplestreams-sync started.")
368368
369 atexit.register(cleanup)
370
371 lockfile = open(SYNC_RUNNING_FLAG_FILE_NAME, 'w')369 lockfile = open(SYNC_RUNNING_FLAG_FILE_NAME, 'w')
372 try:370 try:
373 fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)371 fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
372 atexit.register(cleanup)
374 except IOError:373 except IOError:
375 log.info("{} is locked, exiting".format(SYNC_RUNNING_FLAG_FILE_NAME))374 log.info("{} is locked, exiting".format(SYNC_RUNNING_FLAG_FILE_NAME))
376 sys.exit(0)375 sys.exit(0)

Subscribers

People subscribed via source and target branches