Created attachment 1888924 [details] error displayed on dashboard Description of problem: Error while trying to add/remove projects access to a flavor via Horizon dashboard. Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1.via dashboard or cli create a project "NewProject" 2.via dashboard or cli add project to a flavor "test2" 3.via dashboard or cli remove the project 4.via Dashboard try to add or remove a project to "test2" (via cli it will works) Actual results: #### on dashboard: Error: Unable to modify flavor access of "test2". #### on nova-api-log 2022-06-08 15:12:10.029 17 DEBUG nova.api.openstack.wsgi [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Action: 'action', calling method: <bound method FlavorActionController._remove_tenant_access of <nova.api.openstack.compute.flavor_access.FlavorActionController object at 0x7fb1b621eac8>>, body: {"removeTenantAccess": {"tenant": "53e243252e8b46ebad53f7150d3a93c0"}} _process_stack /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:520 2022-06-08 15:12:10.636 22 DEBUG nova.api.openstack.wsgi [req-5b5a3b53-be45-4bb9-8b57-4e220ff254a3 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Calling method '<bound method Versions.index of <nova.api.openstack.compute.versions.Versions object at 0x7fb1b6dfd9b0>>' _process_stack /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:523 2022-06-08 15:12:10.638 22 INFO nova.api.openstack.requestlog [req-5b5a3b53-be45-4bb9-8b57-4e220ff254a3 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] 192.168.121.3 "OPTIONS /" status: 200 len: 395 microversion: - time: 0.002083 2022-06-08 15:12:10.748 18 DEBUG nova.api.openstack.wsgi [req-df88b92e-e661-45ee-af5e-0a35b3957116 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Calling method '<bound method Versions.index of <nova.api.openstack.compute.versions.Versions object at 0x7fb1b6b65d68>>' _process_stack /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:523 2022-06-08 15:12:10.749 18 INFO nova.api.openstack.requestlog [req-df88b92e-e661-45ee-af5e-0a35b3957116 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] 192.168.121.2 "OPTIONS /" status: 200 len: 395 microversion: - time: 0.000978 2022-06-08 15:12:10.749 17 INFO nova.api.openstack.wsgi [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] HTTP exception thrown: Project ID 53e243252e8b46ebad53f7150d3a93c0 is not a valid project. 2022-06-08 15:12:10.757 17 DEBUG nova.api.openstack.wsgi [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Returning 400 to user: Project ID 53e243252e8b46ebad53f7150d3a93c0 is not a valid project. __call__ /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:941 2022-06-08 15:12:10.758 17 INFO nova.api.openstack.requestlog [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] 192.168.121.2 "POST /v2.1/flavors/a19af703-a2d5-4e73-ae2d-83a3d1cdbdab/action" status: 400 len: 111 microversion: 2.1 time: 0.738203 Expected results: the flavor is modified. Additional info: I found that reason is that after deleting a project, on galera bundle DB, the project is deleted on "keystone.project" table, but the link between project and flavor still remains on "nova_api.flavor_projects". Resuming, deleting projects that were already linked to a flavor will create an inconsistency between "keystone.project" and "nova_api.flavor_projects" that we can observe by running on controller galera DB the following command: select * from nova_api.flavor_projects where project_id not in (select id from keystone.project); so finally all the flavors listed by the following query will not be editable by Horizon dashboard: select * from nova_api.flavors where id in (select flavor_id from nova_api.flavor_projects where project_id not in (select id from keystone.project));
Heya, See inline for question. (In reply to cmilleta from comment #0) > Created attachment 1888924 [details] > error displayed on dashboard > > Description of problem: > > Error while trying to add/remove projects access to a flavor via Horizon > dashboard. > > > Version-Release number of selected component (if applicable): > > > How reproducible: > > > > Steps to Reproduce: > > 1.via dashboard or cli create a project "NewProject" > > 2.via dashboard or cli add project to a flavor "test2" > > 3.via dashboard or cli remove the project > > 4.via Dashboard try to add or remove a project to "test2" (via cli it will > works) Am I understanding correctly that this works via the CLI? In that case, isn't this a bug in Horizon? > Actual results: > > #### on dashboard: > > Error: Unable to modify flavor access of "test2". > > #### on nova-api-log > > 2022-06-08 15:12:10.029 17 DEBUG nova.api.openstack.wsgi > [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Action: 'action', > calling method: <bound method FlavorActionController._remove_tenant_access > of <nova.api.openstack.compute.flavor_access.FlavorActionController object > at 0x7fb1b621eac8>>, body: {"removeTenantAccess": {"tenant": > "53e243252e8b46ebad53f7150d3a93c0"}} _process_stack > /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:520 > 2022-06-08 15:12:10.636 22 DEBUG nova.api.openstack.wsgi > [req-5b5a3b53-be45-4bb9-8b57-4e220ff254a3 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Calling method '<bound > method Versions.index of <nova.api.openstack.compute.versions.Versions > object at 0x7fb1b6dfd9b0>>' _process_stack > /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:523 > 2022-06-08 15:12:10.638 22 INFO nova.api.openstack.requestlog > [req-5b5a3b53-be45-4bb9-8b57-4e220ff254a3 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] 192.168.121.3 "OPTIONS > /" status: 200 len: 395 microversion: - time: 0.002083 > 2022-06-08 15:12:10.748 18 DEBUG nova.api.openstack.wsgi > [req-df88b92e-e661-45ee-af5e-0a35b3957116 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Calling method '<bound > method Versions.index of <nova.api.openstack.compute.versions.Versions > object at 0x7fb1b6b65d68>>' _process_stack > /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:523 > 2022-06-08 15:12:10.749 18 INFO nova.api.openstack.requestlog > [req-df88b92e-e661-45ee-af5e-0a35b3957116 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] 192.168.121.2 "OPTIONS > /" status: 200 len: 395 microversion: - time: 0.000978 > 2022-06-08 15:12:10.749 17 INFO nova.api.openstack.wsgi > [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] HTTP exception thrown: > Project ID 53e243252e8b46ebad53f7150d3a93c0 is not a valid project. > 2022-06-08 15:12:10.757 17 DEBUG nova.api.openstack.wsgi > [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] Returning 400 to user: > Project ID 53e243252e8b46ebad53f7150d3a93c0 is not a valid project. __call__ > /usr/lib/python3.6/site-packages/nova/api/openstack/wsgi.py:941 > 2022-06-08 15:12:10.758 17 INFO nova.api.openstack.requestlog > [req-e1372bfb-01e6-4b72-ac7e-42cb35a007d4 7c943afe3cad465aa243112d4a5373d8 > 661eed9ba6d94f7fbda70ff5f6fc6f0a - default default] 192.168.121.2 "POST > /v2.1/flavors/a19af703-a2d5-4e73-ae2d-83a3d1cdbdab/action" status: 400 len: > 111 microversion: 2.1 time: 0.738203 > > > Expected results: > > the flavor is modified. > > Additional info: > > I found that reason is that after deleting a project, on galera bundle DB, > the project is deleted on "keystone.project" table, but the link between > project and flavor still remains on "nova_api.flavor_projects". > > Resuming, deleting projects that were already linked to a flavor will create > an inconsistency between "keystone.project" and "nova_api.flavor_projects" > that we can observe by running on controller galera DB the following command: > > select * from nova_api.flavor_projects where project_id not in (select id > from keystone.project); > > so finally all the flavors listed by the following query will not be > editable by Horizon dashboard: > > select * from nova_api.flavors where id in (select flavor_id from > nova_api.flavor_projects where project_id not in (select id from > keystone.project));
Nova has no way intelligent way of handling a project being deleted, so it just keeps the deleted project ID in its database, and handles the fact that the project no longer exists as gracefully as it can. The upstream community consensus is that purging a tenant is a client-side operation - the client needs to first delete all the resources in the tenant, then delete the tenant [1]. So in this case, we can ask Horizon to implement a "project purge" RFE, and/or to handle a missing project ID more gracefully. [1] https://docs.openstack.org/python-openstackclient/latest/cli/command-objects/project-cleanup.html
stable/wallaby patch https://review.opendev.org/c/openstack/nova/+/888333 was merged in upstream and will be added to one of future RHOSP 17.1 minor releases. This bug does not look important to me, so it doesn't make sense to track it downstream. Closing as UPSTREAM.