From cdfb1737da21bbb097113a6aaeaae37117038781 Mon Sep 17 00:00:00 2001 From: Alan Meadows Date: Thu, 18 Oct 2018 09:28:11 -0700 Subject: [PATCH] Bugfix Bios Grub Partition Behavior MaaS 2.3.5 added bios grub partition changes that no longer cared for the size of the storage device nor whether it was a boot device. This patch effectively restores the original behavior which was also reintroduced in MaaS 2.4.0. Change-Id: I8b7b38fe42b005a656e6c5cab615c144b6a90b22 --- .../2.3_bios_grub_partition.patch | 23 +++++++++++++++++++ .../2.3_bios_grub_preseed.patch | 22 ++++++++++++++++++ images/maas-region-controller/Dockerfile | 4 ++++ 3 files changed, 49 insertions(+) create mode 100644 images/maas-region-controller/2.3_bios_grub_partition.patch create mode 100644 images/maas-region-controller/2.3_bios_grub_preseed.patch diff --git a/images/maas-region-controller/2.3_bios_grub_partition.patch b/images/maas-region-controller/2.3_bios_grub_partition.patch new file mode 100644 index 0000000..854b0fa --- /dev/null +++ b/images/maas-region-controller/2.3_bios_grub_partition.patch @@ -0,0 +1,23 @@ +--- partition.py 2018-10-18 09:04:40.300721829 -0700 ++++ partition2.py 2018-10-18 09:08:27.952565248 -0700 +@@ -179,6 +179,8 @@ + + def get_partition_number(self): + """Return the partition number in the table.""" ++ # Circular imports. ++ from maasserver.models.partitiontable import GPT_REQUIRED_SIZE + # Sort manually instead of with `order_by`, this will prevent django + # from making a query if the partitions are already cached. + partitions_in_table = self.partition_table.partitions.all() +@@ -196,7 +198,10 @@ + block_device = self.partition_table.block_device + if (arch == "ppc64el" and block_device.id == boot_disk.id): + return idx + 2 +- elif arch == "amd64" and bios_boot_method != "uefi": ++ elif (arch == "amd64" and ++ self.partition_table.block_device.id == boot_disk.id and ++ bios_boot_method != "uefi" and ++ boot_disk.size >= GPT_REQUIRED_SIZE): + return idx + 2 + else: + return idx + 1 diff --git a/images/maas-region-controller/2.3_bios_grub_preseed.patch b/images/maas-region-controller/2.3_bios_grub_preseed.patch new file mode 100644 index 0000000..bbc9db9 --- /dev/null +++ b/images/maas-region-controller/2.3_bios_grub_preseed.patch @@ -0,0 +1,22 @@ +--- preseed_storage.py 2018-10-18 09:09:24.372519602 -0700 ++++ preseed_storage2.py 2018-10-18 09:10:30.112463704 -0700 +@@ -22,6 +22,7 @@ + from maasserver.models.partition import Partition + from maasserver.models.partitiontable import ( + BIOS_GRUB_PARTITION_SIZE, ++ GPT_REQUIRED_SIZE, + INITIAL_PARTITION_OFFSET, + PARTITION_TABLE_EXTRA_SPACE, + PREP_PARTITION_SIZE, +@@ -127,7 +128,10 @@ + """Return True if block device requires the bios_grub partition.""" + arch, _ = self.node.split_arch() + bios_boot_method = self.node.get_bios_boot_method() +- return arch == "amd64" and bios_boot_method != "uefi" ++ return ( ++ arch == "amd64" and ++ bios_boot_method != "uefi" and ++ block_device.size >= GPT_REQUIRED_SIZE) + + def _add_partition_operations(self): + """Add all the partition operations. diff --git a/images/maas-region-controller/Dockerfile b/images/maas-region-controller/Dockerfile index e3174b2..e57b76f 100644 --- a/images/maas-region-controller/Dockerfile +++ b/images/maas-region-controller/Dockerfile @@ -57,9 +57,13 @@ RUN apt-get download maas-region-controller=$MAAS_VERSION && \ COPY 2.3_proxy_port.patch /tmp/2.3_proxy_port.patch COPY 2.3_route.patch /tmp/2.3_route.patch COPY 2.3_kernel_package.patch /tmp/2.3_kernel_package.patch +COPY 2.3_bios_grub_partition.patch /tmp/2.3_bios_grub_partition.patch +COPY 2.3_bios_grub_preseed.patch /tmp/2.3_bios_grub_preseed.patch RUN cd /usr/lib/python3/dist-packages/maasserver && patch compose_preseed.py < /tmp/2.3_proxy_port.patch RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed_network.py < /tmp/2.3_route.patch RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed.py < /tmp/2.3_kernel_package.patch +RUN cd /usr/lib/python3/dist-packages/maasserver/models && patch partition.py < /tmp/2.3_bios_grub_partition.patch +RUN cd /usr/lib/python3/dist-packages/maasserver && patch preseed_storage.py < /tmp/2.3_bios_grub_preseed.patch COPY journalctl-to-tty.service /etc/systemd/system/journalctl-to-tty.service RUN mkdir -p /etc/systemd/system/basic.target.wants ;\