Skip to content

Commit 6e9ad14

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add service version check workaround for FFU" into stable/wallaby
2 parents 1e37f2c + e8b079a commit 6e9ad14

File tree

5 files changed

+64
-2
lines changed

5 files changed

+64
-2
lines changed

nova/api/openstack/wsgi_app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def _get_config_files(env=None):
4444

4545

4646
def _setup_service(host, name):
47-
utils.raise_if_old_compute()
47+
try:
48+
utils.raise_if_old_compute()
49+
except exception.TooOldComputeService as e:
50+
if CONF.workarounds.disable_compute_service_check_for_ffu:
51+
LOG.warning(str(e))
52+
else:
53+
raise
4854

4955
binary = name if name.startswith('nova-') else "nova-%s" % name
5056

nova/conf/workarounds.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,16 @@
435435
Related options:
436436
437437
* :oslo.config:option:`DEFAULT.compute_driver` (libvirt)
438+
"""),
439+
cfg.BoolOpt('disable_compute_service_check_for_ffu',
440+
default=False,
441+
help="""
442+
If this is set, the normal safety check for old compute services will be
443+
treated as a warning instead of an error. This is only to be enabled to
444+
facilitate a Fast-Forward upgrade where new control services are being started
445+
before compute nodes have been able to update their service record. In an FFU,
446+
the service records in the database will be more than one version old until
447+
the compute nodes start up, but control services need to be online first.
438448
"""),
439449
]
440450

nova/service.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ def create(cls, host=None, binary=None, topic=None, manager=None,
261261
# up before it allows the service to be created. The
262262
# raise_if_old_compute() depends on the RPC to be up and does not
263263
# implement its own retry mechanism to connect to the conductor.
264-
utils.raise_if_old_compute()
264+
try:
265+
utils.raise_if_old_compute()
266+
except exception.TooOldComputeService as e:
267+
if CONF.workarounds.disable_compute_service_check_for_ffu:
268+
LOG.warning(str(e))
269+
else:
270+
raise
265271

266272
return service_obj
267273

nova/tests/unit/api/openstack/test_wsgi_app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from oslotest import base
1919

2020
from nova.api.openstack import wsgi_app
21+
from nova import exception
2122
from nova import test
2223
from nova.tests import fixtures as nova_fixtures
2324

@@ -83,3 +84,19 @@ def test_init_application_called_twice(self, mock_get_files, mock_setup,
8384
wsgi_app.init_application('nova-api')
8485
self.assertIn('Global data already initialized, not re-initializing.',
8586
self.stdlog.logger.output)
87+
88+
@mock.patch('nova.objects.Service.get_by_host_and_binary')
89+
@mock.patch('nova.utils.raise_if_old_compute')
90+
def test_setup_service_version_workaround(self, mock_check_old, mock_get):
91+
mock_check_old.side_effect = exception.TooOldComputeService(
92+
oldest_supported_version='2',
93+
scope='scope',
94+
min_service_level=2,
95+
oldest_supported_service=1)
96+
97+
self.assertRaises(exception.TooOldComputeService,
98+
wsgi_app._setup_service, 'myhost', 'api')
99+
wsgi_app.CONF.set_override(
100+
'disable_compute_service_check_for_ffu', True,
101+
group='workarounds')
102+
wsgi_app._setup_service('myhost', 'api')

nova/tests/unit/test_service.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,29 @@ def fake_wait(*args, **kwargs):
286286
mock_check_old.assert_called_once_with()
287287
mock_wait.assert_called_once_with(mock.ANY)
288288

289+
@mock.patch('nova.utils.raise_if_old_compute')
290+
def test_old_compute_version_check_workaround(
291+
self, mock_check_old):
292+
293+
mock_check_old.side_effect = exception.TooOldComputeService(
294+
oldest_supported_version='2',
295+
scope='scope',
296+
min_service_level=2,
297+
oldest_supported_service=1)
298+
299+
self.assertRaises(exception.TooOldComputeService,
300+
service.Service.create,
301+
self.host, 'nova-conductor', self.topic,
302+
'nova.tests.unit.test_service.FakeManager')
303+
304+
CONF.set_override('disable_compute_service_check_for_ffu', True,
305+
group='workarounds')
306+
307+
service.Service.create(self.host, 'nova-conductor', self.topic,
308+
'nova.tests.unit.test_service.FakeManager')
309+
310+
mock_check_old.assert_has_calls([mock.call(), mock.call()])
311+
289312

290313
class TestWSGIService(test.NoDBTestCase):
291314

0 commit comments

Comments
 (0)