Remove second get call to list/show volumes
Recently it was observed that with large numbers of volumes
that things like "cinder list" could take extremely long to
return.
For example, running cinder list on a system with 1000 volumes took
greater than 30 seconds to return. It turns out that the cause of
this is the addition of visible admin_metadata.
There's two problems with this:
1. The original patch probably shouldn't have gone in
data is either admin data or it's not, selectively picking
pieces of admin data out to provide to the user just creates
complications and introduces confusion.
2. The REAL issue here is that since the standar gets are made
with the standard user context, the add_visible_admin_metadata
would go through and do an elevated context get on every single
volume individually. This is what caused the horrible performance
issue on cinder list with large numbers of volumes.
Running as admin, or removing the second call drops this down to about 3
seconds for the same 1000 volume list.
This patch removes the secondary admin context get_call. Instead where
we expect to do display the visible admin_meta, we pass in a flag
requesting that the volume object we're getting has the appropriate
metadata. This way we can elevate the context if needed and avoid
iterating through the gets again.
This patch also cleans up the get_visible_admin_meta methods, and
consolidates both V1 and V2 to use the utils method.
Change-Id: I3fb7aefb7d8a5664b0a3fb3958f509b5cd621320
Closes-Bug:
1317606