Merge lp:~jason-hobbs/charms/trusty/cinder/force-vgreduce into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by Jason Hobbs
Status: Merged
Approved by: Billy Olsen
Approved revision: no longer in the source branch.
Merged at revision: 108
Proposed branch: lp:~jason-hobbs/charms/trusty/cinder/force-vgreduce
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Prerequisite: lp:~jason-hobbs/charms/trusty/cinder/log-lvm-info
Diff against target: 165 lines (+64/-7)
5 files modified
config.yaml (+7/-0)
hooks/cinder_hooks.py (+2/-1)
hooks/cinder_utils.py (+14/-4)
unit_tests/test_cinder_hooks.py (+17/-2)
unit_tests/test_cinder_utils.py (+24/-0)
To merge this branch: bzr merge lp:~jason-hobbs/charms/trusty/cinder/force-vgreduce
Reviewer Review Type Date Requested Status
Billy Olsen Approve
Corey Bryant (community) Approve
Review via email: mp+265448@code.launchpad.net

Commit message

Add 'remove-missing-force' config option.

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

charm_lint_check #6566 cinder-next for jason-hobbs mp265448
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/11916404/
Build: http://10.245.162.77:8080/job/charm_lint_check/6566/

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

charm_unit_test #6198 cinder-next for jason-hobbs mp265448
    UNIT OK: passed

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

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

charm_amulet_test #5243 cinder-next for jason-hobbs mp265448
    AMULET OK: passed

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

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

Jason, thanks for the code submission! There were some lint errors which need to be corrected and I've also added a few comments inline.

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

Hey Jason, One comment from me below.

107. By Corey Bryant

[jason-hobbs,r=corey.bryant] Add LVM logging when configuring LVM.

Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

> Jason, thanks for the code submission! There were some lint errors which need
> to be corrected and I've also added a few comments inline.

Thanks for the review. I fixed up the lint issues and got rid of the force_reduce_lvm_volume_group_missing(). reduce_lvm_volume_group_missing() now takes an optional list of extra args to pass to vgreduce.

Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

> Hey Jason, One comment from me below.

Thanks Corey. I changed it so that force-remove-missing overrides remove-missing.

Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

All of the review comments have been addressed - this is ready for another look.

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

charm_lint_check #6634 cinder-next for jason-hobbs mp265448
    LINT OK: passed

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

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

charm_unit_test #6261 cinder-next for jason-hobbs mp265448
    UNIT OK: passed

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

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

LGTM. Just want to wait on amulet results to be posted.

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

charm_amulet_test #5264 cinder-next for jason-hobbs mp265448
    AMULET OK: passed

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

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

Ok Amulet passes. Billy, look ok to you?

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

Comment below, not a big enough of an issue to hold up this MP, but I'd like to revisit this in the near future.

review: Approve
108. By Billy Olsen <wolsen@blackwell>

[jason-hobbs,r=corecb,billy-olsen] Add remove-missing-force config option.

Adds an option to force remove physical volumes from a volume group even
when a logical volume is allocated on top of the physical volume.

Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

