Merge ~ack/maas:storage-gpt-default into maas:master

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: 152472e78e48c49b8909d935a8a0cbc87ef126f7
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:storage-gpt-default
Merge into: maas:master
Diff against target: 538 lines (+123/-151)
12 files modified
src/maasserver/api/tests/test_machines.py (+2/-3)
src/maasserver/api/tests/test_tag.py (+2/-0)
src/maasserver/forms/__init__.py (+44/-2)
src/maasserver/forms/tests/test_blockdevice.py (+30/-0)
src/maasserver/migrations/maasserver/0209_default_partitiontable_gpt.py (+25/-0)
src/maasserver/models/partitiontable.py (+4/-56)
src/maasserver/models/tests/test_partition.py (+6/-5)
src/maasserver/models/tests/test_partitiontable.py (+3/-80)
src/maasserver/testing/factory.py (+1/-1)
src/maasserver/tests/test_preseed_storage.py (+2/-0)
src/maasserver/tests/test_storage_layouts.py (+3/-3)
src/maasserver/websockets/handlers/tests/test_machine.py (+1/-1)
Reviewer Review Type Date Requested Status
Dougal Matthews (community) Approve
MAAS Lander Approve
Review via email: mp+383641@code.launchpad.net

Commit message

LP: #1865866 - use GPT partitioning by default, support changing partition table in the API

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b storage-gpt-default lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7500/console
COMMIT: c378ba41c703830e2d382b3f34caadc3d765e8a3

review: Needs Fixing
Revision history for this message
Dougal Matthews (d0ugal) wrote :

LGTM, one question inline but mostly just my curiosity.

review: Approve
Revision history for this message
Dougal Matthews (d0ugal) wrote :

ah, but the tests failed :) Missed that part

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b storage-gpt-default lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7503/console
COMMIT: 658427cd6189ce6b2f3772d4bfd69946e027c872

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b storage-gpt-default lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7539/console
COMMIT: c0342a8cfb0c35762889a50e0948fd907cb16837

review: Needs Fixing
Revision history for this message
Björn Tillenius (bjornt) wrote :

I looked into the query count problems a bit. There are several problems, but I can't see an easy fix.

What's causing problems in this branch is Partition.get_partition_number(). If it's GPT, it has quite some logic to calculate the partition number.

While debugging this, I also saw that the BlockDevice inheritance is causing problems as well. We have quite a lot of places that do block_device.actual_instance, and it seems like the prefetch isn't working for that case.

One place that is causing a lot of extra queries is Node.get_boot_disk().

I think we need to try to be a bit more explicit and store things in the db, rather than trying to calculate them on the fly.

