Merge lp:~bjornt/charms/trusty/ceph-radosgw/apt-cache-memonly into lp:~openstack-charmers-archive/charms/trusty/ceph-radosgw/trunk

Proposed by Björn Tillenius
Status: Superseded
Proposed branch: lp:~bjornt/charms/trusty/ceph-radosgw/apt-cache-memonly
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph-radosgw/trunk
Diff against target: 35 lines (+9/-5)
1 file modified
hooks/ceph.py (+9/-5)
To merge this branch: bzr merge lp:~bjornt/charms/trusty/ceph-radosgw/apt-cache-memonly
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+227873@code.launchpad.net

This proposal has been superseded by a proposal from 2014-07-23.

Description of the change

Build the Apt cache in memory when checking the ceph version.

This avoids a race condition where something else is rebuilding
the Apt cache in the same directory.

I also changed the imports, so it's clear that it's the apt_pkg
that is being used. There's another module called apt, which
provides a different API, and importing apt_pkg as apt has
fooled me more than once.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/ceph.py'
2--- hooks/ceph.py 2014-01-24 16:04:49 +0000
3+++ hooks/ceph.py 2014-07-23 08:51:00 +0000
4@@ -11,7 +11,7 @@
5 import subprocess
6 import time
7 import os
8-import apt_pkg as apt
9+import apt_pkg
10
11 from socket import gethostname as get_unit_hostname
12
13@@ -223,14 +223,18 @@
14
15
16 def get_ceph_version(package=None):
17- apt.init()
18- cache = apt.Cache()
19+ apt_pkg.init()
20+ # Force Apt to build its cache in memory. That way we avoid race
21+ # conditions with other applications building the cache in the same
22+ # place.
23+ apt_pkg.config.set("Dir::Cache::pkgcache", "")
24+ cache = apt_pkg.Cache()
25 pkg = cache[package or 'ceph']
26 if pkg.current_ver:
27- return apt.upstream_version(pkg.current_ver.ver_str)
28+ return apt_pkg.upstream_version(pkg.current_ver.ver_str)
29 else:
30 return None
31
32
33 def version_compare(a, b):
34- return apt.version_compare(a, b)
35+ return apt_pkg.version_compare(a, b)

Subscribers

People subscribed via source and target branches