Merge ~ltrager/maas:lp1813019 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 980821c6f8cc3c80549fdcc17e4dc646f273ee0d
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1813019
Merge into: maas:master
Diff against target: 120 lines (+50/-2)
3 files modified
src/maasserver/storage_layouts.py (+15/-0)
src/maasserver/testing/sampledata.py (+5/-2)
src/maasserver/tests/test_storage_layouts.py (+30/-0)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Blake Rouse (community) Approve
Review via email: mp+365617@code.launchpad.net

Commit message

LP: #1813019 - Add a blank storage layout.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

There is no such thing as a empty storage layout. So there should be an api operation to clear the storage whatever that is, not a layout because the lack of storage config means there is no layout

review: Disapprove
Revision history for this message
Lee Trager (ltrager) wrote :

In the bug report the user is asking for an easy way to clear the storage layout so they can apply their own custom storage layout using the API. During discussing of the updated storage layout this was mentioned and added to the new design[1] which is currently being implemented.

[1] https://app.zeplin.io/project/5c814428fe915cbc9cf6ccfa/screen/5c94d39579d02b35ea051b7c

Revision history for this message
Andres Rodriguez (andreserl) wrote :

There is no such thing as a empty storage layout. So there should be an api operation to clear the storage whatever that is, not a layout because the lack of storage config means there is no layout

review: Disapprove
Revision history for this message
Lee Trager (ltrager) wrote :

As discussed during SU I've renamed this from empty to blank. Users can apply the layout with the existing set-storage-layout and the websocket call. Users may also set the global configuration option, default_storage_layout, to blank if they wish however the default remains flat.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Lgtm!

Comment inline before landing

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
Andres Rodriguez (andreserl) wrote :

From your latest change... why this hasn't been an issue and it is now? Why does this require 100GB disks on sampledata when it dind't before?

review: Needs Information
Revision history for this message
Lee Trager (ltrager) wrote :

VMFS6 requires at least 10G of space. In the VMFS6 review I upped LARGE_BLOCK_DEVICE to 100GB in maasserver.tests.test_storage_layouts to ensure unit tests pass. sampledata uses factory.make_PhysicalBlockDevice which allows a disk to be created as small as 64MB. This caused intermittent fails such as 5491 as well as cause make sampledata to fail.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

That's not my question though. Why did this test not fail before and it is now failing, when this branch is simply dealing with a Blank layout?

review: Needs Information
Revision history for this message
Lee Trager (ltrager) wrote :

Before the random number generator happened to create a value big enough for tests to pass. The failure in 5491 happened because it generated a number to small. If you look at the stack trace in 5491 you can see its failing in the VMFS6Layout.clean(). I could remove that fix and keep trying to land until it generates a large enough number but we'd still have the same problem.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good to me.

Thanks for fixing the sampledata, that failing was getting annoying.

review: Approve
Revision history for this message
Andres Rodriguez (andreserl) wrote :

The right fix should really be creating a disk for the specific tests rather than absolutely everything, because that gives good flexibility when testing other stuff and allows us to find issues elsewhere.

I'm not gonna block this landing on that but I would much rather prefer we raise the storage for just the esxi side.

review: Approve
Revision history for this message
Lee Trager (ltrager) wrote :

