Skip to content

Commit 6ac1573

Browse files
committed
Stop handling cells v1 for console authentication
There were a lot of workarounds here to ensure we didn't switch to the new model (vs. the old 'nova-consoleauth' service) if users were on cells v1. These can go now, along with the old 'nova-consoleauth' service (though that's a later, separate change). Part of blueprint remove-cells-v1 Change-Id: I1b8f411b050d34e4e77e9a4f1e613135eb5f74b7 Signed-off-by: Stephen Finucane <[email protected]>
1 parent 7954b27 commit 6ac1573

File tree

13 files changed

+38
-114
lines changed

13 files changed

+38
-114
lines changed

nova/cmd/status.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,9 @@ def _check_console_auths(self):
389389
telling the user to set [workarounds]enable_consoleauth = True if they
390390
are performing a rolling upgrade.
391391
"""
392-
# If we're using cells v1, we don't need to check if the workaround
393-
# needs to be used because cells v1 always uses nova-consoleauth.
394392
# If the operator has already enabled the workaround, we don't need
395393
# to check anything.
396-
if CONF.cells.enable or CONF.workarounds.enable_consoleauth:
394+
if CONF.workarounds.enable_consoleauth:
397395
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
398396

399397
# We need to check cell0 for nova-consoleauth service records because

nova/compute/api.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,10 +2031,7 @@ def _delete(self, context, instance, delete_type, cb, **instance_attrs):
20312031
instance.progress = 0
20322032
instance.save()
20332033

2034-
# NOTE(dtp): cells.enable = False means "use cells v2".
2035-
# Run everywhere except v1 compute cells.
2036-
if (not CONF.cells.enable and CONF.workarounds.enable_consoleauth
2037-
) or self.cell_type == 'api':
2034+
if CONF.workarounds.enable_consoleauth:
20382035
# TODO(melwitt): Remove the conditions for running this line
20392036
# with cells v2, when consoleauth is no longer being used by
20402037
# cells v2, in Stein.
@@ -4551,7 +4548,7 @@ def live_migrate(self, context, instance, block_migration,
45514548
# we convert to using the database. Remove the condition for running
45524549
# this line with cells v2, when consoleauth is no longer being used by
45534550
# cells v2, in Stein.
4554-
if CONF.cells.enable or CONF.workarounds.enable_consoleauth:
4551+
if CONF.workarounds.enable_consoleauth:
45554552
self.consoleauth_rpcapi.delete_tokens_for_instance(
45564553
context, instance.uuid)
45574554

nova/compute/manager.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6927,8 +6927,8 @@ def _consoles_enabled(self):
69276927
def _clean_instance_console_tokens(self, ctxt, instance):
69286928
"""Clean console tokens stored for an instance."""
69296929
# If the database backend isn't in use, don't bother trying to clean
6930-
# tokens. The database backend is not supported for cells v1.
6931-
if not CONF.cells.enable and self._consoles_enabled():
6930+
# tokens.
6931+
if self._consoles_enabled():
69326932
objects.ConsoleAuthToken.\
69336933
clean_console_auths_for_instance(ctxt, instance.uuid)
69346934

@@ -8530,8 +8530,5 @@ def _cleanup_expired_console_auth_tokens(self, context):
85308530
instance. After a time they expire. We periodically remove any expired
85318531
tokens from the database.
85328532
"""
8533-
# If the database backend isn't in use, don't bother looking for
8534-
# expired tokens. The database backend is not supported for cells v1.
8535-
if not CONF.cells.enable:
8536-
objects.ConsoleAuthToken.\
8537-
clean_expired_console_auths_for_host(context, self.host)
8533+
objects.ConsoleAuthToken.clean_expired_console_auths_for_host(
8534+
context, self.host)

nova/conf/workarounds.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@
181181
token TTL of one hour, the operator may disable the flag, one hour after
182182
deploying the new code during an upgrade.
183183
184-
.. note:: Cells v1 was not converted to use the database backend for
185-
console token authorizations. Cells v1 console token authorizations will
186-
continue to be supported by the ``nova-consoleauth`` service and use of
187-
the ``[workarounds]/enable_consoleauth`` option does not apply to
188-
Cells v1 users.
189-
190184
Related options:
191185
192186
* ``[consoleauth]/token_ttl``

