Merge lp:~adam-collard/charms/trusty/swift-storage/fix-unconditional-service-restart into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by Adam Collard on 2015-09-01
Status: Merged
Merged at revision: 79
Proposed branch: lp:~adam-collard/charms/trusty/swift-storage/fix-unconditional-service-restart
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 115 lines (+25/-26)
4 files modified
charmhelpers/contrib/network/ip.py (+5/-1)
charmhelpers/contrib/openstack/utils.py (+7/-5)
charmhelpers/core/hookenv.py (+11/-9)
tests/basic_deployment.py (+2/-11)
To merge this branch: bzr merge lp:~adam-collard/charms/trusty/swift-storage/fix-unconditional-service-restart
Reviewer Review Type Date Requested Status
Liam Young 2015-09-01 Approve on 2015-09-03
Review via email: mp+269744@code.launchpad.net

Description of the change

This branch prevents the swift-storage charm from thinking there was an OpenStack upgrade available at every config-changed.

I had to update the Amulet tests because they were incorrectly asserting that all of the swift services should have been restarted following a change to object-server-threads-per-disk. In fact, only the object services should be restarted, and only are (the test passed prior to this because of the bug in charm-helpers which caused the unconditional OpenStack upgrade, in turn restarting all of the services)

To post a comment you must log in.

charm_lint_check #9156 swift-storage-next for adam-collard mp269744
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/9156/

charm_unit_test #8462 swift-storage-next for adam-collard mp269744
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/8462/

charm_amulet_test #6168 swift-storage-next for adam-collard mp269744
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/6168/

Liam Young (gnuoy) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/network/ip.py'
2--- charmhelpers/contrib/network/ip.py 2015-03-04 09:54:59 +0000
3+++ charmhelpers/contrib/network/ip.py 2015-09-01 12:23:46 +0000
4@@ -435,8 +435,12 @@
5
6 rev = dns.reversename.from_address(address)
7 result = ns_query(rev)
8+
9 if not result:
10- return None
11+ try:
12+ result = socket.gethostbyaddr(address)[0]
13+ except:
14+ return None
15 else:
16 result = address
17
18
19=== modified file 'charmhelpers/contrib/openstack/utils.py'
20--- charmhelpers/contrib/openstack/utils.py 2015-08-17 13:44:42 +0000
21+++ charmhelpers/contrib/openstack/utils.py 2015-09-01 12:23:46 +0000
22@@ -1,5 +1,3 @@
23-#!/usr/bin/python
24-
25 # Copyright 2014-2015 Canonical Limited.
26 #
27 # This file is part of charm-helpers.
28@@ -195,9 +193,9 @@
29 error_out(e)
30
31
32-def get_os_version_codename(codename):
33+def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES):
34 '''Determine OpenStack version number from codename.'''
35- for k, v in six.iteritems(OPENSTACK_CODENAMES):
36+ for k, v in six.iteritems(version_map):
37 if v == codename:
38 return k
39 e = 'Could not derive OpenStack version for '\
40@@ -429,7 +427,11 @@
41 import apt_pkg as apt
42 src = config('openstack-origin')
43 cur_vers = get_os_version_package(package)
44- available_vers = get_os_version_install_source(src)
45+ if "swift" in package:
46+ codename = get_os_codename_install_source(src)
47+ available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)
48+ else:
49+ available_vers = get_os_version_install_source(src)
50 apt.init()
51 return apt.version_compare(available_vers, cur_vers) == 1
52
53
54=== modified file 'charmhelpers/core/hookenv.py'
55--- charmhelpers/core/hookenv.py 2015-08-17 13:44:42 +0000
56+++ charmhelpers/core/hookenv.py 2015-09-01 12:23:46 +0000
57@@ -767,21 +767,23 @@
58
59
60 def status_get():
61- """Retrieve the previously set juju workload state
62-
63- If the status-set command is not found then assume this is juju < 1.23 and
64- return 'unknown'
65+ """Retrieve the previously set juju workload state and message
66+
67+ If the status-get command is not found then assume this is juju < 1.23 and
68+ return 'unknown', ""
69+
70 """
71- cmd = ['status-get']
72+ cmd = ['status-get', "--format=json", "--include-data"]
73 try:
74- raw_status = subprocess.check_output(cmd, universal_newlines=True)
75- status = raw_status.rstrip()
76- return status
77+ raw_status = subprocess.check_output(cmd)
78 except OSError as e:
79 if e.errno == errno.ENOENT:
80- return 'unknown'
81+ return ('unknown', "")
82 else:
83 raise
84+ else:
85+ status = json.loads(raw_status.decode("UTF-8"))
86+ return (status["status"], status["message"])
87
88
89 def translate_exc(from_exc, to_exc):
90
91=== modified file 'tests/basic_deployment.py'
92--- tests/basic_deployment.py 2015-08-22 04:12:14 +0000
93+++ tests/basic_deployment.py 2015-09-01 12:23:46 +0000
94@@ -429,19 +429,10 @@
95
96 # Config file affected by juju set config change, and
97 # services which are expected to restart upon config change
98- services = {'swift-account-server': 'account-server.conf',
99- 'swift-account-auditor': 'account-server.conf',
100- 'swift-account-reaper': 'account-server.conf',
101- 'swift-account-replicator': 'account-server.conf',
102- 'swift-container-server': 'container-server.conf',
103- 'swift-container-auditor': 'container-server.conf',
104- 'swift-container-replicator': 'container-server.conf',
105- 'swift-container-updater': 'container-server.conf',
106- 'swift-object-server': 'object-server.conf',
107+ services = {'swift-object-server': 'object-server.conf',
108 'swift-object-auditor': 'object-server.conf',
109 'swift-object-replicator': 'object-server.conf',
110- 'swift-object-updater': 'object-server.conf',
111- 'swift-container-sync': 'container-server.conf'}
112+ 'swift-object-updater': 'object-server.conf'}
113
114 # Make config change, check for service restarts
115 u.log.debug('Making config change on {}...'.format(juju_service))

Subscribers

People subscribed via source and target branches