The way sampledata works is it creates a number of nodes with 1-5 disks attached to each. Once the node is created it then applies a randomly selected storage_layout. We don't know which layout until the node and disks are created. So the only way we can raise the minimium disk size just for VMFS datastores is by trying it and when it fails recreating the disks with a larger size.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/storage_layouts.py b/src/maasserver/storage_layouts.py
index 475c9ff..2bb5b34 100644
--- a/src/maasserver/storage_layouts.py
+++ b/src/maasserver/storage_layouts.py
@@ -605,12 +605,27 @@ class VMFS6Layout(StorageLayoutBase):
605 return "VMFS6"605 return "VMFS6"
606606
607607
608class BlankStorageLayout(StorageLayoutBase):
609 """Blank layout.
610
611 This layout ensures no disk is configured with any partition table or
612 filesystem. This helps users who want to have a custom storage layout
613 not based on any existing layout.
614 """
615
616 def configure_storage(self, allow_fallback):
617 # StorageLayoutBase has the code to ensure nothing is configured.
618 # Once that is done there is nothing left for us to do.
619 return "blank"
620
621
608# Holds all the storage layouts that can be used.622# Holds all the storage layouts that can be used.
609STORAGE_LAYOUTS = {623STORAGE_LAYOUTS = {
610 "flat": ("Flat layout", FlatStorageLayout),624 "flat": ("Flat layout", FlatStorageLayout),
611 "lvm": ("LVM layout", LVMStorageLayout),625 "lvm": ("LVM layout", LVMStorageLayout),
612 "bcache": ("Bcache layout", BcacheStorageLayout),626 "bcache": ("Bcache layout", BcacheStorageLayout),
613 "vmfs6": ("VMFS6 layout", VMFS6Layout),627 "vmfs6": ("VMFS6 layout", VMFS6Layout),
628 "blank": ("No storage (blank) layout", BlankStorageLayout),
614 }629 }
615630
616631
diff --git a/src/maasserver/testing/sampledata.py b/src/maasserver/testing/sampledata.py
index 62f3e1c..285212a 100644
--- a/src/maasserver/testing/sampledata.py
+++ b/src/maasserver/testing/sampledata.py
@@ -1,4 +1,4 @@
1# Copyright 2016-2017 Canonical Ltd. This software is licensed under the1# Copyright 2016-2019 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Construct sample application data dynamically."""4"""Construct sample application data dynamically."""
@@ -30,6 +30,7 @@ from maasserver.models import (
30)30)
31from maasserver.storage_layouts import STORAGE_LAYOUTS31from maasserver.storage_layouts import STORAGE_LAYOUTS
32from maasserver.testing.factory import factory32from maasserver.testing.factory import factory
33from maasserver.tests.test_storage_layouts import LARGE_BLOCK_DEVICE
33from maasserver.utils.orm import (34from maasserver.utils.orm import (
34 get_one,35 get_one,
35 transactional,36 transactional,
@@ -437,7 +438,9 @@ def populate_main():
437438
438 # Add random storage devices and set a random layout.439 # Add random storage devices and set a random layout.
439 for _ in range(random.randint(1, 5)):440 for _ in range(random.randint(1, 5)):
440 factory.make_PhysicalBlockDevice(node=machine)441 factory.make_PhysicalBlockDevice(
442 node=machine, size=random.randint(
443 LARGE_BLOCK_DEVICE, LARGE_BLOCK_DEVICE * 10))
441 if status in [444 if status in [
442 NODE_STATUS.READY,445 NODE_STATUS.READY,
443 NODE_STATUS.ALLOCATED,446 NODE_STATUS.ALLOCATED,
diff --git a/src/maasserver/tests/test_storage_layouts.py b/src/maasserver/tests/test_storage_layouts.py
index 4fcd911..ef2df86 100644
--- a/src/maasserver/tests/test_storage_layouts.py
+++ b/src/maasserver/tests/test_storage_layouts.py
@@ -24,6 +24,7 @@ from maasserver.models.partitiontable import (
24from maasserver.storage_layouts import (24from maasserver.storage_layouts import (
25 BcacheStorageLayout,25 BcacheStorageLayout,
26 BcacheStorageLayoutBase,26 BcacheStorageLayoutBase,
27 BlankStorageLayout,
27 calculate_size_from_percentage,28 calculate_size_from_percentage,
28 EFI_PARTITION_SIZE,29 EFI_PARTITION_SIZE,
29 FlatStorageLayout,30 FlatStorageLayout,
@@ -33,6 +34,7 @@ from maasserver.storage_layouts import (
33 LVMStorageLayout,34 LVMStorageLayout,
34 MIN_BOOT_PARTITION_SIZE,35 MIN_BOOT_PARTITION_SIZE,
35 MIN_ROOT_PARTITION_SIZE,36 MIN_ROOT_PARTITION_SIZE,
37 STORAGE_LAYOUTS,
36 StorageLayoutBase,38 StorageLayoutBase,
37 StorageLayoutFieldsError,39 StorageLayoutFieldsError,
38 StorageLayoutForm,40 StorageLayoutForm,
@@ -84,6 +86,7 @@ class TestFormHelpers(MAASServerTestCase):
84 ("lvm", "LVM layout"),86 ("lvm", "LVM layout"),
85 ("bcache", "Bcache layout"),87 ("bcache", "Bcache layout"),
86 ("vmfs6", "VMFS6 layout"),88 ("vmfs6", "VMFS6 layout"),
89 ('blank', 'No storage (blank) layout'),
87 ], get_storage_layout_choices())90 ], get_storage_layout_choices())
8891
89 def test_get_storage_layout_for_node(self):92 def test_get_storage_layout_for_node(self):
@@ -1648,3 +1651,30 @@ class TestVMFS6Layout(MAASServerTestCase):
1648 self.assertEqual({1651 self.assertEqual({
1649 "size": ["Boot disk must be atleast 10G."],1652 "size": ["Boot disk must be atleast 10G."],
1650 }, error.message_dict)1653 }, error.message_dict)
1654
1655
1656class TestBlankStorageLayout(MAASServerTestCase):
1657
1658 def __init__(self, *args, **kwargs):
1659 # Make sure any existing storage layout can be cleared.
1660 self.scenarios = [
1661 (layout_name, {'layout_class': layout_class})
1662 for layout_name, layout_class in STORAGE_LAYOUTS.values()
1663 ]
1664 super().__init__(*args, **kwargs)
1665
1666 def test__creates_blank_layout(self):
1667 node = factory.make_Node(with_boot_disk=False)
1668 for _ in range(5):
1669 factory.make_PhysicalBlockDevice(
1670 node=node, size=LARGE_BLOCK_DEVICE)
1671 # Apply another layout to test clearing it
1672 other_layout = self.layout_class(node)
1673 other_layout.configure()
1674
1675 layout = BlankStorageLayout(node)
1676 self.assertEquals("blank", layout.configure())
1677 self.assertFalse(node.virtualblockdevice_set.exists())
1678 for bd in node.blockdevice_set.all():
1679 self.assertFalse(bd.filesystem_set.exists())
1680 self.assertFalse(bd.partitiontable_set.exists())

Subscribers

People subscribed via source and target branches