nova/console/websocketproxy.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,19 @@ def _get_connect_info_database(self, ctxt, token):
150150
def _get_connect_info(self, ctxt, token):
151151
"""Validate the token and get the connect info."""
152152
connect_info = None
153-
# NOTE(PaulMurray) if we are using cells v1, we use the old consoleauth
154-
# way of doing things. The database backend is not supported for cells
155-
# v1.
156-
if CONF.cells.enable:
153+
154+
# NOTE(melwitt): If consoleauth is enabled to aid in transitioning
155+
# to the database backend, check it first before falling back to
156+
# the database. Tokens that existed pre-database-backend will
157+
# reside in the consoleauth service storage.
158+
if CONF.workarounds.enable_consoleauth:
157159
connect_info = self._get_connect_info_consoleauth(ctxt, token)
158-
if not connect_info:
159-
raise exception.InvalidToken(token='***')
160-
else:
161-
# NOTE(melwitt): If consoleauth is enabled to aid in transitioning
162-
# to the database backend, check it first before falling back to
163-
# the database. Tokens that existed pre-database-backend will
164-
# reside in the consoleauth service storage.
165-
if CONF.workarounds.enable_consoleauth:
166-
connect_info = self._get_connect_info_consoleauth(ctxt, token)
167-
# If consoleauth is enabled to aid in transitioning to the database
168-
# backend and we didn't find a token in the consoleauth service
169-
# storage, check the database for a token because it's probably a
170-
# post-database-backend token, which are stored in the database.
171-
if not connect_info:
172-
connect_info = self._get_connect_info_database(ctxt, token)
160+
# If consoleauth is enabled to aid in transitioning to the database
161+
# backend and we didn't find a token in the consoleauth service
162+
# storage, check the database for a token because it's probably a
163+
# post-database-backend token, which are stored in the database.
164+
if not connect_info:
165+
connect_info = self._get_connect_info_database(ctxt, token)
173166

174167
return connect_info
175168

nova/consoleauth/manager.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from oslo_serialization import jsonutils
2424

2525
from nova import cache_utils
26-
from nova.cells import rpcapi as cells_rpcapi
2726
from nova.compute import rpcapi as compute_rpcapi
2827
import nova.conf
2928
from nova import context as nova_context
@@ -47,7 +46,6 @@ def __init__(self, scheduler_driver=None, *args, **kwargs):
4746
self._mc = None
4847
self._mc_instance = None
4948
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
50-
self.cells_rpcapi = cells_rpcapi.CellsAPI()
5149

5250
@property
5351
def mc(self):
@@ -109,13 +107,6 @@ def _validate_token(self, context, token):
109107
if instance_uuid is None:
110108
return False
111109

112-
# NOTE(comstud): consoleauth was meant to run in API cells. So,
113-
# if cells is enabled, we must call down to the child cell for
114-
# the instance.
115-
if CONF.cells.enable:
116-
return self.cells_rpcapi.validate_console_port(context,
117-
instance_uuid, token['port'], token['console_type'])
118-
119110
mapping = objects.InstanceMapping.get_by_instance_uuid(context,
120111
instance_uuid)
121112
with nova_context.target_cell(context, mapping.cell_mapping) as cctxt:

