Description
===========
For a non-admin project, if you have instance launched. And try to query the usage information on GUI by clicking Overview or on CLI: openstack usage show
I will got "Error: Unable to retrieve usage information." on GUI. and the following ERROR for CLI output:
$ openstack usage show
Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<class 'nova.exception.OrphanedObjectError'> (HTTP 500) (Request-ID: req-cbea9542-ecce-42fd-b660-fc5f996ea3c3)
Steps to reproduce
==================
Execute "openstack usage show" command
Or click Project - Compute - Overview button on the GUI.
Expected result
===============
No Error report and the usage information shown
Actual result
=============
Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<class 'nova.exception.OrphanedObjectError'> (HTTP 500) (Request-ID: req-cbea9542-ecce-42fd-b660-fc5f996ea3c3)
Environment
===========
1. Exact version of OpenStack you are running.
Openstack Stein on CentOS7
$ rpm -qa | grep nova
openstack-nova-api-19.0.1-1.el7.noarch
puppet-nova-14.4.0-1.el7.noarch
python2-nova-19.0.1-1.el7.noarch
openstack-nova-conductor-19.0.1-1.el7.noarch
openstack-nova-novncproxy-19.0.1-1.el7.noarch
openstack-nova-migration-19.0.1-1.el7.noarch
openstack-nova-common-19.0.1-1.el7.noarch
openstack-nova-scheduler-19.0.1-1.el7.noarch
openstack-nova-console-19.0.1-1.el7.noarch
python2-novaclient-13.0.1-1.el7.noarch
openstack-nova-placement-api-19.0.1-1.el7.noarch
openstack-nova-compute-19.0.1-1.el7.noarch
2. Which hypervisor did you use?
Libvirt + KVM
$ rpm -qa | grep kvm
qemu-kvm-ev-2.12.0-18.el7_6.5.1.x86_64
libvirt-daemon-kvm-4.5.0-10.el7_6.12.x86_64
qemu-kvm-common-ev-2.12.0-18.el7_6.5.1.x86_64
$ rpm -qa | grep libvirt
libvirt-gconfig-1.0.0-1.el7.x86_64
libvirt-daemon-driver-nwfilter-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-interface-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-config-nwfilter-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-mpath-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-gluster-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-core-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-secret-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-lxc-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-rbd-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-kvm-4.5.0-10.el7_6.12.x86_64
libvirt-bash-completion-4.5.0-10.el7_6.12.x86_64
libvirt-4.5.0-10.el7_6.12.x86_64
libvirt-glib-1.0.0-1.el7.x86_64
libvirt-daemon-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-qemu-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-config-network-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-disk-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-4.5.0-10.el7_6.12.x86_64
libvirt-python-4.5.0-1.el7.x86_64
libvirt-libs-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-scsi-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-network-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-nodedev-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-logical-4.5.0-10.el7_6.12.x86_64
libvirt-daemon-driver-storage-iscsi-4.5.0-10.el7_6.12.x86_64
libvirt-client-4.5.0-10.el7_6.12.x86_64
libvirt-gobject-1.0.0-1.el7.x86_64
Logs & Configs
==============
nova-api.log
2019-07-26 16:12:53.967 8673 INFO nova.osapi_compute.wsgi.server [req-69d7df76-7dd9-4d42-8eeb-347ef1c9d0a5 f887cc44f21043dca85438d74a47d68d 0d47cfd5b9c94a5790fa4472e576cba6 - default default] c5f::e2 "GET /v2.1/0d47cfd5b9c94a5790fa4472e576cba6/servers/detail?all_tenants=True&changes-since=2019-07-26T08%3A07%3A55.280119%2B00%3A00 HTTP/1.1" status: 200 len: 413 time: 0.0639658
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi [req-cbea9542-ecce-42fd-b660-fc5f996ea3c3 1e45ea9a7d5647a6a938c2ac027822f2 85dd8936d21b46a8878ed59678c7ad9a - default default] Unexpected exception in API method: OrphanedObjectError: Cannot call obj_load_attr on orphaned Instance object
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi Traceback (most recent call last):
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/api/openstack/wsgi.py", line 671, in wrapped
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi return f(*args, **kwargs)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 291, in show
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi return self._show(req, id)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 354, in _show
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi detailed=True, limit=limit, marker=marker)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 155, in _tenant_usages_for_period
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi flavor = self._get_flavor(context, instance, flavors)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/simple_tenant_usage.py", line 89, in _get_flavor
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi return instance.get_flavor()
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1191, in get_flavor
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi return getattr(self, attr)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 67, in getter
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi self.obj_load_attr(name)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1114, in obj_load_attr
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi self._obj_load_attr(attrname)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1158, in _obj_load_attr
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi self._load_flavor()
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 967, in _load_flavor
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi self.flavor = instance.flavor
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 67, in getter
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi self.obj_load_attr(name)
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1101, in obj_load_attr
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi objtype=self.obj_name())
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi OrphanedObjectError: Cannot call obj_load_attr on orphaned Instance object
2019-07-26 16:12:57.211 8682 ERROR nova.api.openstack.wsgi
2019-07-26 16:12:57.212 8682 INFO nova.api.openstack.wsgi [req-cbea9542-ecce-42fd-b660-fc5f996ea3c3 1e45ea9a7d5647a6a938c2ac027822f2 85dd8936d21b46a8878ed59678c7ad9a - default default] HTTP exception thrown: Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<class 'nova.exception.OrphanedObjectError'>
2019-07-26 16:12:57.213 8682 INFO nova.osapi_compute.wsgi.server [req-cbea9542-ecce-42fd-b660-fc5f996ea3c3 1e45ea9a7d5647a6a938c2ac027822f2 85dd8936d21b46a8878ed59678c7ad9a - default default] c5f::e2 "GET /v2.1/85dd8936d21b46a8878ed59678c7ad9a/os-simple-tenant-usage/85dd8936d21b46a8878ed59678c7ad9a?start=2019-06-28T08:12:56.417129&end=2019-07-27T08:12:56.417129 HTTP/1.1" status: 500 len: 641 time: 0.3035989
2019-07-26 16:13:00.458 8708 INFO nova.osapi_compute.wsgi.server [req-986dcfad-604b-429d-b9a9-11c8d1ad0036 f887cc44f21043dca85438d74a47d68d 0d47cfd5b9c94a5790fa4472e576cba6 - default default] c5f::e2 "GET /v2.1/0d47cfd5b9c94a5790fa4472e576cba6/servers/detail?all_tenants=True&changes-since=2019-07-26T08%3A08%3A02.099543%2B00%3A00 HTTP/1.1" status: 200 len: 413 time: 0.2606220
2019-07-26 16:13:05.857 8692 INFO nova.osapi_compute.wsgi.server [req-45304a2b-9bc3-4765-aeaf-5be12accbb11 f887cc44f21043dca85438d74a47d68d 0d47cfd5b9c94a5790fa4472e576cba6 - default default] c5f::fc "GET /v2.1/0d47cfd5b9c94a5790fa4472e576cba6/servers/detail?all_tenants=True&changes-since=2019-07-26T08%3A08%3A08.053015%2B00%3A00 HTTP/1.1" status: 200 len: 413 time: 0.0643589
Looks like this is the request:
2019-07-26 16:12:57.213 8682 INFO nova.osapi_ compute. wsgi.server [req-cbea9542- ecce-42fd- b660-fc5f996ea3 c3 1e45ea9a7d5647a 6a938c2ac027822 f2 85dd8936d21b46a 8878ed59678c7ad 9a - default default] c5f::e2 "GET /v2.1/85dd8936d 21b46a8878ed596 78c7ad9a/ os-simple- tenant- usage/85dd8936d 21b46a8878ed596 78c7ad9a? start=2019- 06-28T08: 12:56.417129& end=2019- 07-27T08: 12:56.417129 HTTP/1.1" status: 500 len: 641 time: 0.3035989
I then see this in the stacktrace:
2019-07-26 16:12:57.211 8682 ERROR nova.api. openstack. wsgi File "/usr/lib/ python2. 7/site- packages/ nova/api/ openstack/ compute/ simple_ tenant_ usage.py" , line 291, in show
which should be this API:
https:/ /docs.openstack .org/api- ref/compute/ ?expanded= #show-usage- statistics- for-tenant
it looks like the error is on trying to lazy-load an instance.flavor:
https:/ /github. com/openstack/ nova/blob/ 25e222c68a75f32 1015f655e9ad6a2 5365c86b9d/ nova/api/ openstack/ compute/ simple_ tenant_ usage.py# L155
It looks like the issue is probably that in this method that gets the instances from all cells:
https:/ /github. com/openstack/ nova/blob/ 25e222c68a75f32 1015f655e9ad6a2 5365c86b9d/ nova/api/ openstack/ compute/ simple_ tenant_ usage.py# L109
It's not storing the cell targeted context on the instance objects so trying to lazy load the flavor data from the cell fails. But why would it try to lazy-load the flavor since we are joining the flavor when we pull the instance from the DB:
https:/ /github. com/openstack/ nova/blob/ 25e222c68a75f32 1015f655e9ad6a2 5365c86b9d/ nova/api/ openstack/ compute/ simple_ tenant_ usage.py# L119
So that doesn't make much sense. I would have to try and recreate this in a devstack environment.