MAAS 3.0 incorrectly calculates the amount of free space on drive

Bug #1938296 reported by Eric Desrochers
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Alberto Donato
3.0
Fix Released
High
Alberto Donato
3.1
Fix Released
High
Alberto Donato
3.2
Fix Released
High
Alberto Donato

Bug Description

It has been brought to my attention the following:

"
When doing custom partitioning in MaaS, attempt to add a new partition using the max free space the GUI presents and simply click on next. MaaS will say there is not enough free space on the drive, however lowering the partition size will rectify this issue.

I was able to reproduce the issue using a software raid setup.

In focal/MaaS 3.0 when attempting to add a partition to a software raid drive through the MaaS GUI using the full amount of disk space, the GUI will display an error indicating that

Error:Partition cannot be saved; not enough free space on the block device.

Simply lowering the partition size from something like 42.93 to 42.92 will rectify the issue.

This can be reproduced by adding a VM with two disks, choosing a blank storage layout, adding the two disks to a raid setup, and attempting to click Add Partition to the mdx device
"

Related branches

Eric Desrochers (slashd)
tags: added: seg sts
Revision history for this message
Eric Desrochers (slashd) wrote :

According to the 'ERROR' mentioned above, the code is raising a validationerror exception:

File: src/maasserver/models/partition.py
Function: _validate_enough_space()

https://git.launchpad.net/maas/tree/src/maasserver/models/partition.py#n294

It then enters two statement that look if available_size is lower than self.size and adjusted_size.

    301 if available_size < self.size:
    302 # Adjust the size by one block down to see if it will fit.
    303 # This is a nice to have because we don't want to block
    304 # users from saving partitions if the size is only a one
    305 # block off.
    306 adjusted_size = self.size - self.get_block_size()
    307 if available_size < adjusted_size:

As a debug exercise, we probably should check if available_size, self.size and adjusted_size are calculated properly.

Revision history for this message
Eric Desrochers (slashd) wrote :

More information coming from a colleague of mine:

In testing this on 3.0
1) When VM created with UEFI/OVMF firmware and has two GPT drives raided together, the error is reproduced
2) When VM created with BIOS firmware and has two MBR drives raided together the error is not reproduced

Sample output:
In scenario 1) the total block size of the md0 device is 42.93 GB. When attempting to add a partition, it does not round down to 42.92GB and instead uses 42.93GB which results in "Partition cannot be saved; not enough free space on the block device" error

In scenario 2) total block size o md0 device is 32.19 GB and when attempting to add a partition it rounds down to 32.18 GB

Changed in maas:
status: New → Triaged
Changed in maas:
importance: Undecided → High
Revision history for this message
Heather Lemon (hypothetical-lemon) wrote :
Download full text (3.9 KiB)

stacktrace from regiond.log

stacktrace from regiond.log

