diff --git a/broken-functional-py3-ssl-tests.txt b/broken-functional-py3-ssl-tests.txt index 58c55b3901..c1edae96b2 100644 --- a/broken-functional-py3-ssl-tests.txt +++ b/broken-functional-py3-ssl-tests.txt @@ -1,2 +1 @@ -^glance\.tests\.functional\.test_reload\.TestReload\.test_reload$ ^glance\.tests\.functional\.test_ssl\.TestSSL\.test_ssl_ok$ diff --git a/glance/common/utils.py b/glance/common/utils.py index 3ea76e3b01..4334f0dbc7 100644 --- a/glance/common/utils.py +++ b/glance/common/utils.py @@ -613,12 +613,17 @@ def stash_conf_values(): conf = { 'bind_host': CONF.bind_host, 'bind_port': CONF.bind_port, - 'tcp_keepidle': CONF.cert_file, 'backlog': CONF.backlog, - 'key_file': CONF.key_file, - 'cert_file': CONF.cert_file } + # Note(jokke): As we can still support termination with PY27 we + # need to add the possible certs in that specific case. This is + # only needed prior Ussuri which doesn't support PY27 anymore. + if six.PY2: + conf['key_file'] = CONF.key_file, + conf['cert_file'] = CONF.cert_file + conf['tcp_keepidle'] = CONF.cert_file, + return conf diff --git a/glance/tests/functional/test_reload.py b/glance/tests/functional/test_reload.py index 710b030c33..0712a3c1de 100644 --- a/glance/tests/functional/test_reload.py +++ b/glance/tests/functional/test_reload.py @@ -19,6 +19,7 @@ import time import psutil import requests +import six from six.moves import http_client as http from glance.tests import functional @@ -145,87 +146,88 @@ class TestReload(functional.FunctionalTest): if check_pids(pre_pids['api'], post_pids['api']): break - # Test changing from http to https - # This recycles the existing socket - path = self._url('http', '/') - response = requests.get(path) - self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) - del response # close socket so that process audit is reliable + if six.PY2: + # Test changing from http to https + # This recycles the existing socket + path = self._url('http', '/') + response = requests.get(path) + self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) + del response # close socket so that process audit is reliable - pre_pids['api'] = self._get_children('api') - key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key') - set_config_value(self._conffile('api'), 'key_file', key_file) - cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt') - set_config_value(self._conffile('api'), 'cert_file', cert_file) - cmd = "kill -HUP %s" % self._get_parent('api') - execute(cmd, raise_error=True) + pre_pids['api'] = self._get_children('api') + key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key') + set_config_value(self._conffile('api'), 'key_file', key_file) + cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt') + set_config_value(self._conffile('api'), 'cert_file', cert_file) + cmd = "kill -HUP %s" % self._get_parent('api') + execute(cmd, raise_error=True) - msg = 'http to https timeout' - for _ in self.ticker(msg): - post_pids['api'] = self._get_children('api') - if check_pids(pre_pids['api'], post_pids['api']): - break + msg = 'http to https timeout' + for _ in self.ticker(msg): + post_pids['api'] = self._get_children('api') + if check_pids(pre_pids['api'], post_pids['api']): + break - ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt') - path = self._url('https', '/') - response = requests.get(path, verify=ca_file) - self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) - del response + ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt') + path = self._url('https', '/') + response = requests.get(path, verify=ca_file) + self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) + del response - # Test https restart - # This recycles the existing socket - pre_pids['api'] = self._get_children('api') - cmd = "kill -HUP %s" % self._get_parent('api') - execute(cmd, raise_error=True) + # Test https restart + # This recycles the existing socket + pre_pids['api'] = self._get_children('api') + cmd = "kill -HUP %s" % self._get_parent('api') + execute(cmd, raise_error=True) - msg = 'https restart timeout' - for _ in self.ticker(msg): - post_pids['api'] = self._get_children('api') - if check_pids(pre_pids['api'], post_pids['api']): - break + msg = 'https restart timeout' + for _ in self.ticker(msg): + post_pids['api'] = self._get_children('api') + if check_pids(pre_pids['api'], post_pids['api']): + break - ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt') - path = self._url('https', '/') - response = requests.get(path, verify=ca_file) - self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) - del response + ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt') + path = self._url('https', '/') + response = requests.get(path, verify=ca_file) + self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) + del response - # Test changing the https bind_host - # This requires a new socket - pre_pids['api'] = self._get_children('api') - set_config_value(self._conffile('api'), 'bind_host', '127.0.0.1') - cmd = "kill -HUP %s" % self._get_parent('api') - execute(cmd, raise_error=True) + # Test changing the https bind_host + # This requires a new socket + pre_pids['api'] = self._get_children('api') + set_config_value(self._conffile('api'), 'bind_host', '127.0.0.1') + cmd = "kill -HUP %s" % self._get_parent('api') + execute(cmd, raise_error=True) - msg = 'https bind_host timeout' - for _ in self.ticker(msg): - post_pids['api'] = self._get_children('api') - if check_pids(pre_pids['api'], post_pids['api']): - break + msg = 'https bind_host timeout' + for _ in self.ticker(msg): + post_pids['api'] = self._get_children('api') + if check_pids(pre_pids['api'], post_pids['api']): + break - path = self._url('https', '/') - response = requests.get(path, verify=ca_file) - self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) - del response + path = self._url('https', '/') + response = requests.get(path, verify=ca_file) + self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) + del response - # Test https -> http - # This recycles the existing socket - pre_pids['api'] = self._get_children('api') - set_config_value(self._conffile('api'), 'key_file', '') - set_config_value(self._conffile('api'), 'cert_file', '') - cmd = "kill -HUP %s" % self._get_parent('api') - execute(cmd, raise_error=True) + # Test https -> http + # This recycles the existing socket + pre_pids['api'] = self._get_children('api') + set_config_value(self._conffile('api'), 'key_file', '') + set_config_value(self._conffile('api'), 'cert_file', '') + cmd = "kill -HUP %s" % self._get_parent('api') + execute(cmd, raise_error=True) - msg = 'https to http timeout' - for _ in self.ticker(msg): - post_pids['api'] = self._get_children('api') - if check_pids(pre_pids['api'], post_pids['api']): - break + msg = 'https to http timeout' + for _ in self.ticker(msg): + post_pids['api'] = self._get_children('api') + if check_pids(pre_pids['api'], post_pids['api']): + break - path = self._url('http', '/') - response = requests.get(path) - self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) - del response + path = self._url('http', '/') + response = requests.get(path) + self.assertEqual(http.MULTIPLE_CHOICES, response.status_code) + del response # Test changing the http bind_host # This requires a new socket diff --git a/releasenotes/notes/Fix_reload_PY3-e8a5bd337a77be1a.yaml b/releasenotes/notes/Fix_reload_PY3-e8a5bd337a77be1a.yaml new file mode 100644 index 0000000000..536531817f --- /dev/null +++ b/releasenotes/notes/Fix_reload_PY3-e8a5bd337a77be1a.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + * Bug 1855708_: Reload broken in PY3 + + .. _1855708: https://bugs.launchpad.net/glance/+bug/1855708