Browse Source

Add framework for murano-status upgrade check

This commit adds the functionality of murano-status CLI for performing
upgrade checks as part of the Stein cycle upgrade-checkers goal.
It only includes a sample check which must be replaced by real checks in
future.

Change-Id: If7987cdf5d9a686abbcad5960b8f391f8b9518a3
Story: 2003657
Task: 26143
akhiljain23 6 months ago
parent
commit
4341093b14

+ 11
- 0
doc/source/cli/index.rst View File

@@ -0,0 +1,11 @@
1
+========================
2
+Murano CLI Documentation
3
+========================
4
+
5
+In this section you will find information on Murano's command line
6
+interface.
7
+
8
+.. toctree::
9
+   :maxdepth: 1
10
+
11
+   murano-status

+ 83
- 0
doc/source/cli/murano-status.rst View File

@@ -0,0 +1,83 @@
1
+=============
2
+murano-status
3
+=============
4
+
5
+----------------------------------------
6
+CLI interface for Murano status commands
7
+----------------------------------------
8
+
9
+Synopsis
10
+========
11
+
12
+::
13
+
14
+  murano-status <category> <command> [<args>]
15
+
16
+Description
17
+===========
18
+
19
+:program:`murano-status` is a tool that provides routines for checking the
20
+status of a Murano deployment.
21
+
22
+Options
23
+=======
24
+
25
+The standard pattern for executing a :program:`murano-status` command is::
26
+
27
+    murano-status <category> <command> [<args>]
28
+
29
+Run without arguments to see a list of available command categories::
30
+
31
+    murano-status
32
+
33
+Categories are:
34
+
35
+* ``upgrade``
36
+
37
+Detailed descriptions are below:
38
+
39
+You can also run with a category argument such as ``upgrade`` to see a list of
40
+all commands in that category::
41
+
42
+    murano-status upgrade
43
+
44
+These sections describe the available categories and arguments for
45
+:program:`murano-status`.
46
+
47
+Upgrade
48
+~~~~~~~
49
+
50
+.. _murano-status-checks:
51
+
52
+``murano-status upgrade check``
53
+  Performs a release-specific readiness check before restarting services with
54
+  new code. For example, missing or changed configuration options,
55
+  incompatible object states, or other conditions that could lead to
56
+  failures while upgrading.
57
+
58
+  **Return Codes**
59
+
60
+  .. list-table::
61
+     :widths: 20 80
62
+     :header-rows: 1
63
+
64
+     * - Return code
65
+       - Description
66
+     * - 0
67
+       - All upgrade readiness checks passed successfully and there is nothing
68
+         to do.
69
+     * - 1
70
+       - At least one check encountered an issue and requires further
71
+         investigation. This is considered a warning but the upgrade may be OK.
72
+     * - 2
73
+       - There was an upgrade status check failure that needs to be
74
+         investigated. This should be considered something that stops an
75
+         upgrade.
76
+     * - 255
77
+       - An unexpected error occurred.
78
+
79
+  **History of Checks**
80
+
81
+  **7.0.0 (Stein)**
82
+
83
+  * Sample check to be filled in with checks as they are added in Stein.

+ 8
- 0
doc/source/index.rst View File

@@ -67,6 +67,14 @@ Configuration
67 67
 
68 68
   configuration/index
69 69
 
70
+CLI Guide
71
+~~~~~~~~~
72
+
73
+.. toctree::
74
+  :maxdepth: 2
75
+
76
+  cli/index
77
+
70 78
 Administrator Documentation
71 79
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 80
 

+ 1
- 0
lower-constraints.txt View File

@@ -78,6 +78,7 @@ oslo.middleware==3.31.0
78 78
 oslo.policy==1.30.0
79 79
 oslo.serialization==2.18.0
80 80
 oslo.service==1.24.0
81
+oslo.upgradecheck==0.1.0
81 82
 oslo.utils==3.33.0