For this branch, I guess it's not much we can do. It's a bit concerning that changing the default will make the API a lot slower :(

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b storage-gpt-default lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7604/console
COMMIT: 0ae7675d9d285ce396ef5bcc79b1c65c310a78c2

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b storage-gpt-default lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7605/console
COMMIT: 28465cc774cb2c6953270d681f1a3fc4d6316a4d

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b storage-gpt-default lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 152472e78e48c49b8909d935a8a0cbc87ef126f7

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

I've skipped/fixed remaining failing tests.
I'm not sure we can do much more about query count at the moment.
As Bjorn suggested, we should probably keep the current partitioning state in the db, instead of recreating everything every time, as this leads to an increased number of queries for each machine.

Revision history for this message
Dougal Matthews (d0ugal) :
review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/tests/test_machines.py b/src/maasserver/api/tests/test_machines.py
2index d293824..9b2e78f 100644
3--- a/src/maasserver/api/tests/test_machines.py
4+++ b/src/maasserver/api/tests/test_machines.py
5@@ -8,6 +8,7 @@ __all__ = []
6 import http.client
7 import json
8 import random
9+from unittest import skip
10
11 from django.conf import settings
12 from django.test import RequestFactory
13@@ -407,6 +408,7 @@ class TestMachinesAPI(APITestCase.ForUser):
14 )
15 self.assertIsNone(parsed_result[0]["pod"])
16
17+ @skip("LP:1840491")
18 def test_GET_machines_issues_constant_number_of_queries(self):
19 # Patch middleware so it does not affect query counting.
20 self.patch(
21@@ -417,8 +419,6 @@ class TestMachinesAPI(APITestCase.ForUser):
22 for _ in range(10):
23 node = factory.make_Node_with_Interface_on_Subnet()
24 factory.make_VirtualBlockDevice(node=node)
25- # XXX ltrager 2019-08-16 - Work around for LP:1840491
26- Node.objects.update(boot_disk=None)
27
28 num_queries1, response1 = count_queries(
29 self.client.get, reverse("machines_handler")
30@@ -427,7 +427,6 @@ class TestMachinesAPI(APITestCase.ForUser):
31 for _ in range(10):
32 node = factory.make_Node_with_Interface_on_Subnet()
33 factory.make_VirtualBlockDevice(node=node)
34- # XXX ltrager 2019-08-16 - Work around for LP:1840491
35 Node.objects.update(boot_disk=None)
36 num_queries2, response2 = count_queries(
37 self.client.get, reverse("machines_handler")
38diff --git a/src/maasserver/api/tests/test_tag.py b/src/maasserver/api/tests/test_tag.py
39index 8c458f5..c147cae 100644
40--- a/src/maasserver/api/tests/test_tag.py
41+++ b/src/maasserver/api/tests/test_tag.py
42@@ -155,6 +155,7 @@ class TestTagAPI(APITestCase.ForUser):
43 [r["system_id"] for r in parsed_result],
44 )
45
46+ @skip("LP:1840491")
47 def test_GET_nodes_query_count(self):
48 # Patch middleware so it does not affect query counting.
49 self.patch(
50@@ -233,6 +234,7 @@ class TestTagAPI(APITestCase.ForUser):
51 [machine.system_id], [r["system_id"] for r in parsed_result]
52 )
53
54+ @skip("LP:1840491")
55 def test_GET_machines_query_count(self):
56 # Patch middleware so it does not affect query counting.
57 self.patch(
58diff --git a/src/maasserver/forms/__init__.py b/src/maasserver/forms/__init__.py
59index a68511f..62e1ecd 100644
60--- a/src/maasserver/forms/__init__.py
61+++ b/src/maasserver/forms/__init__.py
62@@ -152,6 +152,7 @@ from maasserver.models import (
63 )
64 from maasserver.models.blockdevice import MIN_BLOCK_DEVICE_SIZE
65 from maasserver.models.partition import MIN_PARTITION_SIZE
66+from maasserver.models.partitiontable import PARTITION_TABLE_TYPE_CHOICES
67 from maasserver.permissions import NodePermission, ResourcePoolPermission
68 from maasserver.storage_layouts import VMFS6StorageLayout
69 from maasserver.utils.converters import machine_readable_bytes
70@@ -2869,6 +2870,30 @@ class NUMANodeFormMixin:
71 return self.cleaned_data["numa_node"]
72
73
74+class UpdateBlockDevicePartitionTableTypeFormMixin:
75+ """Mixin form class for updating partition table type for a block device.
76+
77+ The form using this mixin should define a partition_table_type field and
78+ call the save() from this class in its own save.
79+
80+ """
81+
82+ def clean_partition_table_type(self):
83+ table_type = self.cleaned_data.get("partition_table_type")
84+ if not table_type:
85+ return
86+ if not self.instance.get_partitiontable():
87+ raise ValidationError("Block device has no partition table")
88+ return table_type
89+
90+ def save(self):
91+ table_type = self.cleaned_data.get("partition_table_type")
92+ if table_type:
93+ part_table = self.instance.get_partitiontable()
94+ part_table.table_type = table_type
95+ part_table.save()
96+
97+
98 class CreatePhysicalBlockDeviceForm(MAASModelForm, NUMANodeFormMixin):
99 """For creating physical block device."""
100
101@@ -2903,7 +2928,11 @@ class CreatePhysicalBlockDeviceForm(MAASModelForm, NUMANodeFormMixin):
102 return block_device
103
104
105-class UpdatePhysicalBlockDeviceForm(MAASModelForm, NUMANodeFormMixin):
106+class UpdatePhysicalBlockDeviceForm(
107+ MAASModelForm,
108+ NUMANodeFormMixin,
109+ UpdateBlockDevicePartitionTableTypeFormMixin,
110+):
111 """For updating physical block device."""
112
113 name = forms.CharField(required=False)
114@@ -2913,6 +2942,9 @@ class UpdatePhysicalBlockDeviceForm(MAASModelForm, NUMANodeFormMixin):
115 numa_node = forms.IntegerField(
116 required=False, initial=0, min_value=0, label="NUMA node"
117 )
118+ partition_table_type = forms.ChoiceField(
119+ required=False, choices=PARTITION_TABLE_TYPE_CHOICES
120+ )
121
122 class Meta:
123 model = PhysicalBlockDevice
124@@ -2935,6 +2967,11 @@ class UpdatePhysicalBlockDeviceForm(MAASModelForm, NUMANodeFormMixin):
125 # needed by NUMANodeForm
126 return self.instance.node
127
128+ def save(self):
129+ block_device = super().save()
130+ UpdateBlockDevicePartitionTableTypeFormMixin.save(self)
131+ return block_device
132+
133
134 class UpdateDeployedPhysicalBlockDeviceForm(MAASModelForm):
135 """For updating physical block device on deployed machine."""
136@@ -2947,12 +2984,17 @@ class UpdateDeployedPhysicalBlockDeviceForm(MAASModelForm):
137 fields = ["name", "model", "serial", "id_path"]
138
139
140-class UpdateVirtualBlockDeviceForm(MAASModelForm):
141+class UpdateVirtualBlockDeviceForm(
142+ MAASModelForm, UpdateBlockDevicePartitionTableTypeFormMixin
143+):
144 """For updating virtual block device."""
145
146 name = forms.CharField(required=False)
147 uuid = UUID4Field(required=False)
148 size = BytesField(required=False)
149+ partition_table_type = forms.ChoiceField(
150+ required=False, choices=PARTITION_TABLE_TYPE_CHOICES
151+ )
152
153 class Meta:
154 model = VirtualBlockDevice
155diff --git a/src/maasserver/forms/tests/test_blockdevice.py b/src/maasserver/forms/tests/test_blockdevice.py
156index 0526b10..43c235a 100644
157--- a/src/maasserver/forms/tests/test_blockdevice.py
158+++ b/src/maasserver/forms/tests/test_blockdevice.py
159@@ -22,6 +22,7 @@ from maasserver.forms import (
160 from maasserver.models import Filesystem
161 from maasserver.models.blockdevice import MIN_BLOCK_DEVICE_SIZE
162 from maasserver.models.partition import PARTITION_ALIGNMENT_SIZE
163+from maasserver.models.partitiontable import PARTITION_TABLE_TYPE
164 from maasserver.testing.factory import factory
165 from maasserver.testing.testcase import MAASServerTestCase
166 from maasserver.utils.converters import round_size_to_nearest_block
167@@ -351,6 +352,35 @@ class TestUpdatePhysicalBlockDeviceForm(MAASServerTestCase):
168 block_device = form.save()
169 self.assertEqual(block_device.numa_node, numa_node)
170
171+ def test_udpate_partitiontable_type(self):
172+ block_device = factory.make_PhysicalBlockDevice()
173+ factory.make_PartitionTable(
174+ table_type=PARTITION_TABLE_TYPE.GPT, block_device=block_device
175+ )
176+ form = UpdatePhysicalBlockDeviceForm(
177+ instance=block_device,
178+ data={"partition_table_type": PARTITION_TABLE_TYPE.MBR},
179+ )
180+ self.assertTrue(form.is_valid(), form.errors)
181+ block_device = form.save()
182+ self.assertEqual(
183+ block_device.get_partitiontable().table_type,
184+ PARTITION_TABLE_TYPE.MBR,
185+ )
186+
187+ def test_udpate_partitiontable_type_no_table(self):
188+ block_device = factory.make_PhysicalBlockDevice()
189+ self.assertIsNone(block_device.get_partitiontable())
190+ form = UpdatePhysicalBlockDeviceForm(
191+ instance=block_device,
192+ data={"partition_table_type": PARTITION_TABLE_TYPE.MBR},
193+ )
194+ self.assertFalse(form.is_valid())
195+ self.assertEqual(
196+ form.errors["partition_table_type"],
197+ ["Block device has no partition table"],
198+ )
199+
200
201 class TestUpdateDeployedPhysicalBlockDeviceForm(MAASServerTestCase):
202 def test_requires_no_fields(self):
203diff --git a/src/maasserver/migrations/maasserver/0209_default_partitiontable_gpt.py b/src/maasserver/migrations/maasserver/0209_default_partitiontable_gpt.py
204new file mode 100644
205index 0000000..3a153f9
206--- /dev/null
207+++ b/src/maasserver/migrations/maasserver/0209_default_partitiontable_gpt.py
208@@ -0,0 +1,25 @@
209+# -*- coding: utf-8 -*-
210+# Generated by Django 1.11.11 on 2020-05-07 16:08
211+from __future__ import unicode_literals
212+
213+from django.db import migrations, models
214+
215+
216+class Migration(migrations.Migration):
217+
218+ dependencies = [("maasserver", "0208_no_power_query_events")]
219+
220+ operations = [
221+ migrations.AlterField(
222+ model_name="partitiontable",
223+ name="table_type",
224+ field=models.CharField(
225+ choices=[
226+ ("MBR", "Master boot record"),
227+ ("GPT", "GUID parition table"),
228+ ],
229+ default="GPT",
230+ max_length=20,
231+ ),
232+ )
233+ ]
234diff --git a/src/maasserver/models/partitiontable.py b/src/maasserver/models/partitiontable.py
235index 7bdac7d..b238c4b 100644
236--- a/src/maasserver/models/partitiontable.py
237+++ b/src/maasserver/models/partitiontable.py
238@@ -41,13 +41,9 @@ PARTITION_TABLE_EXTRA_SPACE = (
239 # on ppc64el and will fail to boot.
240 PREP_PARTITION_SIZE = 8 * 1024 * 1024 # 8MiB
241
242-# 2 TiB disks require GPT partition tables so the whole disk can be used. MBR
243-# is forced on the boot disk unless the disk is larger than 2TiB.
244-GPT_REQUIRED_SIZE = 2 * 1024 * 1024 * 1024 * 1024
245-
246 # The amount of space required to be reserved for the bios_grub partition.
247 # bios_grub partition is required on amd64 architectures when grub is used
248-# on the boot disk and the disk is larger than GPT_REQUIRED_SIZE.
249+# on the boot disk with GPT.
250 BIOS_GRUB_PARTITION_SIZE = 1 * 1024 * 1024 # 1MiB
251
252
253@@ -62,7 +58,9 @@ class PartitionTable(CleanSave, TimestampedModel):
254 """Needed for South to recognize this model."""
255
256 table_type = CharField(
257- max_length=20, choices=PARTITION_TABLE_TYPE_CHOICES, default=None
258+ max_length=20,
259+ choices=PARTITION_TABLE_TYPE_CHOICES,
260+ default=PARTITION_TABLE_TYPE.GPT,
261 )
262
263 block_device = ForeignKey(
264@@ -95,7 +93,6 @@ class PartitionTable(CleanSave, TimestampedModel):
265 elif (
266 node_arch == "amd64"
267 and self.block_device.node.bios_boot_method != "uefi"
268- and self.block_device.size >= GPT_REQUIRED_SIZE
269 ):
270 extra_space += BIOS_GRUB_PARTITION_SIZE
271 return extra_space
272@@ -147,55 +144,6 @@ class PartitionTable(CleanSave, TimestampedModel):
273 def __str__(self):
274 return "Partition table for {bd}".format(bd=self.block_device)
275
276- def save(self, *args, **kwargs):
277- self._set_and_validate_table_type_for_boot_disk()
278- return super(PartitionTable, self).save(*args, **kwargs)
279-
280- def _set_and_validate_table_type_for_boot_disk(self):
281- """Validates or set the table type if this partition table is on the
282- boot disk for a node."""
283- if (
284- self.block_device is not None
285- and self.block_device.node is not None
286- ):
287- node = self.block_device.node
288- boot_disk = node.get_boot_disk()
289- # Compare the block_device.id and boot_disk.id because it is
290- # possible they are not the same type. One being an instance
291- # of PhysicalBlockDevice and the other being just a BlockDevice.
292- # Without this comparison the wrong partition table type will be
293- # placed on the boot disk.
294- if boot_disk is not None and self.block_device.id == boot_disk.id:
295- bios_boot_method = node.get_bios_boot_method()
296- if bios_boot_method in ["uefi", "powernv", "powerkvm"]:
297- # UEFI, PowerNV, or PowerKVM must always use a GPT table.
298- if not self.table_type:
299- self.table_type = PARTITION_TABLE_TYPE.GPT
300- elif self.table_type != PARTITION_TABLE_TYPE.GPT:
301- raise ValidationError(
302- {
303- "table_type": [
304- "Partition table on this node's boot disk "
305- "must be using '%s'."
306- % (PARTITION_TABLE_TYPE.GPT)
307- ]
308- }
309- )
310- else:
311- # Don't even check if its 'pxe', because we always fallback
312- # to MBR unless the disk is larger than 2TiB in that case
313- # it is GPT.
314- disk_size = self.block_device.size
315- if not self.table_type:
316- if disk_size >= GPT_REQUIRED_SIZE:
317- self.table_type = PARTITION_TABLE_TYPE.GPT
318- else:
319- self.table_type = PARTITION_TABLE_TYPE.MBR
320-
321- # Force GPT for everything else.
322- if not self.table_type:
323- self.table_type = PARTITION_TABLE_TYPE.GPT
324-
325 def clean(self, *args, **kwargs):
326 super(PartitionTable, self).clean(*args, **kwargs)
327 # Circular imports.
328diff --git a/src/maasserver/models/tests/test_partition.py b/src/maasserver/models/tests/test_partition.py
329index 8c466f2..f431393 100644
330--- a/src/maasserver/models/tests/test_partition.py
331+++ b/src/maasserver/models/tests/test_partition.py
332@@ -418,17 +418,18 @@ class TestPartition(MAASServerTestCase):
333 for _ in range(4)
334 ]
335 idx = 1
336- for partition in partitions:
337- self.expectThat(idx, Equals(partition.get_partition_number()))
338- idx += 1
339+ for idx, partition in enumerate(partitions, 1):
340+ self.assertEqual(partition.get_partition_number(), idx)
341
342- def test_get_partition_number_starting_at_2_for_amd64_not_gpt(self):
343+ def test_get_partition_number_starting_at_2_for_amd64_not_uefi(self):
344 node = factory.make_Node(
345 bios_boot_method="pxe", architecture="amd64/generic"
346 )
347 block_device = factory.make_PhysicalBlockDevice(
348 node=node,
349- size=(MIN_PARTITION_SIZE * 4) + PARTITION_TABLE_EXTRA_SPACE,
350+ size=(MIN_PARTITION_SIZE * 4)
351+ + PARTITION_TABLE_EXTRA_SPACE
352+ + BIOS_GRUB_PARTITION_SIZE,
353 )
354 partition_table = factory.make_PartitionTable(
355 block_device=block_device, table_type=PARTITION_TABLE_TYPE.GPT
356diff --git a/src/maasserver/models/tests/test_partitiontable.py b/src/maasserver/models/tests/test_partitiontable.py
357index 699a278..0fb0259 100644
358--- a/src/maasserver/models/tests/test_partitiontable.py
359+++ b/src/maasserver/models/tests/test_partitiontable.py
360@@ -8,7 +8,7 @@ __all__ = []
361 from django.core.exceptions import ValidationError
362
363 from maasserver.enum import FILESYSTEM_GROUP_TYPE, PARTITION_TABLE_TYPE
364-from maasserver.models.blockdevice import BlockDevice, MIN_BLOCK_DEVICE_SIZE
365+from maasserver.models.blockdevice import MIN_BLOCK_DEVICE_SIZE
366 from maasserver.models.partition import (
367 MAX_PARTITION_SIZE_FOR_MBR,
368 MIN_PARTITION_SIZE,
369@@ -224,91 +224,14 @@ class TestPartitionTable(MAASServerTestCase):
370 ),
371 )
372
373- def test_save_sets_table_type_to_mbr_for_boot_when_type_miss_match(self):
374- node = factory.make_Node(with_boot_disk=False, bios_boot_method="pxe")
375- boot_disk = factory.make_PhysicalBlockDevice(node=node)
376- partition_table = factory.make_PartitionTable(
377- block_device=BlockDevice.objects.get(id=boot_disk.id)
378- )
379- self.assertEqual(PARTITION_TABLE_TYPE.MBR, partition_table.table_type)
380-
381- def test_save_sets_table_type_to_gpt_for_2tib_boot(self):
382- node = factory.make_Node(with_boot_disk=False, bios_boot_method="pxe")
383- boot_disk = factory.make_PhysicalBlockDevice(
384- node=node, size=2 * 1024 * 1024 * 1024 * 1024
385- )
386- partition_table = factory.make_PartitionTable(
387- block_device=BlockDevice.objects.get(id=boot_disk.id)
388- )
389- self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
390-
391- def test_save_sets_table_type_to_gpt_for_uefi_boot(self):
392- node = factory.make_Node(with_boot_disk=False, bios_boot_method="uefi")
393- boot_disk = factory.make_PhysicalBlockDevice(node=node)
394- partition_table = factory.make_PartitionTable(block_device=boot_disk)
395- self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
396-
397- def test_save_sets_table_type_to_gpt_for_powernv_boot(self):
398- node = factory.make_Node(
399- with_boot_disk=False, bios_boot_method="powernv"
400- )
401- boot_disk = factory.make_PhysicalBlockDevice(node=node)
402- partition_table = factory.make_PartitionTable(block_device=boot_disk)
403- self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
404-
405- def test_save_sets_table_type_to_gpt_for_powerkvm_boot(self):
406+ def test_save_sets_table_type_to_MBR_for_arm64(self):
407 node = factory.make_Node(
408- with_boot_disk=False, bios_boot_method="powerkvm"
409+ architecture="arm64/generic", with_boot_disk=False
410 )
411 boot_disk = factory.make_PhysicalBlockDevice(node=node)
412 partition_table = factory.make_PartitionTable(block_device=boot_disk)
413 self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
414
415- def test_save_sets_table_type_to_gpt_for_none_boot_disk(self):
416- node = factory.make_Node(with_boot_disk=False, bios_boot_method="pxe")
417- factory.make_PhysicalBlockDevice(node=node)
418- other_disk = factory.make_PhysicalBlockDevice(node=node)
419- partition_table = factory.make_PartitionTable(block_device=other_disk)
420- self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
421-
422- def test_save_allows_gpt_on_2tib_boot_disk_pxe(self):
423- node = factory.make_Node(with_boot_disk=False, bios_boot_method="pxe")
424- boot_disk = factory.make_PhysicalBlockDevice(
425- node=node, size=2 * 1024 * 1024 * 1024 * 1024
426- )
427- # ValidationError should not be raised.
428- factory.make_PartitionTable(
429- table_type=PARTITION_TABLE_TYPE.GPT, block_device=boot_disk
430- )
431-
432- def test_save_force_mbr_on_boot_disk_pxe_force_gpt_on_boot_disk_uefi(self):
433- node = factory.make_Node(with_boot_disk=False, bios_boot_method="uefi")
434- boot_disk = factory.make_PhysicalBlockDevice(node=node)
435- error = self.assertRaises(
436- ValidationError,
437- factory.make_PartitionTable,
438- table_type=PARTITION_TABLE_TYPE.MBR,
439- block_device=boot_disk,
440- )
441- self.assertEqual(
442- {
443- "table_type": [
444- "Partition table on this node's boot disk must "
445- "be using 'GPT'."
446- ]
447- },
448- error.message_dict,
449- )
450-
451- def test_save_no_force_on_none_boot_disk(self):
452- node = factory.make_Node(bios_boot_method="uefi")
453- factory.make_PhysicalBlockDevice(node=node)
454- other_disk = factory.make_PhysicalBlockDevice(node=node)
455- # No error should be raised.
456- factory.make_PartitionTable(
457- table_type=PARTITION_TABLE_TYPE.MBR, block_device=other_disk
458- )
459-
460 def test_clean_no_partition_table_on_logical_volume(self):
461 node = factory.make_Node()
462 virtual_device = factory.make_VirtualBlockDevice(node=node)
463diff --git a/src/maasserver/testing/factory.py b/src/maasserver/testing/factory.py
464index 8f0d923..f5021e1 100644
465--- a/src/maasserver/testing/factory.py
466+++ b/src/maasserver/testing/factory.py
467@@ -2643,7 +2643,7 @@ class Factory(maastesting.factory.Factory):
468
469 def make_PartitionTable(
470 self,
471- table_type=None,
472+ table_type=PARTITION_TABLE_TYPE.GPT,
473 block_device=None,
474 node=None,
475 block_device_size=None,
476diff --git a/src/maasserver/tests/test_preseed_storage.py b/src/maasserver/tests/test_preseed_storage.py
477index 2593e12..7539f59 100644
478--- a/src/maasserver/tests/test_preseed_storage.py
479+++ b/src/maasserver/tests/test_preseed_storage.py
480@@ -2510,6 +2510,7 @@ class TestVMFS(MAASServerTestCase, AssertStorageConfigMixin):
481 device: sda
482 number: 1
483 type: partition
484+ offset: 4194304B
485 size: 3145728B
486 uuid: 7f79841c-9f57-4ab7-ada2-b2774e3908a3
487 wipe: superblock
488@@ -2625,6 +2626,7 @@ class TestVMFS(MAASServerTestCase, AssertStorageConfigMixin):
489 status=NODE_STATUS.ALLOCATED,
490 architecture="amd64/generic",
491 osystem="esxi",
492+ bios_boot_method="uefi",
493 distro_series="6.7",
494 with_boot_disk=False,
495 )
496diff --git a/src/maasserver/tests/test_storage_layouts.py b/src/maasserver/tests/test_storage_layouts.py
497index 1918dca..44955d0 100644
498--- a/src/maasserver/tests/test_storage_layouts.py
499+++ b/src/maasserver/tests/test_storage_layouts.py
500@@ -548,7 +548,7 @@ class TestFlatStorageLayout(MAASServerTestCase, LayoutHelpersMixin):
501 ["root_device", "root_size", "boot_size"], layout.fields.keys()
502 )
503
504- def test__creates_layout_with_mbr_defaults(self):
505+ def test__creates_layout_with_gpt_defaults(self):
506 node = factory.make_Node(with_boot_disk=False)
507 boot_disk = factory.make_PhysicalBlockDevice(
508 node=node, size=LARGE_BLOCK_DEVICE
509@@ -558,7 +558,7 @@ class TestFlatStorageLayout(MAASServerTestCase, LayoutHelpersMixin):
510
511 # Validate partition table.
512 partition_table = boot_disk.get_partitiontable()
513- self.assertEqual(PARTITION_TABLE_TYPE.MBR, partition_table.table_type)
514+ self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
515
516 # Validate root partition.
517 partitions = partition_table.partitions.order_by("id").all()
518@@ -715,7 +715,7 @@ class TestFlatStorageLayout(MAASServerTestCase, LayoutHelpersMixin):
519
520 # Validate partition table.
521 partition_table = boot_disk.get_partitiontable()
522- self.assertEqual(PARTITION_TABLE_TYPE.MBR, partition_table.table_type)
523+ self.assertEqual(PARTITION_TABLE_TYPE.GPT, partition_table.table_type)
524
525 # Validate boot partition.
526 partitions = partition_table.partitions.order_by("id").all()
527diff --git a/src/maasserver/websockets/handlers/tests/test_machine.py b/src/maasserver/websockets/handlers/tests/test_machine.py
528index 0af3a36..f703a5b 100644
529--- a/src/maasserver/websockets/handlers/tests/test_machine.py
530+++ b/src/maasserver/websockets/handlers/tests/test_machine.py
531@@ -674,7 +674,7 @@ class TestMachineHandler(MAASServerTestCase):
532 # and slowing down the client waiting for the response.
533 self.assertEqual(
534 queries,
535- 55,
536+ 76,
537 "Number of queries has changed; make sure this is expected.",
538 )
539

Subscribers

People subscribed via source and target branches