Thanks Billy - I responded to your comment inline blow.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-07-10 14:14:14 +0000
3+++ config.yaml 2015-07-22 19:16:40 +0000
4@@ -101,6 +101,13 @@
5 description: |
6 If True, charm will attempt to remove missing physical volumes from
7 volume group, if logical volumes are not allocated on them.
8+ remove-missing-force:
9+ default: False
10+ type: boolean
11+ description: |
12+ If True, charm will attempt to remove missing physical volumes from
13+ volume group, even when logical volumes are allocated on them. This
14+ option overrides 'remove-missing' when set.
15 database-user:
16 default: cinder
17 type: string
18
19=== modified file 'hooks/cinder_hooks.py'
20--- hooks/cinder_hooks.py 2015-06-09 09:57:24 +0000
21+++ hooks/cinder_hooks.py 2015-07-22 19:16:40 +0000
22@@ -129,7 +129,8 @@
23 configure_lvm_storage(block_devices,
24 conf['volume-group'],
25 conf['overwrite'] in ['true', 'True', True],
26- conf['remove-missing'])
27+ conf['remove-missing'],
28+ conf['remove-missing-force'])
29
30 if git_install_requested():
31 if config_value_changed('openstack-origin-git'):
32
33=== modified file 'hooks/cinder_utils.py'
34--- hooks/cinder_utils.py 2015-07-22 17:05:42 +0000
35+++ hooks/cinder_utils.py 2015-07-22 19:16:40 +0000
36@@ -333,14 +333,19 @@
37 return list(set(_services))
38
39
40-def reduce_lvm_volume_group_missing(volume_group):
41+def reduce_lvm_volume_group_missing(volume_group, extra_args=None):
42 '''
43 Remove all missing physical volumes from the volume group, if there
44 are no logical volumes allocated on them.
45
46 :param volume_group: str: Name of volume group to reduce.
47+ :param extra_args: list: List of extra args to pass to vgreduce
48 '''
49- subprocess.check_call(['vgreduce', '--removemissing', volume_group])
50+ if extra_args is None:
51+ extra_args = []
52+
53+ command = ['vgreduce', '--removemissing'] + extra_args + [volume_group]
54+ subprocess.check_call(command)
55
56
57 def extend_lvm_volume_group(volume_group, block_device):
58@@ -362,7 +367,7 @@
59
60
61 def configure_lvm_storage(block_devices, volume_group, overwrite=False,
62- remove_missing=False):
63+ remove_missing=False, remove_missing_force=False):
64 ''' Configure LVM storage on the list of block devices provided
65
66 :param block_devices: list: List of whitelisted block devices to detect
67@@ -371,6 +376,9 @@
68 not already in-use
69 :param remove_missing: bool: Remove missing physical volumes from volume
70 group if logical volume not allocated on them
71+ :param remove_missing_force: bool: Remove missing physical volumes from
72+ volume group even if logical volumes are allocated
73+ on them. Overrides 'remove_missing' if set.
74 '''
75 log_lvm_info()
76 devices = []
77@@ -412,7 +420,9 @@
78 new_devices.remove(new_devices[0])
79
80 # Remove missing physical volumes from volume group
81- if remove_missing:
82+ if remove_missing_force:
83+ reduce_lvm_volume_group_missing(volume_group, extra_args=['--force'])
84+ elif remove_missing:
85 reduce_lvm_volume_group_missing(volume_group)
86
87 if len(new_devices) > 0:
88
89=== modified file 'unit_tests/test_cinder_hooks.py'
90--- unit_tests/test_cinder_hooks.py 2015-06-10 21:37:05 +0000
91+++ unit_tests/test_cinder_hooks.py 2015-07-22 19:16:40 +0000
92@@ -156,7 +156,7 @@
93 self.assertTrue(conf_https.called)
94 self.configure_lvm_storage.assert_called_with(['sdb'],
95 'cinder-volumes',
96- False, False)
97+ False, False, False)
98
99 @patch.object(hooks, 'configure_https')
100 @patch.object(hooks, 'git_install_requested')
101@@ -174,7 +174,22 @@
102 self.configure_lvm_storage.assert_called_with(
103 ['sdb', '/dev/sdc', 'sde'],
104 'cinder-new',
105- True, True)
106+ True, True, False)
107+
108+ @patch.object(hooks, 'configure_https')
109+ @patch.object(hooks, 'git_install_requested')
110+ def test_config_changed_uses_remove_missing_force(self, git_requested,
111+ conf_https):
112+ 'It uses the remove-missing-force config option'
113+ git_requested.return_value = False
114+ self.openstack_upgrade_available.return_value = False
115+ self.test_config.set('block-device', 'sdb')
116+ self.test_config.set('remove-missing-force', True)
117+ hooks.hooks.execute(['hooks/config-changed'])
118+ self.configure_lvm_storage.assert_called_with(
119+ ['sdb'],
120+ 'cinder-volumes',
121+ False, False, True)
122
123 @patch.object(hooks, 'configure_https')
124 @patch.object(hooks, 'git_install_requested')
125
126=== modified file 'unit_tests/test_cinder_utils.py'
127--- unit_tests/test_cinder_utils.py 2015-07-21 19:09:36 +0000
128+++ unit_tests/test_cinder_utils.py 2015-07-22 19:16:40 +0000
129@@ -409,12 +409,36 @@
130 self.assertFalse(extend_lvm.called)
131 self.assertFalse(self.create_lvm_volume_group.called)
132
133+ @patch('cinder_utils.log_lvm_info', Mock())
134+ @patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
135+ def test_configure_lvm_storage_unforced_remove_default(self, reduce_lvm):
136+ """It doesn't force remove missing by default."""
137+ devices = ['/dev/vdb']
138+ cinder_utils.configure_lvm_storage(devices, 'test', False, True)
139+ reduce_lvm.assert_called_with('test')
140+
141+ @patch('cinder_utils.log_lvm_info', Mock())
142+ @patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
143+ def test_configure_lvm_storage_force_removemissing(self, reduce_lvm):
144+ """It forces remove missing when asked to."""
145+ devices = ['/dev/vdb']
146+ cinder_utils.configure_lvm_storage(
147+ devices, 'test', False, True, remove_missing_force=True)
148+ reduce_lvm.assert_called_with('test', extra_args=['--force'])
149+
150 @patch('subprocess.check_call')
151 def test_reduce_lvm_volume_group_missing(self, _call):
152 cinder_utils.reduce_lvm_volume_group_missing('test')
153 _call.assert_called_with(['vgreduce', '--removemissing', 'test'])
154
155 @patch('subprocess.check_call')
156+ def test_reduce_lvm_volume_group_missing_extra_args(self, _call):
157+ cinder_utils.reduce_lvm_volume_group_missing(
158+ 'test', extra_args=['--arg'])
159+ expected_call_args = ['vgreduce', '--removemissing', '--arg', 'test']
160+ _call.assert_called_with(expected_call_args)
161+
162+ @patch('subprocess.check_call')
163 def test_extend_lvm_volume_group(self, _call):
164 cinder_utils.extend_lvm_volume_group('test', '/dev/sdb')
165 _call.assert_called_with(['vgextend', 'test', '/dev/sdb'])

Subscribers

People subscribed via source and target branches