Browse Source

Add framework for karbor-status upgrade check

This commit adds the functionality of karbor-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: I8b75d516725c7cdf169d558b1c4b6f92a695ab2e
Story: 2003657
Task: 26134
akhiljain23 6 months ago
parent
commit
b03585d2ca

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

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

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

@@ -0,0 +1,83 @@
1
+=============
2
+karbor-status
3
+=============
4
+
5
+----------------------------------------
6
+CLI interface for Karbor status commands
7
+----------------------------------------
8
+
9
+Synopsis
10
+========
11
+
12
+::
13
+
14
+  karbor-status <category> <command> [<args>]
15
+
16
+Description
17
+===========
18
+
19
+:program:`karbor-status` is a tool that provides routines for checking the
20
+status of a Karbor deployment.
21
+
22
+Options
23
+=======
24
+
25
+The standard pattern for executing a :program:`karbor-status` command is::
26
+
27
+    karbor-status <category> <command> [<args>]
28
+
29
+Run without arguments to see a list of available command categories::
30
+
31
+    karbor-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
+    karbor-status upgrade
43
+
44
+These sections describe the available categories and arguments for
45
+:program:`karbor-status`.
46
+
47
+Upgrade
48
+~~~~~~~
49
+
50
+.. _karbor-status-checks:
51
+
52
+``karbor-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
+  **x.x.x (Stein)**
82
+
83
+  * Sample check to be filled in with checks as they are added in Stein.

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

@@ -27,6 +27,7 @@ Using Karbor
27 27
    readme
28 28
    install/index
29 29
    configuration/index
30
+   cli/index
30 31
    admin/index
31 32
 
32 33
 Available Plugins

+ 53
- 0
karbor/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 karbor.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='karbor', upgrade_command=Checks())
50
+
51
+
52
+if __name__ == '__main__':
53
+    sys.exit(main())

+ 0
- 0
karbor/tests/unit/cmd/__init__.py View File


+ 30
- 0
karbor/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 karbor.cmd import status
18
+from karbor.tests import base
19
+
20
+
21
+class TestUpgradeChecks(base.TestCase):
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)

+ 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.36.0
82 83
 oslo.versionedobjects==1.31.2
83 84
 oslotest==3.2.0

+ 13
- 0
releasenotes/notes/add-upgrade-check-framework-7e4f4c1b31f15272.yaml View File

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

+ 1
- 0
requirements.txt View File

@@ -24,6 +24,7 @@ oslo.middleware>=3.31.0 # Apache-2.0
24 24
 oslo.policy>=1.30.0 # Apache-2.0
25 25
 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
26 26
 oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
27
+oslo.upgradecheck>=0.1.0 # Apache-2.0
27 28
 oslo.versionedobjects>=1.31.2 # Apache-2.0
28 29
 Paste>=2.0.2 # MIT
29 30
 PasteDeploy>=1.5.0 # MIT

+ 1
- 0
setup.cfg View File

@@ -31,6 +31,7 @@ console_scripts =
31 31
     karbor-manage = karbor.cmd.manage:main
32 32
     karbor-operationengine = karbor.cmd.operationengine:main
33 33
     karbor-protection = karbor.cmd.protection:main
34
+    karbor-status = karbor.cmd.status:main
34 35
 oslo.config.opts =
35 36
     karbor.common.opts = karbor.common.opts:list_opts
36 37
 oslo.policy.enforcer =

Loading…
Cancel
Save