0203_interface_node_name_duplicates_delete.py raises an exception with discovered Interfaces

Bug #1863166 reported by Lee Trager on 2020-02-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
High
Newell Jensen

Bug Description

I tried upgrading MAAS to master and the upgrade failed. My MAAS does not have any duplicate interfaces so this code should not be detecting anything.

In [7] duplicates = (
    Interface.objects.all().values("name", "node_id")
    .annotate(if_ids=ArrayAgg("id"), name_count=Count("id"))
    .filter(name_count__gt=1)
    .order_by()
)
In [8]: duplicates
Out[8]: <InterfaceQuerySet [{'name': 'eth0', 'node_id': None, 'if_ids': [16, 17, 29, 27], 'name_count': 4}]>

It appears I do have an eth0 that isn't attached to anything

In[12]: {iface.node: iface for iface in Interface.objects.filter(name='eth0')}
Out[12]:
{
    None: <UnknownInterface: name=eth0, type=unknown, mac=00:16:3e:f0:58:c5, id=29>,
    <Node: yb7knc (maas-bionic)>: <PhysicalInterface: name=eth0, type=physical, mac=00:16:3e:22:3e:36, id=1>,
}

In [22]: iface = Interface.objects.get(mac_address='00:16:3e:f0:58:c5')

In [23]: iface
Out[23]: <UnknownInterface: name=eth0, type=unknown, mac=00:16:3e:f0:58:c5, id=29>

In [24]: iface.node

In [25]: iface.type
Out[25]: 'unknown'

Setting up maas-region-controller (2.7.0~rc1-8226-g.95ab0b976-0ubuntu1) ...
Operations to perform:
  Apply all migrations: auth, contenttypes, maasserver, metadataserver, piston3, sessions, sites
Running migrations:
  Applying maasserver.0203_interface_node_name_duplicates_delete...Traceback (most recent call last):
  File "/usr/sbin/maas-region", line 11, in <module>
    load_entry_point('maas==2.7.0rc1', 'console_scripts', 'maas-region')()
  File "/usr/lib/python3/dist-packages/maasserver/region_script.py", line 76, in run
    run_django(is_snap, is_devenv)
  File "/usr/lib/python3/dist-packages/maasserver/region_script.py", line 65, in run_django
    management.execute_from_command_line()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3/dist-packages/maasserver/management/commands/dbupgrade.py", line 117, in handle
    call_command("migrate", interactive=False)
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 131, in call_command
    return command.execute(*args, **defaults)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/lib/python3/dist-packages/django/db/migrations/migration.py", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/lib/python3/dist-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/usr/lib/python3/dist-packages/maasserver/migrations/maasserver/0203_interface_node_name_duplicates_delete.py", line 30, in delete_duplicate_interfaces
    node = Node.objects.get(id=duplicate["node_id"])
  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 380, in get
    self.model._meta.object_name
__fake__.DoesNotExist: Node matching query does not exist.
dpkg: error processing package maas-region-controller (--configure):
 installed maas-region-controller package post-installation script subprocess returned error exit status 1
No apport report written because the error message indicates its a followup error from a previous failure.
     dpkg: dependency problems prevent configuration of maas:
 maas depends on maas-region-controller (= 2.7.0~rc1-8226-g.95ab0b976-0ubuntu1); however:
  Package maas-region-controller is not configured yet.

dpkg: error processing package maas (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 maas-region-controller
 maas
E: Sub-process /usr/bin/dpkg returned an error code (1)

Lee Trager (ltrager) on 2020-02-13
Changed in maas:
milestone: 2.4.3 → none
Lee Trager (ltrager) wrote :

00:16:3e:f0:58:c5 is a discovered MAC address. I deployed a machine with MAAS and manually launched an LXD container on it which got its IP from MAAS.

Lee Trager (ltrager) wrote :

This may be effecting network discovery. I added two more containers and while MAAS detected both and added them as discovered interfaces into the database I don't see anything in the UI.

summary: 0203_interface_node_name_duplicates_delete.py raises an exception with
- unattached Interface
+ discovered Interfaces
Changed in maas:
assignee: nobody → Newell Jensen (newell-jensen)
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers