Failure to create ephemeral VM when no architectures are found on the VM host

Bug #1994945 reported by Polona Mihalic
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Medium
Igor Brovtsin
3.2
Fix Released
Medium
Igor Brovtsin
3.3
Fix Released
Medium
Igor Brovtsin

Bug Description

MAAS version: 3.2.6
When sending post request to /MAAS/api/2.0/machines/?op=allocate, and all of the existing machines are already allocated, ephemeral machine is not created (although there is enough resources). Instead error is returned: 500 list index out of range

Traceback from regoind.log:
2022-10-27 08:13:41 maasserver: [error] ################################ Exception: list index out of range ################################
2022-10-27 08:13:41 maasserver: [error] Traceback (most recent call last):
  File "/snap/maas/23947/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/utils/views.py", line 288, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/usr/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/api/support.py", line 56, in __call__
    response = super().__call__(request, *args, **kwargs)
  File "/snap/maas/23947/usr/lib/python3/dist-packages/django/views/decorators/vary.py", line 20, in inner_func
    response = func(*args, **kwargs)
  File "/snap/maas/23947/usr/lib/python3.8/dist-packages/piston3/resource.py", line 197, in __call__
    result = self.error_handler(e, request, meth, em_format)
  File "/snap/maas/23947/usr/lib/python3.8/dist-packages/piston3/resource.py", line 195, in __call__
    result = meth(request, *args, **kwargs)
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/api/support.py", line 306, in dispatch
    return function(self, request, *args, **kwargs)
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/api/machines.py", line 2546, in allocate
    ) = get_allocated_composed_machine(
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/api/machines.py", line 347, in get_allocated_composed_machine
    compose_form = ComposeMachineForPodsForm(
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/forms/pods.py", line 760, in __init__
    self.pod_forms = [
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/forms/pods.py", line 761, in <listcomp>
    ComposeMachineForm(request=self.request, data=self.data, pod=pod)
  File "/snap/maas/23947/lib/python3.8/site-packages/maasserver/forms/pods.py", line 422, in __init__
    self.initial["architecture"] = self.pod.architectures[0]
IndexError: list index out of range

Related branches

Revision history for this message
Christian Grabowski (cgrabowski) wrote :

hmm it seems your VM Host is missing its architecture. Can you share the output of `maas $PROFILE vm-hosts read`? Additionally, was the VM Host added with "register as a KVM host" on deployment, or was this an existing host that was added to MAAS' VM Hosts?

Changed in maas:
status: New → Incomplete
Revision history for this message
Polona Mihalic (polona-mihalic) wrote :

So I checked again the architecture, and it is defined, but error still occurs. The vm host that I am working on is actually the one that has maas installed. Important info is also, that this error didn't occur when working with older maas version (I think it was 2.8), instead ephemeral machine was created as expected.

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

We were not able to reproduce this on 3.2 by only requesting it to allocate a machine. We need more details about your setup:

1) what kind of KVM are you running (LXD or Virtsh) and which version?
2) is this a fresh MAAS install or have you been upgrading it since 2.x?
3) the output of `maas $PROFILE vm-hosts read`
4) the output of `maas $PROFILE machines allocate`)

Changed in maas:
status: Incomplete → New
status: New → Incomplete
Revision history for this message
Polona Mihalic (polona-mihalic) wrote :
Download full text (3.3 KiB)

So we figured it out what was the problem - we had 2 hosts, one of them was uninitialized virsh host (cores:0, memory:0):

root@maas:/home/ubuntu# maas admin machines allocate
list index out of range
root@maas:/home/ubuntu# maas admin vm-hosts read
Success.
Machine-readable output follows:
[
    {
        "default_macvlan_mode": "",
        "capabilities": [
            "composable",
            "dynamic_local_storage",
            "over_commit",
            "storage_pools"
        ],
        "host": {
            "system_id": "kwxmgm",
            "__incomplete__": true
        },
        "total": {
            "cores": 4,
            "memory": 8192,
            "local_storage": 22884122624
        },
        "storage_pools": [
            {
                "id": "default",
                "name": "default",
                "type": "zfs",
                "path": "/var/snap/lxd/common/lxd/disks/default.img",
                "total": 22884122624,
                "used": 0,
                "available": 22884122624,
                "default": true
            }
        ],
        "type": "lxd",
        "id": 1,
        "pool": {
            "name": "default",
            "description": "Default pool",
            "id": 0,
            "resource_uri": "/MAAS/api/2.0/resourcepool/0/"
        },
        "architectures": [
            "amd64/generic"
        ],
        "zone": {
            "name": "default",
            "description": "",
            "id": 1,
            "resource_uri": "/MAAS/api/2.0/zones/default/"
        },
        "memory_over_commit_ratio": 1.0,
        "available": {
            "cores": 4,
            "memory": 8192,
            "local_storage": 22884122624
        },
        "name": "crisp-skunk",
        "cpu_over_commit_ratio": 1.0,
        "used": {
            "cores": 0,
            "memory": 0,
            "local_storage": 0
        },
        "version": "5.6",
        "tags": [
            "pod-console-logging",
            "virtual"
        ],
        "resource_uri": "/MAAS/api/2.0/vm-hosts/1/"
    },
    {
        "default_macvlan_mode": null,
        "capabilities": [],
        "host": {
            "system_id": null,
            "__incomplete__": true
        },
        "total": {
            "cores": 0,
            "memory": 0,
            "local_storage": 0
        },
        "storage_pools": [],
        "type": "virsh",
        "id": 50,
        "pool": {
            "name": "default",
            "description": "Default pool",
            "id": 0,
            "resource_uri": "/MAAS/api/2.0/resourcepool/0/"
        },
        "architectures": [],
        "zone": {
            "name": "default",
            "description": "",
            "id": 1,
            "resource_uri": "/MAAS/api/2.0/zones/default/"
        },
        "memory_over_commit_ratio": 1.0,
        "available": {
            "cores": 0,
            "memory": 0,
            "local_storage": 0
        },
        "name": "sadsa",
        "cpu_over_commit_ratio": 1.0,
        "used": {
            "cores": 0,
            "memory": 0,
            "local_storage": 0
        },
        "version": "",
        "tags": [
            "pod-console-logging"
 ...

Read more...

Changed in maas:
status: Incomplete → Triaged
Changed in maas:
importance: Undecided → Medium
Changed in maas:
milestone: none → 3.4.0
status: Triaged → Fix Committed
Changed in maas:
assignee: nobody → Igor Brovtsin (igor-brovtsin)
tags: added: bug-council
tags: removed: bug-council
summary: - Ephemeral machine not created
+ Failure to create ephemeral VM when no architectures are found on the VM
+ host
Alberto Donato (ack)
Changed in maas:
milestone: 3.4.0 → 3.4.0-beta1
Alberto Donato (ack)
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.