Lock file removed even if it fails to get a lock

Bug #1569358 reported by Данило Шеган
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glance-simplestreams-sync (Juju Charms Collection)
Fix Released
High
Данило Шеган

Bug Description

We've noticed that the lockfile gets removed in cleanup() in scripts/glance-simplestreams-sync.py even if it fails to acquire lock: since it runs atexit, cleanup is run when, on exception trying to lock, it does sys.exit().

This manifests in multiple identical images being downloaded in the initial run when there is still a per-minute cronjob: eg. I've had anything from 3 xenial and 2 trusty images to 2 xenial and 1 trusty, depending on the network speed.

What happens is this:

 1. A scripts kicks off, creates a lock file, and starts downloading images
 2. If script from 1 still hasn't finished downloading, a run after one minute finds the lockfile, aborts and removes the lockfile
 3. Two minutes in, if the script from 1 is still downloading, there is no more lockfile, so another run of the script will attempt to download the same images
 ...

The fix is simple, I'll be proposing a branch.

Related branches

Revision history for this message
Данило Шеган (danilo) wrote :

Note, this only applies to next, the trunk already has atexit handler moved past the exception handler, which works as well.

Changed in glance-simplestreams-sync (Juju Charms Collection):
status: New → In Progress
assignee: nobody → Данило Шеган (danilo)
Changed in glance-simplestreams-sync-charm:
status: In Progress → Invalid
no longer affects: glance-simplestreams-sync-charm
James Page (james-page)
Changed in glance-simplestreams-sync (Juju Charms Collection):
status: In Progress → Fix Committed
importance: Undecided → High
James Page (james-page)
Changed in glance-simplestreams-sync (Juju Charms Collection):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.