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
1diff --git a/src/maasserver/storage_layouts.py b/src/maasserver/storage_layouts.py
2index 475c9ff..2bb5b34 100644
3--- a/src/maasserver/storage_layouts.py
4+++ b/src/maasserver/storage_layouts.py
5@@ -605,12 +605,27 @@ class VMFS6Layout(StorageLayoutBase):
6 return "VMFS6"
7
8
9+class BlankStorageLayout(StorageLayoutBase):
10+ """Blank layout.
11+
12+ This layout ensures no disk is configured with any partition table or
13+ filesystem. This helps users who want to have a custom storage layout
14+ not based on any existing layout.
15+ """
16+
17+ def configure_storage(self, allow_fallback):
18+ # StorageLayoutBase has the code to ensure nothing is configured.
19+ # Once that is done there is nothing left for us to do.
20+ return "blank"
21+
22+
23 # Holds all the storage layouts that can be used.
24 STORAGE_LAYOUTS = {
25 "flat": ("Flat layout", FlatStorageLayout),
26 "lvm": ("LVM layout", LVMStorageLayout),
27 "bcache": ("Bcache layout", BcacheStorageLayout),
28 "vmfs6": ("VMFS6 layout", VMFS6Layout),
29+ "blank": ("No storage (blank) layout", BlankStorageLayout),
30 }
31
32
33diff --git a/src/maasserver/testing/sampledata.py b/src/maasserver/testing/sampledata.py
34index 62f3e1c..285212a 100644
35--- a/src/maasserver/testing/sampledata.py
36+++ b/src/maasserver/testing/sampledata.py
37@@ -1,4 +1,4 @@
38-# Copyright 2016-2017 Canonical Ltd. This software is licensed under the
39+# Copyright 2016-2019 Canonical Ltd. This software is licensed under the
40 # GNU Affero General Public License version 3 (see the file LICENSE).
41
42 """Construct sample application data dynamically."""
43@@ -30,6 +30,7 @@ from maasserver.models import (
44 )
45 from maasserver.storage_layouts import STORAGE_LAYOUTS
46 from maasserver.testing.factory import factory
47+from maasserver.tests.test_storage_layouts import LARGE_BLOCK_DEVICE
48 from maasserver.utils.orm import (
49 get_one,
50 transactional,
51@@ -437,7 +438,9 @@ def populate_main():
52
53 # Add random storage devices and set a random layout.
54 for _ in range(random.randint(1, 5)):
55- factory.make_PhysicalBlockDevice(node=machine)
56+ factory.make_PhysicalBlockDevice(
57+ node=machine, size=random.randint(
58+ LARGE_BLOCK_DEVICE, LARGE_BLOCK_DEVICE * 10))
59 if status in [
60 NODE_STATUS.READY,
61 NODE_STATUS.ALLOCATED,
62diff --git a/src/maasserver/tests/test_storage_layouts.py b/src/maasserver/tests/test_storage_layouts.py
63index 4fcd911..ef2df86 100644
64--- a/src/maasserver/tests/test_storage_layouts.py
65+++ b/src/maasserver/tests/test_storage_layouts.py
66@@ -24,6 +24,7 @@ from maasserver.models.partitiontable import (
67 from maasserver.storage_layouts import (
68 BcacheStorageLayout,
69 BcacheStorageLayoutBase,
70+ BlankStorageLayout,
71 calculate_size_from_percentage,
72 EFI_PARTITION_SIZE,
73 FlatStorageLayout,
74@@ -33,6 +34,7 @@ from maasserver.storage_layouts import (
75 LVMStorageLayout,
76 MIN_BOOT_PARTITION_SIZE,
77 MIN_ROOT_PARTITION_SIZE,
78+ STORAGE_LAYOUTS,
79 StorageLayoutBase,
80 StorageLayoutFieldsError,
81 StorageLayoutForm,
82@@ -84,6 +86,7 @@ class TestFormHelpers(MAASServerTestCase):
83 ("lvm", "LVM layout"),
84 ("bcache", "Bcache layout"),
85 ("vmfs6", "VMFS6 layout"),
86+ ('blank', 'No storage (blank) layout'),
87 ], get_storage_layout_choices())
88
89 def test_get_storage_layout_for_node(self):
90@@ -1648,3 +1651,30 @@ class TestVMFS6Layout(MAASServerTestCase):
91 self.assertEqual({
92 "size": ["Boot disk must be atleast 10G."],
93 }, error.message_dict)
94+
95+
96+class TestBlankStorageLayout(MAASServerTestCase):
97+
98+ def __init__(self, *args, **kwargs):
99+ # Make sure any existing storage layout can be cleared.
100+ self.scenarios = [
101+ (layout_name, {'layout_class': layout_class})
102+ for layout_name, layout_class in STORAGE_LAYOUTS.values()
103+ ]
104+ super().__init__(*args, **kwargs)
105+
106+ def test__creates_blank_layout(self):
107+ node = factory.make_Node(with_boot_disk=False)
108+ for _ in range(5):
109+ factory.make_PhysicalBlockDevice(
110+ node=node, size=LARGE_BLOCK_DEVICE)
111+ # Apply another layout to test clearing it
112+ other_layout = self.layout_class(node)
113+ other_layout.configure()
114+
115+ layout = BlankStorageLayout(node)
116+ self.assertEquals("blank", layout.configure())
117+ self.assertFalse(node.virtualblockdevice_set.exists())
118+ for bd in node.blockdevice_set.all():
119+ self.assertFalse(bd.filesystem_set.exists())
120+ self.assertFalse(bd.partitiontable_set.exists())

Subscribers

People subscribed via source and target branches