duplicate tag results in failed deployment for KVM host

Bug #1984141 reported by James
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Medium
Alberto Donato

Bug Description

I'm using maas snap version/build 3.2.2-12005-g.f0f96fa78.
Server: Dell R630

Prior to 3.2.2 I had several servers enlisted & deployed. I've was having trouble with some LXD VM's (no logs on that, sorry - essentially my LXD VM's would intermittently lose network connection between LXD VM's on the same host) so I released the host hoping to re-deploy the LXD host and fix what ever issues might have been host related. I ended up deleting the server and re-commissioning it.

After much debugging, I found that re-deploying my server would fail anytime I selected it as either a LXD or virsh KVM host with the error below from the regiond.log

```
2022-08-09 19:07:20 metadataserver.api_twisted: [critical] Error saving VM host: {'name': ['Tag with this Name already exists.']}
 Traceback (most recent call last):
   File "/snap/maas/23178/lib/python3.8/site-packages/maasserver/utils/orm.py", line 756, in call_within_transaction
     return func_outside_txn(*args, **kwargs)
   File "/snap/maas/23178/lib/python3.8/site-packages/maasserver/utils/orm.py", line 559, in retrier
     return func(*args, **kwargs)
   File "/usr/lib/python3.8/contextlib.py", line 75, in inner
     return func(*args, **kwds)
   File "/snap/maas/23178/lib/python3.8/site-packages/metadataserver/api_twisted.py", line 472, in _processMessage
     _create_vmhost_for_deployment(node)
 --- <exception caught here> ---
   File "/snap/maas/23178/lib/python3.8/site-packages/metadataserver/api_twisted.py", line 251, in _create_vmhost_for_deployment
     pod = pod_form.save()
   File "/snap/maas/23178/lib/python3.8/site-packages/maasserver/forms/pods.py", line 306, in save
     tag, _ = Tag.objects.get_or_create(
   File "/snap/maas/23178/usr/lib/python3/dist-packages/django/db/models/manager.py", line 82, in manager_method
     return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/snap/maas/23178/usr/lib/python3/dist-packages/django/db/models/query.py", line 541, in get_or_create
     return self._create_object_from_params(kwargs, params)
   File "/snap/maas/23178/usr/lib/python3/dist-packages/django/db/models/query.py", line 575, in _create_object_from_params
     obj = self.create(**params)
   File "/snap/maas/23178/usr/lib/python3/dist-packages/django/db/models/query.py", line 422, in create
     obj.save(force_insert=True, using=self.db)
   File "/snap/maas/23178/lib/python3.8/site-packages/maasserver/models/tag.py", line 143, in save
     super().save(*args, **kwargs)
   File "/snap/maas/23178/lib/python3.8/site-packages/maasserver/models/cleansave.py", line 182, in save
     self.validate_unique(exclude=[self._meta.pk.name])
   File "/snap/maas/23178/usr/lib/python3/dist-packages/django/db/models/base.py", line 987, in validate_unique
     raise ValidationError(errors)
 django.core.exceptions.ValidationError: {'name': ['Tag with this Name already exists.']}
```

I released the machine and attempted to re-deploy again as an LXD host and it fails with the same error as above. I cycled and tried several times with the same results today. Essentially, I can:

- deploy without being a KVM host or
- fail deployment trying to be a KVM host.

Pass Deployment options:
Ubuntu 20.04 with hwe-20.04-edge kernel

Fail Deployment options:
Ubuntu 20.04 with hwe-20.04-edge kernel
KVM Host - both LXD or Virsh

Related branches

Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

Can you show us the output of "maas $ADMIN tags read"?

Changed in maas:
status: New → Incomplete
Revision history for this message
James (james-o-benson) wrote (last edit ):

[{'resource_uri': '/MAAS/api/2.0/tags/Rack_2/', 'name': 'Rack_2', 'comment': 'Physical servers on Rack 2', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/openstack_ready/', 'name': 'openstack_ready', 'comment': '', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607417161_yoga/', 'name': '607417161_yoga', 'comment': 'Openstack yoga for 607417161', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607417161_yoga_vip-10_245_125_177/', 'name': '607417161_yoga_vip-10_245_125_177', 'comment': 'Openstack yoga for 607417161', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607417161_yoga_ip_end-10_245_125_176/', 'name': '607417161_yoga_ip_end-10_245_125_176', 'comment': 'Openstack yoga for 607417161', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607417161_yoga_ip_start-10_245_125_170/', 'name': '607417161_yoga_ip_start-10_245_125_170', 'comment': 'Openstack yoga for 607417161', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/Rack1_test_servers/', 'name': 'Rack1_test_servers', 'comment': 'Openstack test servers', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/Rack_1/', 'name': 'Rack_1', 'comment': 'Servers physically located in Rack 1', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607531121_xena/', 'name': '607531121_xena', 'comment': 'Openstack xena for 607531121', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607531121_xena_vip-10_245_125_51/', 'name': '607531121_xena_vip-10_245_125_51', 'comment': 'Openstack xena for 607531121', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607531121_xena_ip_end-10_245_125_50/', 'name': '607531121_xena_ip_end-10_245_125_50', 'comment': 'Openstack xena for 607531121', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/607531121_xena_ip_start-10_245_125_44/', 'name': '607531121_xena_ip_start-10_245_125_44', 'comment': 'Openstack xena for 607531121', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/virtual/', 'name': 'virtual', 'comment': '', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/pod-console-logging/', 'name': 'pod-console-logging', 'comment': '', 'definition': '', 'kernel_opts': ''}, {'resource_uri': '/MAAS/api/2.0/tags/Rack_3/', 'name': 'Rack_3', 'comment': 'Physical Servers on Rack 3', 'definition': '', 'kernel_opts': ''}]

Revision history for this message
James (james-o-benson) wrote :
Alberto Donato (ack)
Changed in maas:
status: Incomplete → Triaged
importance: Undecided → Medium
milestone: none → 3.3.0
Alberto Donato (ack)
Changed in maas:
assignee: nobody → Alberto Donato (ack)
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Revision history for this message
James (james-o-benson) wrote :

I was able to get past this bug by manually removing the 'virtual' tag and deployment was able to proceed. However, still faced resource issues: https://bugs.launchpad.net/maas/+bug/1982423

Changed in maas:
milestone: 3.3.0 → 3.3.0-beta1
Changed in maas:
status: Fix Committed → Fix Released
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.