summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhoami-rajat <rajatdhasmana@gmail.com>2018-10-23 16:40:14 +0530
committerwhoami-rajat <rajatdhasmana@gmail.com>2018-10-23 16:51:51 +0530
commitd75eaff065f876383ff3aedf6ef53bb26522f05c (patch)
treebf45b5ffa6a791a6a62639a48c0afeb18d19676b
parent23ee4d15b85c6d0dedc4e69c0c7109bdf2a3d810 (diff)
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
Notes
Notes (review): Code-Review+1: Akhil jain <akhil.jain@india.nec.com> Code-Review+1: Matt Riedemann <mriedem.os@gmail.com> Code-Review+2: Berezovsky Irena <irenab.dev@gmail.com> Code-Review+1: melissaml <ma.lei@99cloud.net> Code-Review+2: Daniel Mellado <dmellado@redhat.com> Workflow+1: Daniel Mellado <dmellado@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 19 Nov 2018 22:07:11 +0000 Reviewed-on: https://review.openstack.org/612667 Project: openstack/kuryr Branch: refs/heads/master
-rw-r--r--doc/source/cli/index.rst7
-rw-r--r--doc/source/cli/kuryr-status.rst78
-rw-r--r--doc/source/index.rst1
-rw-r--r--kuryr/cmd/__init__.py0
-rw-r--r--kuryr/cmd/status.py54
-rw-r--r--kuryr/tests/unit/cmd/__init__.py0
-rw-r--r--kuryr/tests/unit/cmd/test_status.py30
-rw-r--r--lower-constraints.txt1
-rw-r--r--releasenotes/notes/kuryr-status-upgrade-check-framework-77b478d559020b92.yaml13
-rw-r--r--requirements.txt1
-rw-r--r--setup.cfg3
11 files changed, 188 insertions, 0 deletions
diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst
new file mode 100644
index 0000000..3365c27
--- /dev/null
+++ b/doc/source/cli/index.rst
@@ -0,0 +1,7 @@
1CLI Reference
2=============
3
4.. toctree::
5 :maxdepth: 1
6
7 kuryr-status
diff --git a/doc/source/cli/kuryr-status.rst b/doc/source/cli/kuryr-status.rst
new file mode 100644
index 0000000..1a5ac2f
--- /dev/null
+++ b/doc/source/cli/kuryr-status.rst
@@ -0,0 +1,78 @@
1============
2kuryr-status
3============
4
5Synopsis
6========
7
8::
9
10 kuryr-status <category> <command> [<args>]
11
12Description
13===========
14
15:program:`kuryr-status` is a tool that provides routines for checking the
16status of a Kuryr deployment.
17
18Options
19=======
20
21The standard pattern for executing a :program:`kuryr-status` command is::
22
23 kuryr-status <category> <command> [<args>]
24
25Run without arguments to see a list of available command categories::
26
27 kuryr-status
28
29Categories are:
30
31* ``upgrade``
32
33Detailed descriptions are below.
34
35You can also run with a category argument such as ``upgrade`` to see a list of
36all commands in that category::
37
38 kuryr-status upgrade
39
40These sections describe the available categories and arguments for
41:program:`kuryr-status`.
42
43Upgrade
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.
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 92813f4..c1a4d48 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -29,6 +29,7 @@ Contents:
29 installation 29 installation
30 usage 30 usage
31 contributing 31 contributing
32 cli/index
32 releasenotes 33 releasenotes
33 34
34Design and Developer Docs 35Design and Developer Docs
diff --git a/kuryr/cmd/__init__.py b/kuryr/cmd/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/kuryr/cmd/__init__.py
diff --git a/kuryr/cmd/status.py b/kuryr/cmd/status.py
new file mode 100644
index 0000000..be09540
--- /dev/null
+++ b/kuryr/cmd/status.py
@@ -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
15import sys
16
17from oslo_config import cfg
18from oslo_upgradecheck import upgradecheck
19
20from kuryr.lib._i18n import _
21
22
23class 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
49def main():
50 return upgradecheck.main(
51 cfg.CONF, project='kuryr', upgrade_command=Checks())
52
53if __name__ == '__main__':
54 sys.exit(main())
diff --git a/kuryr/tests/unit/cmd/__init__.py b/kuryr/tests/unit/cmd/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/kuryr/tests/unit/cmd/__init__.py
diff --git a/kuryr/tests/unit/cmd/test_status.py b/kuryr/tests/unit/cmd/test_status.py
new file mode 100644
index 0000000..8fa4a00
--- /dev/null
+++ b/kuryr/tests/unit/cmd/test_status.py
@@ -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
15from oslo_upgradecheck.upgradecheck import Code
16
17from kuryr.cmd import status
18from kuryr.tests.unit import base
19
20
21class 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)
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 554bc4b..d62e572 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -62,6 +62,7 @@ oslo.middleware==3.31.0
62oslo.policy==1.30.0 62oslo.policy==1.30.0
63oslo.serialization==2.18.0 63oslo.serialization==2.18.0
64oslo.service==1.24.0 64oslo.service==1.24.0
65oslo.upgradecheck==0.1.0
65oslo.utils==3.33.0 66oslo.utils==3.33.0
66oslotest==3.2.0 67oslotest==3.2.0
67Paste==2.0.2 68Paste==2.0.2
diff --git a/releasenotes/notes/kuryr-status-upgrade-check-framework-77b478d559020b92.yaml b/releasenotes/notes/kuryr-status-upgrade-check-framework-77b478d559020b92.yaml
new file mode 100644
index 0000000..6a884cb
--- /dev/null
+++ b/releasenotes/notes/kuryr-status-upgrade-check-framework-77b478d559020b92.yaml
@@ -0,0 +1,13 @@
1---
2prelude: >
3 Added new tool ``kuryr-status upgrade check``.
4features:
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.
9upgrade:
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.
diff --git a/requirements.txt b/requirements.txt
index d46278d..8ae7f7b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,6 +9,7 @@ neutron-lib>=1.13.0 # Apache-2.0
9oslo.concurrency>=3.25.0 # Apache-2.0 9oslo.concurrency>=3.25.0 # Apache-2.0
10oslo.i18n>=3.15.3 # Apache-2.0 10oslo.i18n>=3.15.3 # Apache-2.0
11oslo.log>=3.36.0 # Apache-2.0 11oslo.log>=3.36.0 # Apache-2.0
12oslo.upgradecheck>=0.1.0 # Apache-2.0
12oslo.utils>=3.33.0 # Apache-2.0 13oslo.utils>=3.33.0 # Apache-2.0
13pbr!=2.1.0,>=2.0.0 # Apache-2.0 14pbr!=2.1.0,>=2.0.0 # Apache-2.0
14pyroute2>=0.4.21;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2) 15pyroute2>=0.4.21;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
diff --git a/setup.cfg b/setup.cfg
index 6b4b1ff..3f179a7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -25,6 +25,9 @@ universal = 1
25oslo.config.opts = 25oslo.config.opts =
26 kuryr = kuryr.lib.opts:list_kuryr_opts 26 kuryr = kuryr.lib.opts:list_kuryr_opts
27 27
28console_scripts =
29 kuryr-status = kuryr.cmd.status:main
30
28[files] 31[files]
29packages = 32packages =
30 kuryr 33 kuryr