Browse Source

Add kuryr-status upgrade check command framework

This adds basic framework for kuryr-status upgrade
check commands. For now it has only "check_placeholder"
check implemented.
Real checks can be added to this tool in the future.

Change-Id: I8af38f087672a390ec8b2b78916315b5a646fcbb
Story: 2003657
Task: 26137
whoami-rajat 6 months ago
parent
commit
d75eaff065

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

@@ -0,0 +1,7 @@
1
+CLI Reference
2
+=============
3
+
4
+.. toctree::
5
+   :maxdepth: 1
6
+
7
+   kuryr-status

+ 78
- 0
doc/source/cli/kuryr-status.rst View File

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

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

@@ -29,6 +29,7 @@ Contents:
29 29
    installation
30 30
    usage
31 31
    contributing
32
+   cli/index
32 33
    releasenotes
33 34
 
34 35
 Design and Developer Docs

+ 0
- 0
kuryr/cmd/__init__.py View File


+ 54
- 0
kuryr/cmd/status.py View File

@@ -0,0 +1,54 @@
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 kuryr.lib._i18n import _
21
+
22
+
23
+class Checks(upgradecheck.UpgradeCommands):
24
+
25
+    """Upgrade checks for the kuryr-status upgrade check command
26
+
27
+    Upgrade checks should be added as separate methods in this class
28
+    and added to _upgrade_checks tuple.
29
+    """
30
+
31
+    def _check_placeholder(self):
32
+        # This is just a placeholder for upgrade checks, it should be
33
+        # removed when the actual checks are added
34
+        return upgradecheck.Result(upgradecheck.Code.SUCCESS)
35
+
36
+    # The format of the check functions is to return an
37
+    # oslo_upgradecheck.upgradecheck.Result
38
+    # object with the appropriate
39
+    # oslo_upgradecheck.upgradecheck.Code and details set.
40
+    # If the check hits warnings or failures then those should be stored
41
+    # in the returned Result's "details" attribute. The
42
+    # summary will be rolled up at the end of the check() method.
43
+    _upgrade_checks = (
44
+        # In the future there should be some real checks added here
45
+        (_('Placeholder'), _check_placeholder),
46
+    )
47
+
48
+
49
+def main():
50
+    return upgradecheck.main(
51
+        cfg.CONF, project='kuryr', upgrade_command=Checks())
52
+
53
+if __name__ == '__main__':
54
+    sys.exit(main())

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


+ 30
- 0
kuryr/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 kuryr.cmd import status
18
+from kuryr.tests.unit 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__check_placeholder(self):
28
+        check_result = self.cmd._check_placeholder()
29
+        self.assertEqual(
30
+            Code.SUCCESS, check_result.code)

+ 1
- 0
lower-constraints.txt View File

@@ -62,6 +62,7 @@ oslo.middleware==3.31.0
62 62
 oslo.policy==1.30.0
63 63
 oslo.serialization==2.18.0
64 64
 oslo.service==1.24.0
65
+oslo.upgradecheck==0.1.0
65 66
 oslo.utils==3.33.0
66 67
 oslotest==3.2.0
67 68
 Paste==2.0.2

+ 13
- 0
releasenotes/notes/kuryr-status-upgrade-check-framework-77b478d559020b92.yaml View File

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

+ 1
- 0
requirements.txt View File

@@ -9,6 +9,7 @@ neutron-lib>=1.13.0 # Apache-2.0
9 9
 oslo.concurrency>=3.25.0 # Apache-2.0
10 10
 oslo.i18n>=3.15.3 # Apache-2.0
11 11
 oslo.log>=3.36.0 # Apache-2.0
12
+oslo.upgradecheck>=0.1.0 # Apache-2.0
12 13
 oslo.utils>=3.33.0 # Apache-2.0
13 14
 pbr!=2.1.0,>=2.0.0 # Apache-2.0
14 15
 pyroute2>=0.4.21;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)

+ 3
- 0
setup.cfg View File

@@ -25,6 +25,9 @@ universal = 1
25 25
 oslo.config.opts =
26 26
     kuryr = kuryr.lib.opts:list_kuryr_opts
27 27
 
28
+console_scripts =
29
+    kuryr-status = kuryr.cmd.status:main
30
+
28 31
 [files]
29 32
 packages =
30 33
     kuryr

Loading…
Cancel
Save