Merge lp:~thedac/charms/trusty/neutron-gateway/action-managed-upgrade into lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next
- Trusty Tahr (14.04)
- action-managed-upgrade
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 141 |
Proposed branch: | lp:~thedac/charms/trusty/neutron-gateway/action-managed-upgrade |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next |
Diff against target: |
266 lines (+158/-5) 8 files modified
actions.yaml (+2/-0) actions/openstack_upgrade.py (+36/-0) config.yaml (+10/-0) hooks/charmhelpers/contrib/openstack/utils.py (+51/-0) hooks/neutron_hooks.py (+2/-3) hooks/neutron_utils.py (+2/-1) unit_tests/test_actions_openstack_upgrade.py (+53/-0) unit_tests/test_neutron_utils.py (+2/-1) |
To merge this branch: | bzr merge lp:~thedac/charms/trusty/neutron-gateway/action-managed-upgrade |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Ames (community) | Needs Resubmitting | ||
Billy Olsen | Needs Fixing | ||
OpenStack Charmers | Pending | ||
Review via email: mp+271183@code.launchpad.net |
Commit message
Description of the change
Action managed upgrades
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9228 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6449 neutron-
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10421 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9611 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6566 neutron-
AMULET OK: passed
Build: http://
Billy Olsen (billy-olsen) wrote : | # |
David, same comment in this MP as with the openstack-dashboard MP. Quick comment inline which is a fairly simple fix and it should be good to go.
- 145. By David Ames
-
Do not use register_configs import CONFIGS directly
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10572 neutron-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9762 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6707 neutron-
AMULET OK: passed
Build: http://
Preview Diff
1 | === modified file 'actions.yaml' | |||
2 | --- actions.yaml 2015-04-10 14:22:04 +0000 | |||
3 | +++ actions.yaml 2015-09-23 14:40:28 +0000 | |||
4 | @@ -1,2 +1,4 @@ | |||
5 | 1 | git-reinstall: | 1 | git-reinstall: |
6 | 2 | description: Reinstall quantum-gateway from the openstack-origin-git repositories. | 2 | description: Reinstall quantum-gateway from the openstack-origin-git repositories. |
7 | 3 | openstack-upgrade: | ||
8 | 4 | description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True. | ||
9 | 3 | 5 | ||
10 | === added symlink 'actions/openstack-upgrade' | |||
11 | === target is u'openstack_upgrade.py' | |||
12 | === added file 'actions/openstack_upgrade.py' | |||
13 | --- actions/openstack_upgrade.py 1970-01-01 00:00:00 +0000 | |||
14 | +++ actions/openstack_upgrade.py 2015-09-23 14:40:28 +0000 | |||
15 | @@ -0,0 +1,36 @@ | |||
16 | 1 | #!/usr/bin/python | ||
17 | 2 | import sys | ||
18 | 3 | |||
19 | 4 | sys.path.append('hooks/') | ||
20 | 5 | |||
21 | 6 | from charmhelpers.contrib.openstack.utils import ( | ||
22 | 7 | do_action_openstack_upgrade, | ||
23 | 8 | ) | ||
24 | 9 | |||
25 | 10 | from neutron_utils import ( | ||
26 | 11 | do_openstack_upgrade, | ||
27 | 12 | get_common_package, | ||
28 | 13 | ) | ||
29 | 14 | |||
30 | 15 | from neutron_hooks import ( | ||
31 | 16 | config_changed, | ||
32 | 17 | CONFIGS, | ||
33 | 18 | ) | ||
34 | 19 | |||
35 | 20 | |||
36 | 21 | def openstack_upgrade(): | ||
37 | 22 | """Upgrade packages to config-set Openstack version. | ||
38 | 23 | |||
39 | 24 | If the charm was installed from source we cannot upgrade it. | ||
40 | 25 | For backwards compatibility a config flag must be set for this | ||
41 | 26 | code to run, otherwise a full service level upgrade will fire | ||
42 | 27 | on config-changed.""" | ||
43 | 28 | |||
44 | 29 | if do_action_openstack_upgrade(get_common_package(), | ||
45 | 30 | do_openstack_upgrade, | ||
46 | 31 | CONFIGS): | ||
47 | 32 | config_changed() | ||
48 | 33 | |||
49 | 34 | |||
50 | 35 | if __name__ == '__main__': | ||
51 | 36 | openstack_upgrade() | ||
52 | 0 | 37 | ||
53 | === modified file 'config.yaml' | |||
54 | --- config.yaml 2015-09-15 20:26:06 +0000 | |||
55 | +++ config.yaml 2015-09-23 14:40:28 +0000 | |||
56 | @@ -216,3 +216,13 @@ | |||
57 | 216 | description: | | 216 | description: | |
58 | 217 | Default multicast port number that will be used to communicate between | 217 | Default multicast port number that will be used to communicate between |
59 | 218 | HA Cluster nodes. | 218 | HA Cluster nodes. |
60 | 219 | action-managed-upgrade: | ||
61 | 220 | type: boolean | ||
62 | 221 | default: False | ||
63 | 222 | description: | | ||
64 | 223 | If True enables openstack upgrades for this charm via juju actions. | ||
65 | 224 | You will still need to set openstack-origin to the new repository but | ||
66 | 225 | instead of an upgrade running automatically across all units, it will | ||
67 | 226 | wait for you to execute the openstack-upgrade action for this charm on | ||
68 | 227 | each unit. If False it will revert to existing behavior of upgrading | ||
69 | 228 | all units on config change. | ||
70 | 219 | 229 | ||
71 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
72 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-03 09:43:15 +0000 | |||
73 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-09-23 14:40:28 +0000 | |||
74 | @@ -25,6 +25,7 @@ | |||
75 | 25 | import re | 25 | import re |
76 | 26 | 26 | ||
77 | 27 | import six | 27 | import six |
78 | 28 | import traceback | ||
79 | 28 | import yaml | 29 | import yaml |
80 | 29 | 30 | ||
81 | 30 | from charmhelpers.contrib.network import ip | 31 | from charmhelpers.contrib.network import ip |
82 | @@ -34,6 +35,8 @@ | |||
83 | 34 | ) | 35 | ) |
84 | 35 | 36 | ||
85 | 36 | from charmhelpers.core.hookenv import ( | 37 | from charmhelpers.core.hookenv import ( |
86 | 38 | action_fail, | ||
87 | 39 | action_set, | ||
88 | 37 | config, | 40 | config, |
89 | 38 | log as juju_log, | 41 | log as juju_log, |
90 | 39 | charm_dir, | 42 | charm_dir, |
91 | @@ -114,6 +117,7 @@ | |||
92 | 114 | ('2.2.1', 'kilo'), | 117 | ('2.2.1', 'kilo'), |
93 | 115 | ('2.2.2', 'kilo'), | 118 | ('2.2.2', 'kilo'), |
94 | 116 | ('2.3.0', 'liberty'), | 119 | ('2.3.0', 'liberty'), |
95 | 120 | ('2.4.0', 'liberty'), | ||
96 | 117 | ]) | 121 | ]) |
97 | 118 | 122 | ||
98 | 119 | # >= Liberty version->codename mapping | 123 | # >= Liberty version->codename mapping |
99 | @@ -142,6 +146,9 @@ | |||
100 | 142 | 'glance-common': OrderedDict([ | 146 | 'glance-common': OrderedDict([ |
101 | 143 | ('11.0.0', 'liberty'), | 147 | ('11.0.0', 'liberty'), |
102 | 144 | ]), | 148 | ]), |
103 | 149 | 'openstack-dashboard': OrderedDict([ | ||
104 | 150 | ('8.0.0', 'liberty'), | ||
105 | 151 | ]), | ||
106 | 145 | } | 152 | } |
107 | 146 | 153 | ||
108 | 147 | DEFAULT_LOOPBACK_SIZE = '5G' | 154 | DEFAULT_LOOPBACK_SIZE = '5G' |
109 | @@ -745,3 +752,47 @@ | |||
110 | 745 | return projects[key] | 752 | return projects[key] |
111 | 746 | 753 | ||
112 | 747 | return None | 754 | return None |
113 | 755 | |||
114 | 756 | |||
115 | 757 | def do_action_openstack_upgrade(package, upgrade_callback, configs): | ||
116 | 758 | """Perform action-managed OpenStack upgrade. | ||
117 | 759 | |||
118 | 760 | Upgrades packages to the configured openstack-origin version and sets | ||
119 | 761 | the corresponding action status as a result. | ||
120 | 762 | |||
121 | 763 | If the charm was installed from source we cannot upgrade it. | ||
122 | 764 | For backwards compatibility a config flag (action-managed-upgrade) must | ||
123 | 765 | be set for this code to run, otherwise a full service level upgrade will | ||
124 | 766 | fire on config-changed. | ||
125 | 767 | |||
126 | 768 | @param package: package name for determining if upgrade available | ||
127 | 769 | @param upgrade_callback: function callback to charm's upgrade function | ||
128 | 770 | @param configs: templating object derived from OSConfigRenderer class | ||
129 | 771 | |||
130 | 772 | @return: True if upgrade successful; False if upgrade failed or skipped | ||
131 | 773 | """ | ||
132 | 774 | ret = False | ||
133 | 775 | |||
134 | 776 | if git_install_requested(): | ||
135 | 777 | action_set({'outcome': 'installed from source, skipped upgrade.'}) | ||
136 | 778 | else: | ||
137 | 779 | if openstack_upgrade_available(package): | ||
138 | 780 | if config('action-managed-upgrade'): | ||
139 | 781 | juju_log('Upgrading OpenStack release') | ||
140 | 782 | |||
141 | 783 | try: | ||
142 | 784 | upgrade_callback(configs=configs) | ||
143 | 785 | action_set({'outcome': 'success, upgrade completed.'}) | ||
144 | 786 | ret = True | ||
145 | 787 | except: | ||
146 | 788 | action_set({'outcome': 'upgrade failed, see traceback.'}) | ||
147 | 789 | action_set({'traceback': traceback.format_exc()}) | ||
148 | 790 | action_fail('do_openstack_upgrade resulted in an ' | ||
149 | 791 | 'unexpected error') | ||
150 | 792 | else: | ||
151 | 793 | action_set({'outcome': 'action-managed-upgrade config is ' | ||
152 | 794 | 'False, skipped upgrade.'}) | ||
153 | 795 | else: | ||
154 | 796 | action_set({'outcome': 'no upgrade available.'}) | ||
155 | 797 | |||
156 | 798 | return ret | ||
157 | 748 | 799 | ||
158 | === modified file 'hooks/neutron_hooks.py' | |||
159 | --- hooks/neutron_hooks.py 2015-09-22 13:46:41 +0000 | |||
160 | +++ hooks/neutron_hooks.py 2015-09-23 14:40:28 +0000 | |||
161 | @@ -102,10 +102,9 @@ | |||
162 | 102 | if config_value_changed('openstack-origin-git'): | 102 | if config_value_changed('openstack-origin-git'): |
163 | 103 | git_install(config('openstack-origin-git')) | 103 | git_install(config('openstack-origin-git')) |
164 | 104 | CONFIGS.write_all() | 104 | CONFIGS.write_all() |
166 | 105 | else: | 105 | elif not config('action-managed-upgrade'): |
167 | 106 | if openstack_upgrade_available(get_common_package()): | 106 | if openstack_upgrade_available(get_common_package()): |
170 | 107 | do_openstack_upgrade() | 107 | do_openstack_upgrade(CONFIGS) |
169 | 108 | CONFIGS.write_all() | ||
171 | 109 | 108 | ||
172 | 110 | update_nrpe_config() | 109 | update_nrpe_config() |
173 | 111 | 110 | ||
174 | 112 | 111 | ||
175 | === modified file 'hooks/neutron_utils.py' | |||
176 | --- hooks/neutron_utils.py 2015-09-10 12:35:59 +0000 | |||
177 | +++ hooks/neutron_utils.py 2015-09-23 14:40:28 +0000 | |||
178 | @@ -652,7 +652,7 @@ | |||
179 | 652 | return list(set(_services)) | 652 | return list(set(_services)) |
180 | 653 | 653 | ||
181 | 654 | 654 | ||
183 | 655 | def do_openstack_upgrade(): | 655 | def do_openstack_upgrade(configs): |
184 | 656 | """ | 656 | """ |
185 | 657 | Perform an upgrade. Takes care of upgrading packages, rewriting | 657 | Perform an upgrade. Takes care of upgrading packages, rewriting |
186 | 658 | configs, database migrations and potentially any other post-upgrade | 658 | configs, database migrations and potentially any other post-upgrade |
187 | @@ -672,6 +672,7 @@ | |||
188 | 672 | fatal=True, dist=True) | 672 | fatal=True, dist=True) |
189 | 673 | apt_install(get_early_packages(), fatal=True) | 673 | apt_install(get_early_packages(), fatal=True) |
190 | 674 | apt_install(get_packages(), fatal=True) | 674 | apt_install(get_packages(), fatal=True) |
191 | 675 | configs.write_all() | ||
192 | 675 | 676 | ||
193 | 676 | 677 | ||
194 | 677 | def configure_ovs(): | 678 | def configure_ovs(): |
195 | 678 | 679 | ||
196 | === added file 'unit_tests/test_actions_openstack_upgrade.py' | |||
197 | --- unit_tests/test_actions_openstack_upgrade.py 1970-01-01 00:00:00 +0000 | |||
198 | +++ unit_tests/test_actions_openstack_upgrade.py 2015-09-23 14:40:28 +0000 | |||
199 | @@ -0,0 +1,53 @@ | |||
200 | 1 | from mock import patch | ||
201 | 2 | import os | ||
202 | 3 | |||
203 | 4 | os.environ['JUJU_UNIT_NAME'] = 'neutron-gateway' | ||
204 | 5 | |||
205 | 6 | with patch('neutron_utils.register_configs') as register_configs: | ||
206 | 7 | import openstack_upgrade | ||
207 | 8 | |||
208 | 9 | from test_utils import ( | ||
209 | 10 | CharmTestCase | ||
210 | 11 | ) | ||
211 | 12 | |||
212 | 13 | TO_PATCH = [ | ||
213 | 14 | 'do_openstack_upgrade', | ||
214 | 15 | 'config_changed', | ||
215 | 16 | ] | ||
216 | 17 | |||
217 | 18 | |||
218 | 19 | class TestNeutronGWUpgradeActions(CharmTestCase): | ||
219 | 20 | |||
220 | 21 | def setUp(self): | ||
221 | 22 | super(TestNeutronGWUpgradeActions, self).setUp(openstack_upgrade, | ||
222 | 23 | TO_PATCH) | ||
223 | 24 | |||
224 | 25 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
225 | 26 | @patch('charmhelpers.contrib.openstack.utils.action_set') | ||
226 | 27 | @patch('charmhelpers.contrib.openstack.utils.git_install_requested') | ||
227 | 28 | @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') | ||
228 | 29 | def test_openstack_upgrade_true(self, upgrade_avail, git_requested, | ||
229 | 30 | action_set, config): | ||
230 | 31 | git_requested.return_value = False | ||
231 | 32 | upgrade_avail.return_value = True | ||
232 | 33 | config.return_value = True | ||
233 | 34 | |||
234 | 35 | openstack_upgrade.openstack_upgrade() | ||
235 | 36 | |||
236 | 37 | self.assertTrue(self.do_openstack_upgrade.called) | ||
237 | 38 | self.assertTrue(self.config_changed.called) | ||
238 | 39 | |||
239 | 40 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
240 | 41 | @patch('charmhelpers.contrib.openstack.utils.action_set') | ||
241 | 42 | @patch('charmhelpers.contrib.openstack.utils.git_install_requested') | ||
242 | 43 | @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') | ||
243 | 44 | def test_openstack_upgrade_false(self, upgrade_avail, git_requested, | ||
244 | 45 | action_set, config): | ||
245 | 46 | git_requested.return_value = False | ||
246 | 47 | upgrade_avail.return_value = True | ||
247 | 48 | config.return_value = False | ||
248 | 49 | |||
249 | 50 | openstack_upgrade.openstack_upgrade() | ||
250 | 51 | |||
251 | 52 | self.assertFalse(self.do_openstack_upgrade.called) | ||
252 | 53 | self.assertFalse(self.config_changed.called) | ||
253 | 0 | 54 | ||
254 | === modified file 'unit_tests/test_neutron_utils.py' | |||
255 | --- unit_tests/test_neutron_utils.py 2015-09-10 12:35:59 +0000 | |||
256 | +++ unit_tests/test_neutron_utils.py 2015-09-23 14:40:28 +0000 | |||
257 | @@ -244,7 +244,8 @@ | |||
258 | 244 | self.test_config.set('openstack-origin', 'cloud:precise-havana') | 244 | self.test_config.set('openstack-origin', 'cloud:precise-havana') |
259 | 245 | self.test_config.set('plugin', 'ovs') | 245 | self.test_config.set('plugin', 'ovs') |
260 | 246 | self.get_os_codename_install_source.return_value = 'havana' | 246 | self.get_os_codename_install_source.return_value = 'havana' |
262 | 247 | neutron_utils.do_openstack_upgrade() | 247 | configs = neutron_utils.register_configs() |
263 | 248 | neutron_utils.do_openstack_upgrade(configs) | ||
264 | 248 | self.assertTrue(self.log.called) | 249 | self.assertTrue(self.log.called) |
265 | 249 | self.apt_update.assert_called_with(fatal=True) | 250 | self.apt_update.assert_called_with(fatal=True) |
266 | 250 | dpkg_opts = [ | 251 | dpkg_opts = [ |
charm_lint_check #10063 neutron- gateway- next for thedac mp271183
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/10063/