From 31b2f0a2a65b782be4d0a68b3b53604a076f4748 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 24 May 2017 17:06:35 -0400 Subject: [PATCH] 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 ecfb65cee68e96cc99ceecddbf27c6d6f768358e) --- nova/api/openstack/compute/hide_server_addresses.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/compute/hide_server_addresses.py b/nova/api/openstack/compute/hide_server_addresses.py index df787799a486..b6e837710aaf 100644 --- a/nova/api/openstack/compute/hide_server_addresses.py +++ b/nova/api/openstack/compute/hide_server_addresses.py @@ -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):