From a351d51b843d5ba7be7be496c6dfb1719193534f Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Sun, 3 May 2020 01:43:49 +0000 Subject: [PATCH] maas-region patch: PartitionTable does not exist An API request for the list of partitions associated with a block device should simply return an empty list if there are no partitions. Instead, we get an maasserver.models.partitiontable.DoesNotExist exception. This patch allows the API server to respond correctly. Before: maas admin partitions read x76dma 9 PartitionTable matching query does not exist. After: maas admin partitions read x76dma 9 Success. Machine-readable output follows: [] Reference: https://old-docs.maas.io/2.3/en/api#get-api20nodessystem_idblockdevicesdevice_idpartitions Change-Id: I427a17686e257bbcc89843dead60f297b4903489 --- .../2.3_partitiontable_does_not_exist.patch | 13 +++++++++++++ images/maas-region-controller/Dockerfile | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 images/maas-region-controller/2.3_partitiontable_does_not_exist.patch diff --git a/images/maas-region-controller/2.3_partitiontable_does_not_exist.patch b/images/maas-region-controller/2.3_partitiontable_does_not_exist.patch new file mode 100644 index 0000000..3acb0ae --- /dev/null +++ b/images/maas-region-controller/2.3_partitiontable_does_not_exist.patch @@ -0,0 +1,13 @@ +diff --git a/src/maasserver/api/partitions.py b/src/maasserver/api/partitions.py +index fb75600a8..f03fc5685 100644 +--- a/src/maasserver/api/partitions.py ++++ b/src/maasserver/api/partitions.py +@@ -89,7 +89,7 @@ class PartitionsHandler(OperationsHandler): + """ + device = BlockDevice.objects.get_block_device_or_404( + system_id, device_id, request.user, NODE_PERMISSION.VIEW) +- partition_table = device.partitiontable_set.get() ++ partition_table = device.get_partitiontable() + if partition_table is None: + return [] + else: diff --git a/images/maas-region-controller/Dockerfile b/images/maas-region-controller/Dockerfile index 1d992f9..104fd79 100644 --- a/images/maas-region-controller/Dockerfile +++ b/images/maas-region-controller/Dockerfile @@ -79,6 +79,7 @@ COPY 2.3_proxy_acl.patch /tmp/2.3_proxy_acl.patch copy 2.3_configure_ipmi_user.patch /tmp/2.3_configure_ipmi_user.patch COPY 2.3_secure_headers.patch /tmp/2.3_secure_headers.patch COPY 2.3_region_secret_rotate.patch /tmp/2.3_region_secret_rotate.patch +COPY 2.3_partitiontable_does_not_exist.patch /tmp/2.3_partitiontable_does_not_exist.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 @@ -90,6 +91,7 @@ RUN cd /usr/lib/python3/dist-packages/metadataserver/user_data/templates/snippet RUN cd /usr/lib/python3/dist-packages/provisioningserver/utils && patch ipaddr.py < /tmp/2.3_mac_address.patch RUN cd /usr/lib/python3/dist-packages/provisioningserver/templates/proxy && patch maas-proxy.conf.template < /tmp/2.3_proxy_acl.patch RUN cd /usr/lib/python3/dist-packages/twisted/web && patch server.py < /tmp/2.3_secure_headers.patch +RUN cd /usr/lib/python3/dist-packages/maasserver/api && patch partitions.py < /tmp/2.3_partitiontable_does_not_exist.patch COPY journalctl-to-tty.service /etc/systemd/system/journalctl-to-tty.service