LVM : can't create 2 LVs with the same name on 2 differents VGs

Bug #1809241 reported by Junien Fridrick
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Triaged
Medium
Unassigned
3.3
Triaged
Medium
Unassigned

Bug Description

Hi,

Using MAAS 2.4.2 (7034-g2f5deb8b8-0ubuntu1)

I have 2 LVM VGs created : vg0 and vg1. When I try to add a logical volume name "lv0" on each (which is perfectly correct), it works fine for the first one, but the second one silently fails, and MAAS logs the following trace. I expect MAAS to accep vg0-lv0 and vg1-lv0 without erroring out.

Thanks !

2018-12-20 10:27:53 maasserver.websockets.protocol: [critical] Error on request (45) machine.create_logical_volume: {"__all__": ["Block device with this Node and Name already exists."]}
        Traceback (most recent call last):
          File "/usr/lib/python3.6/threading.py", line 864, in run
            self._target(*self._args, **self._kwargs)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 850, in worker
            return target()
          File "/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
            task()
          File "/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
            task()
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 250, in inContext
            result = inContext.theWork()
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
            inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
            return func(*args,**kw)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 883, in callInContext
            return func(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 232, in wrapper
            result = func(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 756, in call_within_transaction
            return func_outside_txn(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 563, in retrier
            return func(*args, **kwargs)
          File "/usr/lib/python3.6/contextlib.py", line 52, in inner
            return func(*args, **kwds)
          File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/machine.py", line 719, in create_logical_volume
            logical_volume = form.save()
          File "/usr/lib/python3/dist-packages/maasserver/forms/__init__.py", line 3778, in save
            size=self.cleaned_data['size'])
          File "/usr/lib/python3/dist-packages/maasserver/models/filesystemgroup.py", line 795, in create_logical_volume
            filesystem_group=self)
          File "/usr/lib/python3/dist-packages/django/db/models/manager.py", line 85, in manager_method
            return getattr(self.get_queryset(), name)(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 394, in create
            obj.save(force_insert=True, using=self.db)
          File "/usr/lib/python3/dist-packages/maasserver/models/virtualblockdevice.py", line 131, in save
            return super(VirtualBlockDevice, self).save(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/models/cleansave.py", line 213, in save
            self.validate_unique(exclude=[self._meta.pk.name])
          File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 1041, in validate_unique
            raise ValidationError(errors)
        django.core.exceptions.ValidationError: {'__all__': ['Block device with this Node and Name already exists.']}

Alberto Donato (ack)
Changed in maas:
status: New → Triaged
Revision history for this message
Alberto Donato (ack) wrote :

This happens because BlockDevice has a unique_together on (node,name).

In this case the name would be the same, but since these are two VirtualBlockDevices with a different filesystem_group it's actually ok.

I think we need to drop the unique index and add an explicit check in BlockDevice.save() for it, and override it in VirtualBlockDevice.save() so that it takes into account the filesystem_group as well.

Changed in maas:
milestone: none → 3.3.0
importance: Undecided → Medium
Changed in maas:
milestone: 3.3.0 → 3.4.0
Alberto Donato (ack)
Changed in maas:
milestone: 3.4.0 → 3.4.x
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.