82 83
 oslotest==3.2.0
83 84
 packaging==17.1

+ 53
- 0
murano/cmd/status.py View File

@@ -0,0 +1,53 @@
1
+# Copyright (c) 2018 NEC, Corp.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+import sys
16
+
17
+from oslo_config import cfg
18
+from oslo_upgradecheck import upgradecheck
19
+
20
+from murano.common.i18n import _
21
+
22
+CONF = cfg.CONF
23
+
24
+
25
+class Checks(upgradecheck.UpgradeCommands):
26
+
27
+    """Contains upgrade checks
28
+
29
+    Various upgrade checks should be added as separate methods in this class
30
+    and added to _upgrade_checks tuple.
31
+    """
32
+
33
+    def _sample_check(self):
34
+        """This is sample check added to test the upgrade check framework
35
+
36
+        It needs to be removed after adding any real upgrade check
37
+        """
38
+        return upgradecheck.Result(upgradecheck.Code.SUCCESS, 'Sample detail')
39
+
40
+    _upgrade_checks = (
41
+        # Sample check added for now.
42
+        # Whereas in future real checks must be added here in tuple
43
+        (_('Sample Check'), _sample_check),
44
+    )
45
+
46
+
47
+def main():
48
+    return upgradecheck.main(
49
+        CONF, project='murano', upgrade_command=Checks())
50
+
51
+
52
+if __name__ == '__main__':
53
+    sys.exit(main())

+ 30
- 0
murano/tests/unit/cmd/test_status.py View File

@@ -0,0 +1,30 @@
1
+# Copyright (c) 2018 NEC, Corp.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+from oslo_upgradecheck.upgradecheck import Code
16
+
17
+from murano.cmd import status
18
+from murano.tests.unit import base
19
+
20
+
21
+class TestUpgradeChecks(base.MuranoTestCase):
22
+
23
+    def setUp(self):
24
+        super(TestUpgradeChecks, self).setUp()
25
+        self.cmd = status.Checks()
26
+
27
+    def test__sample_check(self):
28
+        check_result = self.cmd._sample_check()
29
+        self.assertEqual(
30
+            Code.SUCCESS, check_result.code)

+ 13
- 0
releasenotes/notes/add-upgrade-check-framework-1c069e5a54125d1b.yaml View File

@@ -0,0 +1,13 @@
1
+---
2
+prelude: >
3
+    Added new tool ``murano-status upgrade check``.
4
+features:
5
+  - |
6
+    New framework for ``murano-status upgrade check`` command is added.
7
+    This framework allows adding various checks which can be run before a
8
+    Murano upgrade to ensure if the upgrade can be performed safely.
9
+upgrade:
10
+  - |
11
+    Operator can now use new CLI tool ``murano-status upgrade check``
12
+    to check if Murano deployment can be safely upgraded from
13
+    N-1 to N release.

+ 1
- 0
requirements.txt View File

@@ -46,5 +46,6 @@ oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
46 46
 oslo.utils>=3.33.0 # Apache-2.0
47 47
 oslo.i18n>=3.15.3 # Apache-2.0
48 48
 oslo.log>=3.36.0 # Apache-2.0
49
+oslo.upgradecheck>=0.1.0 # Apache-2.0
49 50
 semantic-version>=2.3.1 # BSD
50 51
 castellan>=0.16.0 # Apache-2.0

+ 1
- 0
setup.cfg View File

@@ -56,6 +56,7 @@ console_scripts =
56 56
     murano-cfapi-db-manage = murano.cmd.cfapi_db_manage:main
57 57
     murano-test-runner = murano.cmd.test_runner:main
58 58
     murano-cfapi = murano.cmd.cfapi:main
59
+    murano-status = murano.cmd.status:main
59 60
 
60 61
 wsgi_scripts =
61 62
     murano-wsgi-api = murano.httpd.murano_api:init_application

Loading…
Cancel
Save