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
1=== modified file 'scripts/glance-simplestreams-sync.py'
2--- scripts/glance-simplestreams-sync.py 2015-09-08 16:25:57 +0000
3+++ scripts/glance-simplestreams-sync.py 2016-04-12 14:17:41 +0000
4@@ -366,11 +366,10 @@
5
6 log.info("glance-simplestreams-sync started.")
7
8- atexit.register(cleanup)
9-
10 lockfile = open(SYNC_RUNNING_FLAG_FILE_NAME, 'w')
11 try:
12 fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
13+ atexit.register(cleanup)
14 except IOError:
15 log.info("{} is locked, exiting".format(SYNC_RUNNING_FLAG_FILE_NAME))
16 sys.exit(0)

Subscribers

People subscribed via source and target branches