Exclude fake marker instance when listing servers
The fill_virtual_interface_list online data migration added in Stein creates a fake instance marker record without some fields (like flavor) which will fail to load and result in a 500 error when listing deleted servers across all tenants: openstack server list --all-projects --deleted This fixes the issue by excluding the specific fake marker instance when listing servers in the API. This admittedly isn't great but it's one of many not-so-great options (listed in the bug) and also something that we'll eventually remove when we drop the online data migration. Change-Id: Ibd34b7f24016641bc251f85e6ea17e8a969c3095 Closes-Bug: #1825034
This commit is contained in:
parent
91056970b5
commit
f9eb685bee
|
@ -29,6 +29,7 @@ from nova import context as nova_context
|
|||
from nova import exception
|
||||
from nova.network.security_group import openstack_driver
|
||||
from nova import objects
|
||||
from nova.objects import virtual_interface
|
||||
from nova.policies import extended_server_attributes as esa_policies
|
||||
from nova.policies import flavor_extra_specs as fes_policies
|
||||
from nova.policies import servers as servers_policies
|
||||
|
@ -422,7 +423,10 @@ class ViewBuilder(common.ViewBuilder):
|
|||
show_host_status=show_host_status,
|
||||
show_sec_grp=show_sec_grp, bdms=bdms,
|
||||
cell_down_support=cell_down_support)["server"]
|
||||
for server in servers]
|
||||
for server in servers
|
||||
# Filter out the fake marker instance created by the
|
||||
# fill_virtual_interface_list online data migration.
|
||||
if server.uuid != virtual_interface.FAKE_UUID]
|
||||
servers_links = self._get_collection_links(request,
|
||||
servers,
|
||||
coll_name)
|
||||
|
|
|
@ -10,14 +10,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova.db import api as db_api
|
||||
from nova.objects import virtual_interface
|
||||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
from nova.tests.functional.api import client as api_client
|
||||
from nova.tests.functional import fixtures as func_fixtures
|
||||
from nova.tests.functional import integrated_helpers
|
||||
from nova.tests.unit.image import fake as fake_image
|
||||
|
@ -82,10 +79,10 @@ class FillVirtualInterfaceListMigration(
|
|||
# Since the above (archive stuff) removed the fake instance, do the
|
||||
# migration again to recreate it so we can exercise the code path.
|
||||
virtual_interface.fill_virtual_interface_list(ctxt, max_count=50)
|
||||
# Now list deleted servers.
|
||||
# FIXME(mriedem): This blows up trying to load fields (flavor) on the
|
||||
# deleted marker flavor (bug 1825034).
|
||||
ex = self.assertRaises(api_client.OpenStackApiException,
|
||||
self.api.get_servers,
|
||||
search_opts={'all_tenants': 1, 'deleted': 1})
|
||||
self.assertIn('OrphanedObjectError', six.text_type(ex))
|
||||
# Now list deleted servers. The fake marker instance should be excluded
|
||||
# from the API results.
|
||||
for detail in (True, False):
|
||||
servers = self.api.get_servers(detail=detail,
|
||||
search_opts={'all_tenants': 1,
|
||||
'deleted': 1})
|
||||
self.assertEqual(0, len(servers))
|
||||
|
|
Loading…
Reference in New Issue