nova/tests/unit/cmd/test_status.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,6 @@ def _create_service_in_cell(ctxt, cell, binary, is_deleted=False,
662662

663663
return service
664664

665-
def test_check_cells_v1_enabled(self):
666-
"""This is a 'success' case since the console auths check is
667-
ignored when running cells v1.
668-
"""
669-
self.flags(enable=True, group='cells')
670-
result = self.cmd._check_console_auths()
671-
self.assertEqual(upgradecheck.Code.SUCCESS, result.code)
672-
673665
def test_check_workaround_enabled(self):
674666
"""This is a 'success' case since the console auths check is
675667
ignored when the workaround is already enabled.

nova/tests/unit/compute/test_compute.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10178,7 +10178,7 @@ def test_vnc_console(self, enable_consoleauth, mock_auth, mock_get):
1017810178
mock_get.assert_called_once_with(
1017910179
self.context, instance=fake_instance,
1018010180
console_type=fake_console_type)
10181-
if enable_consoleauth or CONF.cells.enable:
10181+
if enable_consoleauth:
1018210182
mock_auth.assert_called_once_with(
1018310183
self.context, 'fake_token', fake_console_type,
1018410184
'fake_console_host', 'fake_console_port', 'fake_access_path',
@@ -10222,7 +10222,7 @@ def test_spice_console(self, enable_consoleauth, mock_spice, mock_auth):
1022210222
mock_spice.assert_called_once_with(self.context,
1022310223
instance=fake_instance,
1022410224
console_type=fake_console_type)
10225-
if enable_consoleauth or CONF.cells.enable:
10225+
if enable_consoleauth:
1022610226
mock_auth.assert_called_once_with(
1022710227
self.context, 'fake_token', fake_console_type,
1022810228
'fake_console_host', 'fake_console_port', 'fake_access_path',
@@ -10283,7 +10283,7 @@ def test_rdp_console(self, enable_consoleauth, mock_rdp, mock_auth):
1028310283
self.assertEqual(console, {'url': 'fake_console_url'})
1028410284
mock_rdp.assert_called_once_with(self.context, instance=fake_instance,
1028510285
console_type=fake_console_type)
10286-
if enable_consoleauth or CONF.cells.enable:
10286+
if enable_consoleauth:
1028710287
mock_auth.assert_called_once_with(
1028810288
self.context, 'fake_token', fake_console_type,
1028910289
'fake_console_host', 'fake_console_port', 'fake_access_path',
@@ -11416,7 +11416,7 @@ def do_test(record_action_start, get_by_instance_uuid,
1141611416
disk_over_commit=True,
1141711417
request_spec=fake_spec, async_=False)
1141811418

11419-
if CONF.workarounds.enable_consoleauth or CONF.cells.enable:
11419+
if CONF.workarounds.enable_consoleauth:
1142011420
delete_tokens_for_instance.assert_called_once_with(
1142111421
self.context, instance.uuid)
1142211422
else:

nova/tests/unit/compute/test_compute_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,7 @@ def _reset_task_state(context, instance, migration, src_host,
12021202
mock_terminate.assert_called_once_with(
12031203
self.context, inst, [], delete_type=delete_type)
12041204

1205-
if ((self.cell_type is None and CONF.workarounds.enable_consoleauth)
1206-
or self.cell_type == 'api'):
1205+
if CONF.workarounds.enable_consoleauth:
12071206
mock_del_token.assert_called_once_with(self.context, instance_uuid)
12081207
else:
12091208
mock_del_token.assert_not_called()

nova/tests/unit/compute/test_compute_cells.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import functools
2020
import inspect
2121

22+
import ddt
2223
import mock
2324
from oslo_utils.fixture import uuidsentinel as uuids
2425
from oslo_utils import timeutils
@@ -110,6 +111,7 @@ def deploy_stubs(stubs, api, original_instance=None):
110111
stubs.Set(api, '_cast_to_cells', cast)
111112

112113

114+
@ddt.ddt
113115
class CellsComputeAPITestCase(test_compute.ComputeAPITestCase):
114116
def setUp(self):
115117
self.flags(use_neutron=False)
@@ -520,6 +522,18 @@ def test_multi_instance_display_name(self):
520522
super(CellsComputeAPITestCase,
521523
self).test_multi_instance_display_name(cells_enabled=True)
522524

525+
@ddt.data(True, False)
526+
def test_rdp_console(self, enabled_consoleauth):
527+
self.skipTest("Removing cells v1")
528+
529+
@ddt.data(True, False)
530+
def test_spice_console(self, enabled_consoleauth):
531+
self.skipTest("Removing cells v1")
532+
533+
@ddt.data(True, False)
534+
def test_vnc_console(self, enabled_consoleauth):
535+
self.skipTest("Removing cells v1")
536+
523537

524538
class CellsShelveComputeAPITestCase(test_shelve.ShelveComputeAPITestCase):
525539
def setUp(self):

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4605,8 +4605,6 @@ def test_delete_scheduler_instance_info(self, mock_delete):
46054605
'clean_console_auths_for_instance')
46064606
def test_clean_instance_console_tokens(self, g1, g2, g3, g4, g5,
46074607
mock_clean):
4608-
# Make sure cells v1 is disabled
4609-
self.flags(enable=False, group='cells')
46104608
# Enable one of each of the console types and disable the rest
46114609
self.flags(enabled=True, group=g1)
46124610
for g in [g2, g3, g4, g5]:
@@ -4625,30 +4623,12 @@ def test_clean_instance_console_tokens_no_consoles_enabled(self,
46254623
self.compute._clean_instance_console_tokens(self.context, instance)
46264624
mock_clean.assert_not_called()
46274625

4628-
@mock.patch('nova.objects.ConsoleAuthToken.'
4629-
'clean_console_auths_for_instance')
4630-
def test_clean_instance_console_tokens_cells_v1_enabled(self, mock_clean):
4631-
# Enable cells v1
4632-
self.flags(enable=True, group='cells')
4633-
self.flags(enabled=True, group='vnc')
4634-
instance = objects.Instance(uuid=uuids.instance)
4635-
self.compute._clean_instance_console_tokens(self.context, instance)
4636-
mock_clean.assert_not_called()
4637-
46384626
@mock.patch('nova.objects.ConsoleAuthToken.'
46394627
'clean_expired_console_auths_for_host')
46404628
def test_cleanup_expired_console_auth_tokens(self, mock_clean):
4641-
# Make sure cells v1 is disabled
4642-
self.flags(enable=False, group='cells')
46434629
self.compute._cleanup_expired_console_auth_tokens(self.context)
46444630
mock_clean.assert_called_once_with(self.context, self.compute.host)
46454631

4646-
# Enable cells v1
4647-
mock_clean.reset_mock()
4648-
self.flags(enable=True, group='cells')
4649-
self.compute._cleanup_expired_console_auth_tokens(self.context)
4650-
mock_clean.assert_not_called()
4651-
46524632
@mock.patch.object(nova.context.RequestContext, 'elevated')
46534633
@mock.patch.object(nova.objects.InstanceList, 'get_by_host')
46544634
@mock.patch.object(nova.scheduler.client.query.SchedulerQueryClient,

nova/tests/unit/console/test_websocketproxy.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,26 +197,6 @@ def setUp(self):
197197
'Host': 'example.net:6080',
198198
}
199199

200-
@mock.patch('nova.consoleauth.rpcapi.ConsoleAuthAPI.check_token')
201-
def test_new_websocket_client_with_server_with_cells(self, check_token):
202-
# this test cells enabled, so consoleauth should be used
203-
CONF.set_override('enable', True, group='cells')
204-
check_token.return_value = {
205-
'host': 'node1',
206-
'port': '10000',
207-
'console_type': 'novnc',
208-
'access_url': 'https://example.net:6080'
209-
}
210-
self.wh.socket.return_value = '<socket>'
211-
self.wh.path = "http://127.0.0.1/?token=123-456-789"
212-
self.wh.headers = self.fake_header
213-
214-
self.wh.new_websocket_client()
215-
216-
check_token.assert_called_with(mock.ANY, token="123-456-789")
217-
self.wh.socket.assert_called_with('node1', 10000, connect=True)
218-
self.wh.do_proxy.assert_called_with('<socket>')
219-
220200
@mock.patch('nova.consoleauth.rpcapi.ConsoleAuthAPI.check_token')
221201
def test_new_websocket_client_enable_consoleauth(self, check_token):
222202
self.flags(enable_consoleauth=True, group='workarounds')

nova/tests/unit/consoleauth/test_consoleauth.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,3 @@ def test_delete_tokens_for_instance_encoding(self):
238238
mock_instance_get.assert_has_calls([mock.call(b'instance')])
239239
mock_instance_delete.assert_has_calls([mock.call(b'instance')])
240240
mock_delete_multi.assert_has_calls([mock.call([b'token'])])
241-
242-
243-
class CellsConsoleauthTestCase(ConsoleauthTestCase):
244-
"""Test Case for consoleauth w/ cells enabled."""
245-
246-
rpcapi = 'nova.cells.rpcapi.CellsAPI.'
247-
248-
def setUp(self):
249-
super(CellsConsoleauthTestCase, self).setUp()
250-
self.flags(enable=True, group='cells')
251-
self.is_cells = True

0 commit comments

Comments
 (0)