Fix instance lookup in hide_server_addresses extension

The hide_server_addresses extension is looking up the cached
instance based on what the user provided for the server id,
which may not match what is used to cache the instance for the
request. For example, a request with upper-case server uuid
could be found in a mysql-backed system because mysql is
case insensitive by default, but the instance is keyed off the
server id from the DB, which is lower-case, so we'll fail
to look up the instance in the cache if the IDs don't match.

There is no test for this because it turns out it's actually
really hard to recreate this since it requires running with a
mysql backend to recreate the case insensitive check, which
isn't going to work with sqlite. Given how trivial this fix is,
creating a big mysql recreate test is not worth it.

Change-Id: I09b288aa2ad9969800a3cd26c675b002c6c9f638
Closes-Bug: #1693335
(cherry picked from commit ecfb65cee6)
This commit is contained in:
Matt Riedemann 2017-05-24 17:06:35 -04:00
parent 8fdb137213
commit 31b2f0a2a6
1 changed files with 3 additions and 2 deletions

View File

@ -49,8 +49,9 @@ class Controller(wsgi.Controller):
return
if 'server' in resp.obj and 'addresses' in resp.obj['server']:
instance = req.get_db_instance(id)
self._perhaps_hide_addresses(instance, resp.obj['server'])
resp_server = resp.obj['server']
instance = req.get_db_instance(resp_server['id'])
self._perhaps_hide_addresses(instance, resp_server)
@wsgi.extends
def detail(self, req, resp_obj):