Merge lp:~ltrager/maas/lp1519397-1.9 into lp:maas/1.9

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 4513
Proposed branch: lp:~ltrager/maas/lp1519397-1.9
Merge into: lp:maas/1.9
Diff against target: 48 lines (+23/-0)
2 files modified
src/maasserver/models/tests/test_virtualblockdevice.py (+17/-0)
src/maasserver/models/virtualblockdevice.py (+6/-0)
To merge this branch: bzr merge lp:~ltrager/maas/lp1519397-1.9
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+278550@code.launchpad.net

Commit message

Cherry pick from trunk for lp1519397: Don't check empty cache_set filesystem_groups when finding parent devices

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/models/tests/test_virtualblockdevice.py'
--- src/maasserver/models/tests/test_virtualblockdevice.py 2015-11-18 18:14:30 +0000
+++ src/maasserver/models/tests/test_virtualblockdevice.py 2015-11-25 08:27:41 +0000
@@ -20,6 +20,7 @@
2020
21from django.core.exceptions import ValidationError21from django.core.exceptions import ValidationError
22from maasserver.enum import FILESYSTEM_GROUP_TYPE22from maasserver.enum import FILESYSTEM_GROUP_TYPE
23from maasserver.models.blockdevice import MIN_BLOCK_DEVICE_SIZE
23from maasserver.models.virtualblockdevice import VirtualBlockDevice24from maasserver.models.virtualblockdevice import VirtualBlockDevice
24from maasserver.testing.factory import factory25from maasserver.testing.factory import factory
25from maasserver.testing.orm import reload_object26from maasserver.testing.orm import reload_object
@@ -173,3 +174,19 @@
173 virtualblockdevice = node.virtualblockdevice_set.first()174 virtualblockdevice = node.virtualblockdevice_set.first()
174 self.assertEqual(175 self.assertEqual(
175 len(fs_group_disks), len(virtualblockdevice.get_parents()))176 len(fs_group_disks), len(virtualblockdevice.get_parents()))
177
178 def test_get_parents_handles_cache_set(self):
179 # Regression test for lp1519397
180 node = factory.make_Node(with_boot_disk=False)
181 volume_group = factory.make_VolumeGroup(node=node)
182 name = factory.make_name()
183 vguuid = "%s" % uuid4()
184 size = random.randint(MIN_BLOCK_DEVICE_SIZE, volume_group.get_size())
185 logical_volume = volume_group.create_logical_volume(
186 name=name, uuid=vguuid, size=size)
187 logical_volume = reload_object(logical_volume)
188 sdb = factory.make_PhysicalBlockDevice(node=node)
189 factory.make_CacheSet(block_device=sdb, node=node)
190 self.assertItemsEqual(
191 [fs.block_device_id for fs in volume_group.filesystems.all()],
192 [parent.id for parent in logical_volume.get_parents()])
176193
=== modified file 'src/maasserver/models/virtualblockdevice.py'
--- src/maasserver/models/virtualblockdevice.py 2015-11-18 18:14:30 +0000
+++ src/maasserver/models/virtualblockdevice.py 2015-11-25 08:27:41 +0000
@@ -149,6 +149,12 @@
149 elif fs.cache_set is not None:149 elif fs.cache_set is not None:
150 # A block device/partition can only have one cache_set150 # A block device/partition can only have one cache_set
151 fs_group = fs.cache_set.filesystemgroup_set.first()151 fs_group = fs.cache_set.filesystemgroup_set.first()
152 # bcache devices only show up in cache_set.filesystemgroup_set,
153 # not in fs.filesystem_group. However if only a cache_set has
154 # been created and not a bcache device
155 # cache_set.filesystemgroup_set will be empty.
156 if fs_group is None:
157 return False
152 else:158 else:
153 return False159 return False
154 for virtual_device in fs_group.virtual_devices.all():160 for virtual_device in fs_group.virtual_devices.all():

Subscribers

People subscribed via source and target branches