Merge "fix: ignore errors when flavors are deleted"

This commit is contained in:
Zuul 2024-03-04 07:20:21 +00:00 committed by Gerrit Code Review
commit 061380cba7
4 changed files with 9 additions and 24 deletions

View File

@ -133,10 +133,6 @@ class InstanceViewTest(test.BaseAdminViewTests):
res = self.client.get(INDEX_URL)
instances = res.context['table'].data
self.assertTemplateUsed(res, INDEX_TEMPLATE)
# Since error messages produced for each instance are identical,
# there will be only one error message for all instances
# (messages de-duplication).
self.assertMessageCount(res, error=1)
self.assertCountEqual(instances, servers)
self.assertEqual(self.mock_image_list_detailed.call_count, 4)

View File

@ -33,6 +33,8 @@ from openstack_dashboard.dashboards.admin.instances \
from openstack_dashboard.dashboards.admin.instances \
import tables as project_tables
from openstack_dashboard.dashboards.admin.instances import tabs
from openstack_dashboard.dashboards.project.instances \
import utils as instance_utils
from openstack_dashboard.dashboards.project.instances import views
from openstack_dashboard.dashboards.project.instances.workflows \
import update_instance
@ -215,18 +217,9 @@ class AdminIndexView(tables.PagedTableMixin, tables.DataTableView):
else:
inst.image['name'] = _("-")
flavor_id = inst.flavor["id"]
try:
if flavor_id in flavor_dict:
inst.full_flavor = flavor_dict[flavor_id]
else:
# If the flavor_id is not in flavor_dict list,
# gets it via nova api.
inst.full_flavor = api.nova.flavor_get(
self.request, flavor_id)
except Exception:
msg = _('Unable to retrieve instance size information.')
exceptions.handle(self.request, msg)
inst.full_flavor = instance_utils.resolve_flavor(self.request,
inst, flavor_dict)
tenant = tenant_dict.get(inst.tenant_id, None)
inst.tenant_name = getattr(tenant, "name", None)
return instances

View File

@ -316,6 +316,7 @@ class InstanceTableTests(InstanceTestBase, InstanceTableTestMixin):
self.mock_is_feature_available.return_value = True
self.mock_server_list_paged.return_value = [servers, False, False]
self.mock_servers_update_addresses.return_value = None
self.mock_flavor_get.side_effect = self.exceptions.nova
self.mock_flavor_list.side_effect = self.exceptions.nova
self.mock_image_list_detailed.return_value = (self.images.list(),
False, False)

View File

@ -171,14 +171,9 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView):
for instance in instances:
self._populate_image_info(instance, image_dict, volume_dict)
flavor_id = instance.flavor["id"]
if flavor_id in flavor_dict:
instance.full_flavor = flavor_dict[flavor_id]
else:
# If the flavor_id is not in flavor_dict,
# put info in the log file.
LOG.info('Unable to retrieve flavor "%s" for instance "%s".',
flavor_id, instance.id)
instance.full_flavor = instance_utils.resolve_flavor(self.request,
instance,
flavor_dict)
return instances