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

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

Description of the change

Add action managed upgrades of OpenStack

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

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/

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

charm_unit_test #9160 openstack-dashboard-next for thedac mp271027
    UNIT OK: passed

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

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

charm_amulet_test #6425 openstack-dashboard-next for thedac mp271027
    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/12412383/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6425/

86. By David Ames

Add tests for action managed upgrade

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

charm_lint_check #10062 openstack-dashboard-next for thedac mp271027
    LINT OK: passed

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

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

charm_unit_test #9229 openstack-dashboard-next for thedac mp271027
    UNIT OK: passed

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

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

charm_amulet_test #6448 openstack-dashboard-next for thedac mp271027
    AMULET OK: passed

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

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Hey David, inline comment below.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Response to my initial comment inline.h

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

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

Agreed. Calling config_changed() on successful upgrade.

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

charm_unit_test #9613 openstack-dashboard-next for thedac mp271027
    UNIT OK: passed

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

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

charm_lint_check #10424 openstack-dashboard-next for thedac mp271027
    LINT OK: passed

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

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

charm_amulet_test #6569 openstack-dashboard-next for thedac mp271027
    AMULET OK: passed

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

Revision history for this message
Billy Olsen (billy-olsen) wrote :

David, added an inline comment below. Minor fix and it should be good to go.

review: Needs Fixing
89. 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 #10574 openstack-dashboard-next for thedac mp271027
    LINT OK: passed

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

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

charm_unit_test #9761 openstack-dashboard-next for thedac mp271027
    UNIT OK: passed

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

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 #6706 openstack-dashboard-next for thedac mp271027
    AMULET OK: passed

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

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-07 13:58:41 +0000
+++ actions.yaml 2015-09-23 14:38:13 +0000
@@ -1,2 +1,4 @@
1git-reinstall:1git-reinstall:
2 description: Reinstall openstack-dashboard from the openstack-origin-git repositories.2 description: Reinstall openstack-dashboard 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:38:13 +0000
@@ -0,0 +1,34 @@
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 horizon_utils import (
11 do_openstack_upgrade,
12)
13
14from horizon_hooks import (
15 config_changed,
16 CONFIGS,
17)
18
19
20def openstack_upgrade():
21 """Upgrade packages to config-set Openstack version.
22
23 If the charm was installed from source we cannot upgrade it.
24 For backwards compatibility a config flag must be set for this
25 code to run, otherwise a full service level upgrade will fire
26 on config-changed."""
27
28 if do_action_openstack_upgrade('openstack-dashboard',
29 do_openstack_upgrade,
30 CONFIGS):
31 config_changed()
32
33if __name__ == '__main__':
34 openstack_upgrade()
035
=== modified file 'config.yaml'
--- config.yaml 2015-07-10 14:18:48 +0000
+++ config.yaml 2015-09-23 14:38:13 +0000
@@ -175,4 +175,13 @@
175 description: |175 description: |
176 A comma-separated list of nagios servicegroups. If left empty, the176 A comma-separated list of nagios servicegroups. If left empty, the
177 nagios_context will be used as the servicegroup.177 nagios_context will be used as the servicegroup.
178178 action-managed-upgrade:
179 type: boolean
180 default: False
181 description: |
182 If True enables openstack upgrades for this charm via juju actions.
183 You will still need to set openstack-origin to the new repository but
184 instead of an upgrade running automatically across all units, it will
185 wait for you to execute the openstack-upgrade action for this charm on
186 each unit. If False it will revert to existing behavior of upgrading
187 all units on config change.
179188
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-04 13:59:26 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2015-09-23 14:38:13 +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
@@ -748,3 +752,47 @@
748 return projects[key]752 return projects[key]
749753
750 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
751799
=== modified file 'hooks/horizon_hooks.py'
--- hooks/horizon_hooks.py 2015-09-23 08:07:40 +0000
+++ hooks/horizon_hooks.py 2015-09-23 14:38:13 +0000
@@ -104,7 +104,7 @@
104 if git_install_requested():104 if git_install_requested():
105 if config_value_changed('openstack-origin-git'):105 if config_value_changed('openstack-origin-git'):
106 git_install(config('openstack-origin-git'))106 git_install(config('openstack-origin-git'))
107 else:107 elif not config('action-managed-upgrade'):
108 if openstack_upgrade_available('openstack-dashboard'):108 if openstack_upgrade_available('openstack-dashboard'):
109 do_openstack_upgrade(configs=CONFIGS)109 do_openstack_upgrade(configs=CONFIGS)
110110
111111
=== 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:38:13 +0000
@@ -0,0 +1,53 @@
1from mock import patch
2import os
3
4os.environ['JUJU_UNIT_NAME'] = 'openstack-dashboard'
5
6with patch('horizon_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 TestHorizonUpgradeActions(CharmTestCase):
20
21 def setUp(self):
22 super(TestHorizonUpgradeActions, 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)

Subscribers

People subscribed via source and target branches