Upgrade from 2.4 -> 2.5 doesn't upgrade manual power_type

Bug #1812509 reported by Lloyd Parkes
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Newell Jensen
2.5
Fix Released
Critical
Newell Jensen

Bug Description

I have three nodes that have manual power control in my lab and after upgrading from MAAS 2.4.x to 2.5.0 I found that I could not add a fourth node.

The node had been enlisted and I couldn't set the power type to manual in the GUI. There was no error message in the GUI, the manual setting just seemed to not get saved. When I tried to set the power_type for the enlisted node from the CLI, I got a one line error message.

  $ maas cli machine update ces6hn power_type=manual
  get() returned more than one BMC -- it returned 3!

I found that error message in the middle of Django and went looking for the BMC table. Sure enough, there were three manual entries listed there and they were associated with three different nodes.

I deleted one of the nodes matching the three manual BMC entries and sure enough, the error message changed to complain about two entries instead of three. I realised that I was only using one of my three manually controlled nodes, and so I just deleted the second unused node leaving only one manual power_type entry in the maasserver_bmc table.

I reran "maas cli machine update ces6hn power_type=manual" and this time it spat out a whole pile of JSON like I expected it to. Also, I checked the maasserver_bmc table and it still only had one entry in it.

Did the MAAS code get changed so that the manual power type is now effectively a singleton in the maasserver_bmc table? It makes some kind of sense, because it's not like the manual power type has any parameters. It also looks like the upgrade doesn't collapse all the existing manual BMCs into the single one that is now expected.

For completeness here is my package listing followed by the traceback from regiond.log.

lloyd@maas:~$ dpkg -l '*maas*'|cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================-======================================-============-=================================================
ii maas 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all "Metal as a Service" is a physical cloud and IPAM
ii maas-cli 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS client and command-line interface
un maas-cluster-controller <none> <none> (no description available)
ii maas-common 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS server common files
ii maas-dhcp 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS DHCP server
un maas-dns <none> <none> (no description available)
ii maas-proxy 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS Caching Proxy
ii maas-rack-controller 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all Rack Controller for MAAS
ii maas-region-api 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all Region controller API service for MAAS
ii maas-region-controller 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all Region Controller for MAAS
un maas-region-controller-min <none> <none> (no description available)
un python-django-maas <none> <none> (no description available)
un python-maas-client <none> <none> (no description available)
un python-maas-provisioningserver <none> <none> (no description available)
ii python3-django-maas 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS server Django web framework (Python 3)
ii python3-maas-client 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS python API client (Python 3)
ii python3-maas-provisioningserver 2.5.0-7442-gdf68e30a5-0ubuntu1~18.04.1 all MAAS server provisioning libraries (Python 3)

2019-01-19 20:29:43 maasserver.websockets.protocol: [critical] Error on request (75) machine.update: get() returned more than one BMC -- it returned 3!
        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 852, 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 885, in callInContext
            return func(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 234, 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 376, in update
            data = super(NodeHandler, self).update(params)
          File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 431, in update
            obj = form.save()
          File "/usr/lib/python3/dist-packages/maasserver/forms/__init__.py", line 1316, in save
            node = super(WithMACAddressesMixin, self).save()
          File "/usr/lib/python3/dist-packages/maasserver/forms/__init__.py", line 1101, in save
            WithPowerTypeMixin.set_values(self, machine)
          File "/usr/lib/python3/dist-packages/maasserver/forms/__init__.py", line 379, in set_values
            machine.power_type = new_type
          File "/usr/lib/python3/dist-packages/maasserver/models/cleansave.py", line 152, in __setattr__
            prop_obj.fset(self, value)
          File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 1203, in power_type
            power_type=power_type, power_parameters=self.power_parameters)
          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 464, in get_or_create
            return self.get(**lookup), False
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 384, in get
            (self.model._meta.object_name, num)
        maasserver.models.bmc.MultipleObjectsReturned: get() returned more than one BMC -- it returned 3!

Related branches

Changed in maas:
milestone: none → 2.6.0
importance: Undecided → Critical
assignee: nobody → Newell Jensen (newell-jensen)
Changed in maas:
status: New → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: 2.6.0 → 2.6.0alpha1
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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