[2.2] Failed to get virsh pod storage: cryptic message if no pools are defined

Bug #1696122 reported by Dmitrii Shcherbakov
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Alberto Donato
2.2
Won't Fix
High
Alberto Donato

Bug Description

For some reason a default storage pool for libvirt wasn't created after libvirt-bin package installation.

In this case, adding a pod resulted in a cryptic error:

buntu@maas:~$ maas maas pods create type=virsh power_address='qemu+ssh://<email address hidden>/system'

Jun 6 08:44:46 maas maas.drivers.pod.virsh: [error] Failed to get pod local storage

ubuntu@maas:~$ ssh <email address hidden> 'virsh pool-list'
 Name State Autostart
-------------------------------------------

ubuntu@maas:~$ maas maas pods create type=virsh power_address='qemu+ssh://<email address hidden>/system'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Pod creation fails and an error that finally gets to the end user is not very descriptive.

src/provisioningserver/drivers/pod/virsh.py

    def get_pod_local_storage(self):
        """Gets the total local storage for the pod."""
        pools = self.get_pod_pool_size_map("Capacity")
        if len(pools) == 0:
            maaslog.error("Failed to get pod local storage")
            return None
        return sum(pools.values())

Tags: sts internal

Related branches

Changed in maas:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.3.0
Revision history for this message
Frode Nordahl (fnordahl) wrote :

Repeated the test with current packages from maas-next PPA and gathered some logs.

This is printed in the web console:
int() argument must be a string, a bytes-like object or a number, not 'NoneType' is logged in the web console.

==> maas.log <==
Aug 8 21:45:44 maas maas.drivers.pod.virsh: [error] Failed to get pod local storage

==> regiond.log <==
2017-08-08 21:45:44 regiond: [info] 127.0.0.1 GET /MAAS/rpc/ HTTP/1.0 --> 200 OK (referrer: -; agent: provisioningserver.rpc.clusterservice.ClusterClientService)
2017-08-08 21:45:45 maasserver.websockets.protocol: [critical] Error on request (31) pod.create: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 588, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 859, in _cbDeferred
    self.callback(self.resultList)
  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 393, in callback
    self._startRunCallbacks(result)
  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
    self._runCallbacks()
--- <exception caught here> ---
  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 588, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/lib/python3/dist-packages/maasserver/forms/pods.py", line 249, in wrap_errors
    raise PodProblem(str(failure.value))
maasserver.exceptions.PodProblem: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

tags: added: sts
Revision history for this message
Frode Nordahl (fnordahl) wrote :

A quick fix is of course to add the missing storage pool on the libvirt host you want MAAS to talk to.

Example:
sudo virsh pool-create-as default dir --target /var/lib/libvirt/images

tags: added: internal
Changed in maas:
milestone: 2.3.0 → 2.3.0beta3
Revision history for this message
Andres Rodriguez (andreserl) wrote :

IMHO, I would do this:

1. If there are no pools, then create the "default" pool automatically:

sudo virsh pool-create-as default dir --target /var/lib/libvirt/images

2. If the creation fails, then raise an error telling the user that no storage pools are available.

However, if we dont wanna do 1 above, then MAAS needs to raise the error to the user telling them that there's no storage pools defined and that they need to create one.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Also, it would be nice to have some verbosity in maas.log

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

1. might be worthwhile but libvirt has support for different kinds of storage pools

https://libvirt.org/storage.html

I think we shouldn't aim to support every storage pool type out there so I would just error out. We're not building another OpenStack after all.

2. Yes, I think the only functionality I would add is an ability to specify a storage pool name to be used.

Revision history for this message
Alberto Donato (ack) wrote :

A similar issue happens if you don't have a network defined

Changed in maas:
milestone: 2.3.0beta3 → 2.3.0beta4
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: 2.3.0beta4 → 2.3.0rc1
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.