Merge lp:~thedac/charms/trusty/openstack-dashboard/action-managed-upgrade into lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/next
- Trusty Tahr (14.04)
- action-managed-upgrade
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 87 |
Proposed branch: | lp:~thedac/charms/trusty/openstack-dashboard/action-managed-upgrade |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/next |
Diff against target: |
216 lines (+148/-2) 6 files modified
actions.yaml (+2/-0) actions/openstack_upgrade.py (+34/-0) config.yaml (+10/-1) hooks/charmhelpers/contrib/openstack/utils.py (+48/-0) hooks/horizon_hooks.py (+1/-1) unit_tests/test_actions_openstack_upgrade.py (+53/-0) |
To merge this branch: | bzr merge lp:~thedac/charms/trusty/openstack-dashboard/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+271027@code.launchpad.net |
Commit message
Description of the change
Add action managed upgrades of OpenStack
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9160 openstack-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6425 openstack-
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://
- 86. By David Ames
-
Add tests for action managed upgrade
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10062 openstack-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9229 openstack-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6448 openstack-
AMULET OK: passed
Build: http://
Corey Bryant (corey.bryant) wrote : | # |
Hey David, inline comment below.
Corey Bryant (corey.bryant) wrote : | # |
Response to my initial comment inline.h
Corey Bryant (corey.bryant) wrote : | # |
Bad wifi, added comment inline again
- 87. By David Ames
-
Specifically call config_changed which has the restart_on_change decorator
- 88. By David Ames
-
Fix tests
David Ames (thedac) wrote : | # |
Agreed. Calling config_changed() on successful upgrade.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9613 openstack-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10424 openstack-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6569 openstack-
AMULET OK: passed
Build: http://
Billy Olsen (billy-olsen) wrote : | # |
David, added an inline comment below. Minor fix and it should be good to go.
- 89. By David Ames
-
Do not use register_configs import CONFIGS directly
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10574 openstack-
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9761 openstack-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6706 openstack-
AMULET OK: passed
Build: http://
Preview Diff
1 | === modified file 'actions.yaml' | |||
2 | --- actions.yaml 2015-04-07 13:58:41 +0000 | |||
3 | +++ actions.yaml 2015-09-23 14:38:13 +0000 | |||
4 | @@ -1,2 +1,4 @@ | |||
5 | 1 | git-reinstall: | 1 | git-reinstall: |
6 | 2 | description: Reinstall openstack-dashboard from the openstack-origin-git repositories. | 2 | description: Reinstall openstack-dashboard 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:38:13 +0000 | |||
15 | @@ -0,0 +1,34 @@ | |||
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 horizon_utils import ( | ||
26 | 11 | do_openstack_upgrade, | ||
27 | 12 | ) | ||
28 | 13 | |||
29 | 14 | from horizon_hooks import ( | ||
30 | 15 | config_changed, | ||
31 | 16 | CONFIGS, | ||
32 | 17 | ) | ||
33 | 18 | |||
34 | 19 | |||
35 | 20 | def openstack_upgrade(): | ||
36 | 21 | """Upgrade packages to config-set Openstack version. | ||
37 | 22 | |||
38 | 23 | If the charm was installed from source we cannot upgrade it. | ||
39 | 24 | For backwards compatibility a config flag must be set for this | ||
40 | 25 | code to run, otherwise a full service level upgrade will fire | ||
41 | 26 | on config-changed.""" | ||
42 | 27 | |||
43 | 28 | if do_action_openstack_upgrade('openstack-dashboard', | ||
44 | 29 | do_openstack_upgrade, | ||
45 | 30 | CONFIGS): | ||
46 | 31 | config_changed() | ||
47 | 32 | |||
48 | 33 | if __name__ == '__main__': | ||
49 | 34 | openstack_upgrade() | ||
50 | 0 | 35 | ||
51 | === modified file 'config.yaml' | |||
52 | --- config.yaml 2015-07-10 14:18:48 +0000 | |||
53 | +++ config.yaml 2015-09-23 14:38:13 +0000 | |||
54 | @@ -175,4 +175,13 @@ | |||
55 | 175 | description: | | 175 | description: | |
56 | 176 | A comma-separated list of nagios servicegroups. If left empty, the | 176 | A comma-separated list of nagios servicegroups. If left empty, the |
57 | 177 | nagios_context will be used as the servicegroup. | 177 | nagios_context will be used as the servicegroup. |
59 | 178 | 178 | action-managed-upgrade: | |
60 | 179 | type: boolean | ||
61 | 180 | default: False | ||
62 | 181 | description: | | ||
63 | 182 | If True enables openstack upgrades for this charm via juju actions. | ||
64 | 183 | You will still need to set openstack-origin to the new repository but | ||
65 | 184 | instead of an upgrade running automatically across all units, it will | ||
66 | 185 | wait for you to execute the openstack-upgrade action for this charm on | ||
67 | 186 | each unit. If False it will revert to existing behavior of upgrading | ||
68 | 187 | all units on config change. | ||
69 | 179 | 188 | ||
70 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
71 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-04 13:59:26 +0000 | |||
72 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-09-23 14:38:13 +0000 | |||
73 | @@ -25,6 +25,7 @@ | |||
74 | 25 | import re | 25 | import re |
75 | 26 | 26 | ||
76 | 27 | import six | 27 | import six |
77 | 28 | import traceback | ||
78 | 28 | import yaml | 29 | import yaml |
79 | 29 | 30 | ||
80 | 30 | from charmhelpers.contrib.network import ip | 31 | from charmhelpers.contrib.network import ip |
81 | @@ -34,6 +35,8 @@ | |||
82 | 34 | ) | 35 | ) |
83 | 35 | 36 | ||
84 | 36 | from charmhelpers.core.hookenv import ( | 37 | from charmhelpers.core.hookenv import ( |
85 | 38 | action_fail, | ||
86 | 39 | action_set, | ||
87 | 37 | config, | 40 | config, |
88 | 38 | log as juju_log, | 41 | log as juju_log, |
89 | 39 | charm_dir, | 42 | charm_dir, |
90 | @@ -114,6 +117,7 @@ | |||
91 | 114 | ('2.2.1', 'kilo'), | 117 | ('2.2.1', 'kilo'), |
92 | 115 | ('2.2.2', 'kilo'), | 118 | ('2.2.2', 'kilo'), |
93 | 116 | ('2.3.0', 'liberty'), | 119 | ('2.3.0', 'liberty'), |
94 | 120 | ('2.4.0', 'liberty'), | ||
95 | 117 | ]) | 121 | ]) |
96 | 118 | 122 | ||
97 | 119 | # >= Liberty version->codename mapping | 123 | # >= Liberty version->codename mapping |
98 | @@ -748,3 +752,47 @@ | |||
99 | 748 | return projects[key] | 752 | return projects[key] |
100 | 749 | 753 | ||
101 | 750 | return None | 754 | return None |
102 | 755 | |||
103 | 756 | |||
104 | 757 | def do_action_openstack_upgrade(package, upgrade_callback, configs): | ||
105 | 758 | """Perform action-managed OpenStack upgrade. | ||
106 | 759 | |||
107 | 760 | Upgrades packages to the configured openstack-origin version and sets | ||
108 | 761 | the corresponding action status as a result. | ||
109 | 762 | |||
110 | 763 | If the charm was installed from source we cannot upgrade it. | ||
111 | 764 | For backwards compatibility a config flag (action-managed-upgrade) must | ||
112 | 765 | be set for this code to run, otherwise a full service level upgrade will | ||
113 | 766 | fire on config-changed. | ||
114 | 767 | |||
115 | 768 | @param package: package name for determining if upgrade available | ||
116 | 769 | @param upgrade_callback: function callback to charm's upgrade function | ||
117 | 770 | @param configs: templating object derived from OSConfigRenderer class | ||
118 | 771 | |||
119 | 772 | @return: True if upgrade successful; False if upgrade failed or skipped | ||
120 | 773 | """ | ||
121 | 774 | ret = False | ||
122 | 775 | |||
123 | 776 | if git_install_requested(): | ||
124 | 777 | action_set({'outcome': 'installed from source, skipped upgrade.'}) | ||
125 | 778 | else: | ||
126 | 779 | if openstack_upgrade_available(package): | ||
127 | 780 | if config('action-managed-upgrade'): | ||
128 | 781 | juju_log('Upgrading OpenStack release') | ||
129 | 782 | |||
130 | 783 | try: | ||
131 | 784 | upgrade_callback(configs=configs) | ||
132 | 785 | action_set({'outcome': 'success, upgrade completed.'}) | ||
133 | 786 | ret = True | ||
134 | 787 | except: | ||
135 | 788 | action_set({'outcome': 'upgrade failed, see traceback.'}) | ||
136 | 789 | action_set({'traceback': traceback.format_exc()}) | ||
137 | 790 | action_fail('do_openstack_upgrade resulted in an ' | ||
138 | 791 | 'unexpected error') | ||
139 | 792 | else: | ||
140 | 793 | action_set({'outcome': 'action-managed-upgrade config is ' | ||
141 | 794 | 'False, skipped upgrade.'}) | ||
142 | 795 | else: | ||
143 | 796 | action_set({'outcome': 'no upgrade available.'}) | ||
144 | 797 | |||
145 | 798 | return ret | ||
146 | 751 | 799 | ||
147 | === modified file 'hooks/horizon_hooks.py' | |||
148 | --- hooks/horizon_hooks.py 2015-09-23 08:07:40 +0000 | |||
149 | +++ hooks/horizon_hooks.py 2015-09-23 14:38:13 +0000 | |||
150 | @@ -104,7 +104,7 @@ | |||
151 | 104 | if git_install_requested(): | 104 | if git_install_requested(): |
152 | 105 | if config_value_changed('openstack-origin-git'): | 105 | if config_value_changed('openstack-origin-git'): |
153 | 106 | git_install(config('openstack-origin-git')) | 106 | git_install(config('openstack-origin-git')) |
155 | 107 | else: | 107 | elif not config('action-managed-upgrade'): |
156 | 108 | if openstack_upgrade_available('openstack-dashboard'): | 108 | if openstack_upgrade_available('openstack-dashboard'): |
157 | 109 | do_openstack_upgrade(configs=CONFIGS) | 109 | do_openstack_upgrade(configs=CONFIGS) |
158 | 110 | 110 | ||
159 | 111 | 111 | ||
160 | === added file 'unit_tests/test_actions_openstack_upgrade.py' | |||
161 | --- unit_tests/test_actions_openstack_upgrade.py 1970-01-01 00:00:00 +0000 | |||
162 | +++ unit_tests/test_actions_openstack_upgrade.py 2015-09-23 14:38:13 +0000 | |||
163 | @@ -0,0 +1,53 @@ | |||
164 | 1 | from mock import patch | ||
165 | 2 | import os | ||
166 | 3 | |||
167 | 4 | os.environ['JUJU_UNIT_NAME'] = 'openstack-dashboard' | ||
168 | 5 | |||
169 | 6 | with patch('horizon_utils.register_configs') as register_configs: | ||
170 | 7 | import openstack_upgrade | ||
171 | 8 | |||
172 | 9 | from test_utils import ( | ||
173 | 10 | CharmTestCase | ||
174 | 11 | ) | ||
175 | 12 | |||
176 | 13 | TO_PATCH = [ | ||
177 | 14 | 'do_openstack_upgrade', | ||
178 | 15 | 'config_changed', | ||
179 | 16 | ] | ||
180 | 17 | |||
181 | 18 | |||
182 | 19 | class TestHorizonUpgradeActions(CharmTestCase): | ||
183 | 20 | |||
184 | 21 | def setUp(self): | ||
185 | 22 | super(TestHorizonUpgradeActions, self).setUp(openstack_upgrade, | ||
186 | 23 | TO_PATCH) | ||
187 | 24 | |||
188 | 25 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
189 | 26 | @patch('charmhelpers.contrib.openstack.utils.action_set') | ||
190 | 27 | @patch('charmhelpers.contrib.openstack.utils.git_install_requested') | ||
191 | 28 | @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') | ||
192 | 29 | def test_openstack_upgrade_true(self, upgrade_avail, git_requested, | ||
193 | 30 | action_set, config): | ||
194 | 31 | git_requested.return_value = False | ||
195 | 32 | upgrade_avail.return_value = True | ||
196 | 33 | config.return_value = True | ||
197 | 34 | |||
198 | 35 | openstack_upgrade.openstack_upgrade() | ||
199 | 36 | |||
200 | 37 | self.assertTrue(self.do_openstack_upgrade.called) | ||
201 | 38 | self.assertTrue(self.config_changed.called) | ||
202 | 39 | |||
203 | 40 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
204 | 41 | @patch('charmhelpers.contrib.openstack.utils.action_set') | ||
205 | 42 | @patch('charmhelpers.contrib.openstack.utils.git_install_requested') | ||
206 | 43 | @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') | ||
207 | 44 | def test_openstack_upgrade_false(self, upgrade_avail, git_requested, | ||
208 | 45 | action_set, config): | ||
209 | 46 | git_requested.return_value = False | ||
210 | 47 | upgrade_avail.return_value = True | ||
211 | 48 | config.return_value = False | ||
212 | 49 | |||
213 | 50 | openstack_upgrade.openstack_upgrade() | ||
214 | 51 | |||
215 | 52 | self.assertFalse(self.do_openstack_upgrade.called) | ||
216 | 53 | self.assertFalse(self.config_changed.called) |
charm_lint_check #9942 openstack- dashboard- next for thedac mp271027
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/9942/