nova api returns 500 when resizing an instance with memory encryption enabled

Bug #2047399 reported by Takashi Kajinami
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
New
Undecided
Unassigned

Bug Description

Description
===========
When a user attempts to resize an instance with memory encryption enabled, API returns 500 error consistently.
Looking into nova-api.log, it seems the issue is caused by a mechanism similar to https://bugs.launchpad.net/nova/+bug/2041511 .

Steps to reproduce
==================
* Create an image with hw_mem_encryption=True
 $ openstack image create encrypted ...
 $ openstack image set encrypted --property hw_mem_encryption=True

* Create an instance
 $ openstack server create testinstance --image encrypted --flavor flavor1 ...

* Resize the instance
 $ openstack server resize testinstance --flavor flavor2

Expected result
===============
Instance resize is accepted and processed by nova, without errors

Actual result
=============
Nova api returns 500 error and does not accept the request

Environment
===========

1. Exact version of OpenStack you are running. See the following
  list for all releases: http://docs.openstack.org/releases/

Ubuntu 22.04 and UCA bobcat.

# dpkg -l | grep nova
ii nova-api 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - API frontend
ii nova-common 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - common files
ii nova-compute 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - compute node base
ii nova-compute-kvm 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - compute node (KVM)
ii nova-compute-libvirt 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - compute node libvirt support
ii nova-conductor 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - conductor service
ii nova-novncproxy 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - NoVNC proxy
ii nova-scheduler 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute - virtual machine scheduler
ii python3-nova 3:28.0.0-0ubuntu1~cloud0 all OpenStack Compute Python 3 libraries
ii python3-novaclient 2:18.4.0-0ubuntu1~cloud0 all client library for OpenStack Compute API - 3.x

2. Which hypervisor did you use?
Libvirt + KVM

3. Which storage type did you use?
LVM

4. Which networking type did you use?
ml2 + ovs

Logs & Configs
==============
The following traceback is found in nova-api.log

```
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi [None req-20b9b69c-a792-45cd-8520-7e9cd3387c0d 838cd42e04884ddfa8ec4ac11e2f8818 baf003aa0202430a92edd003f98794a3 - - default default] Unexpected exception in API method: NotImplementedError: Cannot load 'id' in the base class
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi Traceback (most recent call last):
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/api/openstack/wsgi.py", line 658, in wrapped
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return f(*args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/api/validation/__init__.py", line 110, in wrapper
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return func(*args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/api/openstack/compute/servers.py", line 1146, in _action_resize
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi self._resize(req, id, flavor_ref, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/api/openstack/compute/servers.py", line 1060, in _resize
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi self.compute_api.resize(context, instance, flavor_id,
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 389, in inner
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return function(self, context, instance, *args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 374, in wrapper
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return func(self, context, instance, *args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 357, in wrapper
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return func(self, context, instance, *args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 242, in inner
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return function(self, context, instance, *args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 168, in inner
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return f(self, context, instance, *args, **kw)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 232, in wrapped
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi return function(self, context, instance, *args, **kwargs)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 4270, in resize
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi self._validate_flavor_image_nostatus(
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 830, in _validate_flavor_image_nostatus
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi API._validate_flavor_image_numa_pci(
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/compute/api.py", line 880, in _validate_flavor_image_numa_pci
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi hardware.get_mem_encryption_constraint(flavor, image_meta)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/nova/virt/hardware.py", line 1195, in get_mem_encryption_constraint
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi image_meta.id)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/oslo_versionedobjects/base.py", line 67, in getter
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi self.obj_load_attr(name)
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi File "/usr/lib/python3/dist-packages/oslo_versionedobjects/base.py", line 600, in obj_load_attr
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi raise NotImplementedError(
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi NotImplementedError: Cannot load 'id' in the base class
2023-12-26 08:02:19.371 30791 ERROR nova.api.openstack.wsgi
```

Revision history for this message
Jie Song (songjie-cmss) wrote (last edit ):

In nova/compute/api.py resize() function, `image = utils.get_image_from_system_metadata(instance.system_metadata)` will lead to `image` has no `id` key.

Therefore, when calling `self._validate_flavor_image_nostatus()→API._validate_flavor_image_numa_pci()→hardware.get_mem_encryption_constraint()`, using `image_meta.id` will will cause an error.

See https://bugs.launchpad.net/nova/+bug/2041511, the similar issue.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to nova (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/nova/+/904197

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.