summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Gibizer <balazs.gibizer@est.tech>2020-10-30 10:41:06 +0100
committerBalazs Gibizer <balazs.gibizer@est.tech>2021-01-11 14:05:08 +0000
commit4e5b92545db5f5434bcfeab90bae1a8555a54dd4 (patch)
tree4aa6b6ed8d03284b88812c19930fef764c852453
parentcb4963ba8c4babb7e460d71daf91099fc6da1dc6 (diff)
downloadnova-4e5b92545db5f5434bcfeab90bae1a8555a54dd4.tar.gz
Add upgrade check about old computes
Report a warning during upgrade checks if there are computes older than the previous major nova release in the system. So if code is upgraded to N+1 and the upgrade check was run before the restart of the services with N+1 code then the check warns for N-1 computes in the system. There are small modification in the documentation and code comment to align it to the Victoria context. Related-Bug: #1903545 Change-Id: I873b0c1e6e695ae88241bbf75ac9f80ecc6f5664 (cherry picked from commit 3b8257cd239d0bb52cb654d709cc579ca9841628)
-rw-r--r--doc/source/cli/nova-status.rst2
-rw-r--r--doc/source/install/verify.rst4
-rw-r--r--nova/cmd/status.py12
-rw-r--r--nova/tests/unit/cmd/test_status.py30
4 files changed, 48 insertions, 0 deletions
diff --git a/doc/source/cli/nova-status.rst b/doc/source/cli/nova-status.rst
index 9eae13b43d..96ae333c1c 100644
--- a/doc/source/cli/nova-status.rst
+++ b/doc/source/cli/nova-status.rst
@@ -142,6 +142,8 @@ Upgrade
**22.0.0 (Victoria)**
* Checks for the policy files is not JSON-formatted.
+ * Checks for computes older than the previous major release. This check was
+ backported from 23.0.0 (Wallaby).
See Also
========
diff --git a/doc/source/install/verify.rst b/doc/source/install/verify.rst
index 440abc7e71..9c67e4574e 100644
--- a/doc/source/install/verify.rst
+++ b/doc/source/install/verify.rst
@@ -131,3 +131,7 @@ Verify operation of the Compute service.
| Result: Success |
| Details: None |
+--------------------------------------------------------------------+
+ | Check: Older than N-1 computes |
+ | Result: Success |
+ | Details: None |
+ +--------------------------------------------------------------------+
diff --git a/nova/cmd/status.py b/nova/cmd/status.py
index fd3c307dca..8036d550fa 100644
--- a/nova/cmd/status.py
+++ b/nova/cmd/status.py
@@ -427,6 +427,16 @@ class UpgradeCommands(upgradecheck.UpgradeCommands):
status = upgradecheck.Result(upgradecheck.Code.FAILURE, msg)
return status
+ def _check_old_computes(self):
+ # warn if there are computes in the system older than the previous
+ # major release
+ try:
+ utils.raise_if_old_compute()
+ except exception.TooOldComputeService as e:
+ return upgradecheck.Result(upgradecheck.Code.WARNING, str(e))
+
+ return upgradecheck.Result(upgradecheck.Code.SUCCESS)
+
# The format of the check functions is to return an upgradecheck.Result
# object with the appropriate upgradecheck.Code and details set. If the
# check hits warnings or failures then those should be stored in the
@@ -447,6 +457,8 @@ class UpgradeCommands(upgradecheck.UpgradeCommands):
(_('Policy Scope-based Defaults'), _check_policy),
# Added in Victoria
(_('Policy File JSON to YAML Migration'), _check_policy_json),
+ # Backported from Wallaby
+ (_('Older than N-1 computes'), _check_old_computes)
)
diff --git a/nova/tests/unit/cmd/test_status.py b/nova/tests/unit/cmd/test_status.py
index 6922a2a6e0..f5f2a8b634 100644
--- a/nova/tests/unit/cmd/test_status.py
+++ b/nova/tests/unit/cmd/test_status.py
@@ -44,6 +44,7 @@ from nova import exception
# NOTE(mriedem): We only use objects as a convenience to populate the database
# in the tests, we don't use them in the actual CLI.
from nova import objects
+from nova.objects import service
from nova import policy
from nova import test
from nova.tests import fixtures as nova_fixtures
@@ -667,3 +668,32 @@ class TestUpgradeCheckPolicyJSON(test.NoDBTestCase):
jsonutils.dump(self.data, fh)
self.assertEqual(upgradecheck.Code.FAILURE,
self.cmd._check_policy_json().code)
+
+
+class TestUpgradeCheckOldCompute(test.NoDBTestCase):
+
+ def setUp(self):
+ super(TestUpgradeCheckOldCompute, self).setUp()
+ self.cmd = status.UpgradeCommands()
+
+ def test_no_compute(self):
+ self.assertEqual(
+ upgradecheck.Code.SUCCESS, self.cmd._check_old_computes().code)
+
+ def test_only_new_compute(self):
+ last_supported_version = service.SERVICE_VERSION_ALIASES[
+ service.OLDEST_SUPPORTED_SERVICE_VERSION]
+ with mock.patch(
+ "nova.objects.service.get_minimum_version_all_cells",
+ return_value=last_supported_version):
+ self.assertEqual(
+ upgradecheck.Code.SUCCESS, self.cmd._check_old_computes().code)
+
+ def test_old_compute(self):
+ too_old = service.SERVICE_VERSION_ALIASES[
+ service.OLDEST_SUPPORTED_SERVICE_VERSION] - 1
+ with mock.patch(
+ "nova.objects.service.get_minimum_version_all_cells",
+ return_value=too_old):
+ result = self.cmd._check_old_computes()
+ self.assertEqual(upgradecheck.Code.WARNING, result.code)