Merge lp:~thedac/charms/trusty/neutron-gateway/action-managed-upgrade into lp:~openstack-charmers-archive/charms/trusty/neutron-gateway/next

Proposed by David Ames
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
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

Description of the change

Action managed upgrades

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #9228 neutron-gateway-next for thedac mp271183
    UNIT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #6449 neutron-gateway-next for thedac mp271183
    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://paste.ubuntu.com/12420416/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6449/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #10421 neutron-gateway-next for thedac mp271183
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #9611 neutron-gateway-next for thedac mp271183
    UNIT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #6566 neutron-gateway-next for thedac mp271183
    AMULET OK: passed

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

Revision history for this message
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.

review: Needs Fixing
145. By David Ames

Do not use register_configs import CONFIGS directly

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #10572 neutron-gateway-next for thedac mp271183
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #9762 neutron-gateway-next for thedac mp271183
    UNIT OK: passed

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

Revision history for this message
David Ames (thedac) wrote :

Resubmit

review: Needs Resubmitting
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #6707 neutron-gateway-next for thedac mp271183
    AMULET OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'actions.yaml'
--- actions.yaml 2015-04-10 14:22:04 +0000
+++ actions.yaml 2015-09-23 14:40:28 +0000
@@ -1,2 +1,4 @@
1git-reinstall:1git-reinstall:
2 description: Reinstall quantum-gateway from the openstack-origin-git repositories.2 description: Reinstall quantum-gateway from the openstack-origin-git repositories.
3openstack-upgrade:
4 description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True.
35
=== added symlink 'actions/openstack-upgrade'
=== target is u'openstack_upgrade.py'
=== added file 'actions/openstack_upgrade.py'
--- actions/openstack_upgrade.py 1970-01-01 00:00:00 +0000
+++ actions/openstack_upgrade.py 2015-09-23 14:40:28 +0000
@@ -0,0 +1,36 @@
1#!/usr/bin/python
2import sys
3
4sys.path.append('hooks/')
5
6from charmhelpers.contrib.openstack.utils import (
7 do_action_openstack_upgrade,
8)
9
10from neutron_utils import (
11 do_openstack_upgrade,
12 get_common_package,
13)
14
15from neutron_hooks import (
16 config_changed,
17 CONFIGS,
18)
19
20
21def openstack_upgrade():
22 """Upgrade packages to config-set Openstack version.
23
24 If the charm was installed from source we cannot upgrade it.
25 For backwards compatibility a config flag must be set for this
26 code to run, otherwise a full service level upgrade will fire
27 on config-changed."""
28
29 if do_action_openstack_upgrade(get_common_package(),
30 do_openstack_upgrade,
31 CONFIGS):
32 config_changed()
33
34
35if __name__ == '__main__':
36 openstack_upgrade()
037
=== modified file 'config.yaml'
--- config.yaml 2015-09-15 20:26:06 +0000
+++ config.yaml 2015-09-23 14:40:28 +0000
@@ -216,3 +216,13 @@
216 description: |216 description: |
217 Default multicast port number that will be used to communicate between217 Default multicast port number that will be used to communicate between
218 HA Cluster nodes.218 HA Cluster nodes.
219 action-managed-upgrade:
220 type: boolean
221 default: False
222 description: |
223 If True enables openstack upgrades for this charm via juju actions.
224 You will still need to set openstack-origin to the new repository but
225 instead of an upgrade running automatically across all units, it will
226 wait for you to execute the openstack-upgrade action for this charm on
227 each unit. If False it will revert to existing behavior of upgrading
228 all units on config change.
219229
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-03 09:43:15 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2015-09-23 14:40:28 +0000
@@ -25,6 +25,7 @@
25import re25import re
2626
27import six27import six
28import traceback
28import yaml29import yaml
2930
30from charmhelpers.contrib.network import ip31from charmhelpers.contrib.network import ip
@@ -34,6 +35,8 @@
34)35)
3536
36from charmhelpers.core.hookenv import (37from charmhelpers.core.hookenv import (
38 action_fail,
39 action_set,
37 config,40 config,
38 log as juju_log,41 log as juju_log,
39 charm_dir,42 charm_dir,
@@ -114,6 +117,7 @@
114 ('2.2.1', 'kilo'),117 ('2.2.1', 'kilo'),
115 ('2.2.2', 'kilo'),118 ('2.2.2', 'kilo'),
116 ('2.3.0', 'liberty'),119 ('2.3.0', 'liberty'),
120 ('2.4.0', 'liberty'),
117])121])
118122
119# >= Liberty version->codename mapping123# >= Liberty version->codename mapping
@@ -142,6 +146,9 @@
142 'glance-common': OrderedDict([146 'glance-common': OrderedDict([
143 ('11.0.0', 'liberty'),147 ('11.0.0', 'liberty'),
144 ]),148 ]),
149 'openstack-dashboard': OrderedDict([
150 ('8.0.0', 'liberty'),
151 ]),
145}152}
146153
147DEFAULT_LOOPBACK_SIZE = '5G'154DEFAULT_LOOPBACK_SIZE = '5G'
@@ -745,3 +752,47 @@
745 return projects[key]752 return projects[key]
746753
747 return None754 return None
755
756
757def do_action_openstack_upgrade(package, upgrade_callback, configs):
758 """Perform action-managed OpenStack upgrade.
759
760 Upgrades packages to the configured openstack-origin version and sets
761 the corresponding action status as a result.
762
763 If the charm was installed from source we cannot upgrade it.
764 For backwards compatibility a config flag (action-managed-upgrade) must
765 be set for this code to run, otherwise a full service level upgrade will
766 fire on config-changed.
767
768 @param package: package name for determining if upgrade available
769 @param upgrade_callback: function callback to charm's upgrade function
770 @param configs: templating object derived from OSConfigRenderer class
771
772 @return: True if upgrade successful; False if upgrade failed or skipped
773 """
774 ret = False
775
776 if git_install_requested():
777 action_set({'outcome': 'installed from source, skipped upgrade.'})
778 else:
779 if openstack_upgrade_available(package):
780 if config('action-managed-upgrade'):
781 juju_log('Upgrading OpenStack release')
782
783 try:
784 upgrade_callback(configs=configs)
785 action_set({'outcome': 'success, upgrade completed.'})
786 ret = True
787 except:
788 action_set({'outcome': 'upgrade failed, see traceback.'})
789 action_set({'traceback': traceback.format_exc()})
790 action_fail('do_openstack_upgrade resulted in an '
791 'unexpected error')
792 else:
793 action_set({'outcome': 'action-managed-upgrade config is '
794 'False, skipped upgrade.'})
795 else:
796 action_set({'outcome': 'no upgrade available.'})
797
798 return ret
748799
=== modified file 'hooks/neutron_hooks.py'
--- hooks/neutron_hooks.py 2015-09-22 13:46:41 +0000
+++ hooks/neutron_hooks.py 2015-09-23 14:40:28 +0000
@@ -102,10 +102,9 @@
102 if config_value_changed('openstack-origin-git'):102 if config_value_changed('openstack-origin-git'):
103 git_install(config('openstack-origin-git'))103 git_install(config('openstack-origin-git'))
104 CONFIGS.write_all()104 CONFIGS.write_all()
105 else:105 elif not config('action-managed-upgrade'):
106 if openstack_upgrade_available(get_common_package()):106 if openstack_upgrade_available(get_common_package()):
107 do_openstack_upgrade()107 do_openstack_upgrade(CONFIGS)
108 CONFIGS.write_all()
109108
110 update_nrpe_config()109 update_nrpe_config()
111110
112111
=== modified file 'hooks/neutron_utils.py'
--- hooks/neutron_utils.py 2015-09-10 12:35:59 +0000
+++ hooks/neutron_utils.py 2015-09-23 14:40:28 +0000
@@ -652,7 +652,7 @@
652 return list(set(_services))652 return list(set(_services))
653653
654654
655def do_openstack_upgrade():655def do_openstack_upgrade(configs):
656 """656 """
657 Perform an upgrade. Takes care of upgrading packages, rewriting657 Perform an upgrade. Takes care of upgrading packages, rewriting
658 configs, database migrations and potentially any other post-upgrade658 configs, database migrations and potentially any other post-upgrade
@@ -672,6 +672,7 @@
672 fatal=True, dist=True)672 fatal=True, dist=True)
673 apt_install(get_early_packages(), fatal=True)673 apt_install(get_early_packages(), fatal=True)
674 apt_install(get_packages(), fatal=True)674 apt_install(get_packages(), fatal=True)
675 configs.write_all()
675676
676677
677def configure_ovs():678def configure_ovs():
678679
=== added file 'unit_tests/test_actions_openstack_upgrade.py'
--- unit_tests/test_actions_openstack_upgrade.py 1970-01-01 00:00:00 +0000
+++ unit_tests/test_actions_openstack_upgrade.py 2015-09-23 14:40:28 +0000
@@ -0,0 +1,53 @@
1from mock import patch
2import os
3
4os.environ['JUJU_UNIT_NAME'] = 'neutron-gateway'
5
6with patch('neutron_utils.register_configs') as register_configs:
7 import openstack_upgrade
8
9from test_utils import (
10 CharmTestCase
11)
12
13TO_PATCH = [
14 'do_openstack_upgrade',
15 'config_changed',
16]
17
18
19class TestNeutronGWUpgradeActions(CharmTestCase):
20
21 def setUp(self):
22 super(TestNeutronGWUpgradeActions, self).setUp(openstack_upgrade,
23 TO_PATCH)
24
25 @patch('charmhelpers.contrib.openstack.utils.config')
26 @patch('charmhelpers.contrib.openstack.utils.action_set')
27 @patch('charmhelpers.contrib.openstack.utils.git_install_requested')
28 @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available')
29 def test_openstack_upgrade_true(self, upgrade_avail, git_requested,
30 action_set, config):
31 git_requested.return_value = False
32 upgrade_avail.return_value = True
33 config.return_value = True
34
35 openstack_upgrade.openstack_upgrade()
36
37 self.assertTrue(self.do_openstack_upgrade.called)
38 self.assertTrue(self.config_changed.called)
39
40 @patch('charmhelpers.contrib.openstack.utils.config')
41 @patch('charmhelpers.contrib.openstack.utils.action_set')
42 @patch('charmhelpers.contrib.openstack.utils.git_install_requested')
43 @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available')
44 def test_openstack_upgrade_false(self, upgrade_avail, git_requested,
45 action_set, config):
46 git_requested.return_value = False
47 upgrade_avail.return_value = True
48 config.return_value = False
49
50 openstack_upgrade.openstack_upgrade()
51
52 self.assertFalse(self.do_openstack_upgrade.called)
53 self.assertFalse(self.config_changed.called)
054
=== modified file 'unit_tests/test_neutron_utils.py'
--- unit_tests/test_neutron_utils.py 2015-09-10 12:35:59 +0000
+++ unit_tests/test_neutron_utils.py 2015-09-23 14:40:28 +0000
@@ -244,7 +244,8 @@
244 self.test_config.set('openstack-origin', 'cloud:precise-havana')244 self.test_config.set('openstack-origin', 'cloud:precise-havana')
245 self.test_config.set('plugin', 'ovs')245 self.test_config.set('plugin', 'ovs')
246 self.get_os_codename_install_source.return_value = 'havana'246 self.get_os_codename_install_source.return_value = 'havana'
247 neutron_utils.do_openstack_upgrade()247 configs = neutron_utils.register_configs()
248 neutron_utils.do_openstack_upgrade(configs)
248 self.assertTrue(self.log.called)249 self.assertTrue(self.log.called)
249 self.apt_update.assert_called_with(fatal=True)250 self.apt_update.assert_called_with(fatal=True)
250 dpkg_opts = [251 dpkg_opts = [

Subscribers

People subscribed via source and target branches