Skip to content

Commit 321d290

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add upgrade check about old computes"
2 parents bf0f9b1 + 3b8257c commit 321d290

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

doc/source/cli/nova-status.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ Upgrade
143143

144144
* Checks for the policy files is not JSON-formatted.
145145

146+
**23.0.0 (Wallaby)**
147+
148+
* Checks for computes older than the previous major release
149+
146150
See Also
147151
========
148152

doc/source/install/verify.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,7 @@ Verify operation of the Compute service.
131131
| Result: Success |
132132
| Details: None |
133133
+--------------------------------------------------------------------+
134+
| Check: Older than N-1 computes |
135+
| Result: Success |
136+
| Details: None |
137+
+--------------------------------------------------------------------+

nova/cmd/status.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,16 @@ def _check_policy_json(self):
427427
status = upgradecheck.Result(upgradecheck.Code.FAILURE, msg)
428428
return status
429429

430+
def _check_old_computes(self):
431+
# warn if there are computes in the system older than the previous
432+
# major release
433+
try:
434+
utils.raise_if_old_compute()
435+
except exception.TooOldComputeService as e:
436+
return upgradecheck.Result(upgradecheck.Code.WARNING, str(e))
437+
438+
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
439+
430440
# The format of the check functions is to return an upgradecheck.Result
431441
# object with the appropriate upgradecheck.Code and details set. If the
432442
# check hits warnings or failures then those should be stored in the
@@ -447,6 +457,8 @@ def _check_policy_json(self):
447457
(_('Policy Scope-based Defaults'), _check_policy),
448458
# Added in Victoria
449459
(_('Policy File JSON to YAML Migration'), _check_policy_json),
460+
# Added in Wallaby
461+
(_('Older than N-1 computes'), _check_old_computes)
450462
)
451463

452464

nova/tests/unit/cmd/test_status.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
# NOTE(mriedem): We only use objects as a convenience to populate the database
4545
# in the tests, we don't use them in the actual CLI.
4646
from nova import objects
47+
from nova.objects import service
4748
from nova import policy
4849
from nova import test
4950
from nova.tests import fixtures as nova_fixtures
@@ -667,3 +668,32 @@ def test_old_default_policy_json_file_fail_upgrade(self):
667668
jsonutils.dump(self.data, fh)
668669
self.assertEqual(upgradecheck.Code.FAILURE,
669670
self.cmd._check_policy_json().code)
671+
672+
673+
class TestUpgradeCheckOldCompute(test.NoDBTestCase):
674+
675+
def setUp(self):
676+
super(TestUpgradeCheckOldCompute, self).setUp()
677+
self.cmd = status.UpgradeCommands()
678+
679+
def test_no_compute(self):
680+
self.assertEqual(
681+
upgradecheck.Code.SUCCESS, self.cmd._check_old_computes().code)
682+
683+
def test_only_new_compute(self):
684+
last_supported_version = service.SERVICE_VERSION_ALIASES[
685+
service.OLDEST_SUPPORTED_SERVICE_VERSION]
686+
with mock.patch(
687+
"nova.objects.service.get_minimum_version_all_cells",
688+
return_value=last_supported_version):
689+
self.assertEqual(
690+
upgradecheck.Code.SUCCESS, self.cmd._check_old_computes().code)
691+
692+
def test_old_compute(self):
693+
too_old = service.SERVICE_VERSION_ALIASES[
694+
service.OLDEST_SUPPORTED_SERVICE_VERSION] - 1
695+
with mock.patch(
696+
"nova.objects.service.get_minimum_version_all_cells",
697+
return_value=too_old):
698+
result = self.cmd._check_old_computes()
699+
self.assertEqual(upgradecheck.Code.WARNING, result.code)

0 commit comments

Comments
 (0)