2021-10-12 17:36:59 maasserver.websockets.protocol: [critical] Error on request (17) machine.create_partition: {"size": ["Partition cannot be saved; not enough free space on the block device."]}
    Traceback (most recent call last):
      File "/usr/lib/python3.8/threading.py", line 870, in run
        self._target(*self._args, **self._kwargs)
      File "/snap/maas/15003/lib/python3.8/site-packages/provisioningserver/utils/twisted.py", line 835, in worker
        return target()
      File "/snap/maas/15003/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
        task()
      File "/snap/maas/15003/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
        task()
    --- <exception caught here> ---
      File "/snap/maas/15003/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 250, in inContext
        result = inContext.theWork()
      File "/snap/maas/15003/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
        inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
      File "/snap/maas/15003/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/snap/maas/15003/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
        return func(*args,**kw)
      File "/snap/maas/15003/lib/python3.8/site-packages/provisioningserver/utils/twisted.py", line 870, in callInContext
        return func(*args, **kwargs)
      File "/snap/maas/15003/lib/python3.8/site-packages/provisioningserver/utils/twisted.py", line 202, in wrapper
        result = func(*args, **kwargs)
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/utils/orm.py", line 751, in call_within_transaction
        return func_outside_txn(*args, **kwargs)
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/utils/orm.py", line 554, in retrier
        return func(*args, **kwargs)
      File "/usr/lib/python3.8/contextlib.py", line 75, in inner
        return func(*args, **kwds)
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/websockets/base.py", line 402, in prep_user_execute
        return self._call_method_track_queries(
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/websockets/base.py", line 426, in _call_method_track_queries
        result = method(params)
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/websockets/handlers/machine.py", line 760, in create_partition
        partition = form.save()
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/forms/__init__.py", line 2755, in save
        return partition_table.add_partition(
      File "/snap/maas/15003/lib/python3.8/site-packages/maasserver/models/partitiontable.py", line 139, in add_partition
        return Partition.objects.create(
      File "/snap/maas/15003/usr/lib/python3/dist-packages/django/db/models/manager.py", line 82, in manager_method
        return getattr(self.get_queryset(), nam...

Read more...

Revision history for this message
Heather Lemon (hypothetical-lemon) wrote :

raid error video, use VLC to view

Changed in maas:
assignee: nobody → Alexsander de Souza (alexsander-souza)
Changed in maas:
status: Triaged → In Progress
Changed in maas:
milestone: none → next
status: In Progress → Fix Committed
Revision history for this message
Heather Lemon (hypothetical-lemon) wrote :

Will this fix be backported to 3.0?

Changed in maas:
milestone: next → 3.2.0-beta1
Changed in maas:
status: Fix Committed → Fix Released
Revision history for this message
Heather Lemon (hypothetical-lemon) wrote :

Please add this bug to the MAAS 3.0.1 milestone.

Revision history for this message
Anton Troyanov (troyanov) wrote :

After some discussions, the decision was made to revert the fix. We will also take this particular issue onto our backlog, as the proper fix may affect the UI and API in non-trivial ways.

Changed in maas:
assignee: Alexsander de Souza (alexsander-souza) → nobody
status: Fix Released → New
milestone: 3.2.0-beta1 → 3.3.0
Changed in maas:
status: New → Triaged
Revision history for this message
Adam Collard (adam-collard) wrote :

LP:1981536 was the reason this change was reverted

tags: added: bug-council
Revision history for this message
Adam Collard (adam-collard) wrote :

Let's have another stab at fixing this - investigate reserving space for a partition table with a small headroom (~100Mb) when calculating free space. Please be mindful of regressing bug 1981536.

summary: - MaaS 3.0 incorrectly calculates the amount of free space on drive
+ MAAS 3.0 incorrectly calculates the amount of free space on drive
tags: removed: bug-council
Alberto Donato (ack)
Changed in maas:
assignee: nobody → Alberto Donato (ack)
Alberto Donato (ack)
Changed in maas:
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: 3.3.0 → 3.3.0-beta1
Changed in maas:
status: Fix Committed → Fix Released
Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote :

Hello Heather, Eric, or anyone else affected,

Accepted maas 3.0.1~rc1 into ppa:maas/3.0-next and snap:3.0/edge
(code version 3.0.1~rc1-10049-g.577c3c6b7).

Please test this update and provide your feedback on this bug:

If it fixes the bug for you, please add a comment mentioning the version you tested and what testing has been performed, and change the tag from verification-needed-maas-3.0 to verification-done-maas-3.0.

If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-maas-3.0.

Thank you in advance for helping!

The update will be released after the bug(s) have been verified and quality assurance testing is successful.

tags: added: verification-needed-maas-3.0
Revision history for this message
Heitor Alves de Siqueira (halves) wrote :

MAAS 3.0.1 has now been released, and is available as below:
- deb: ppa:maas/3.0 (3.0.1-10052-g.82c730c57-0ubuntu1~20.04.1)
- snap: 3.0/stable (3.0.1-10052-g.82c730c57)

tags: added: verification-done-maas-3.0
removed: verification-needed-maas-3.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.