Comment 2 for bug 1632247

Revision history for this message
Tina Kevin (song-ruixia) wrote : Re: The command "nova list --all-tenants" query is slow

@siva
My steps:
I add logs in code, and then gradually narrowing the scope of the code,
the final positioning to the follow function.

    /nova/api/openstack/compute/servers.py
    def _get_servers(self, req, is_detail):
        """Returns a list of servers, based on any search options specified."""
        ……

        if is_detail:
             instance_list.fill_faults() #the function
             response = self._view_builder.detail(req, instance_list)

    /nova/objects/instance.py
    def fill_faults(self):
        """Batch query the database for our instances' faults.

        :returns: A list of instance uuids for which faults were found.
        """
        uuids = [inst.uuid for inst in self]
        LOG.info(_("before"))
        faults = objects.InstanceFaultList.get_by_instance_uuids(
            self._context, uuids) #the function
        LOG.info(_("end"))

I compare the printing time of the two logs, they differ by about 30 seconds.
I also test the other case, I remove this line of code and then query,
the total time is much less obvious than before. So I think it is caused by the
instance_faults table records

   def _get_servers(self, req, is_detail):
        """Returns a list of servers, based on any search options specified."""
        ……

        if is_detail:
             #instance_list.fill_faults() #remove
             response = self._view_builder.detail(req, instance_list)