summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-24 12:11:46 +0000
committerGerrit Code Review <review@openstack.org>2018-10-24 12:11:46 +0000
commit66b02df4e466bbf01fdd4f9b2c0c9c39e337906a (patch)
tree1e803edacc24d7d534e57d95e9d4a34f63f7c624
parent4fdb274cbaca0a5d28f9c725ecf3c023f75213f7 (diff)
parentb03585d2ca54f24210b46e074edc657d88c9583b (diff)
Merge "Add framework for karbor-status upgrade check"
-rw-r--r--doc/source/cli/index.rst11
-rw-r--r--doc/source/cli/karbor-status.rst83
-rw-r--r--doc/source/index.rst1
-rw-r--r--karbor/cmd/status.py53
-rw-r--r--karbor/tests/unit/cmd/__init__.py0
-rw-r--r--karbor/tests/unit/cmd/test_status.py30
-rw-r--r--lower-constraints.txt1
-rw-r--r--releasenotes/notes/add-upgrade-check-framework-7e4f4c1b31f15272.yaml13
-rw-r--r--requirements.txt1
-rw-r--r--setup.cfg1
10 files changed, 194 insertions, 0 deletions
diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst
new file mode 100644
index 0000000..f59c1c3
--- /dev/null
+++ b/doc/source/cli/index.rst
@@ -0,0 +1,11 @@
1========================
2Karbor CLI Documentation
3========================
4
5In this section you will find information on Karbor’s command line
6interface.
7
8.. toctree::
9 :maxdepth: 1
10
11 karbor-status
diff --git a/doc/source/cli/karbor-status.rst b/doc/source/cli/karbor-status.rst
new file mode 100644
index 0000000..0ef7946
--- /dev/null
+++ b/doc/source/cli/karbor-status.rst
@@ -0,0 +1,83 @@
1=============
2karbor-status
3=============
4
5----------------------------------------
6CLI interface for Karbor status commands
7----------------------------------------
8
9Synopsis
10========
11
12::
13
14 karbor-status <category> <command> [<args>]
15
16Description
17===========
18
19:program:`karbor-status` is a tool that provides routines for checking the
20status of a Karbor deployment.
21
22Options
23=======
24
25The standard pattern for executing a :program:`karbor-status` command is::
26
27 karbor-status <category> <command> [<args>]
28
29Run without arguments to see a list of available command categories::
30
31 karbor-status
32
33Categories are:
34
35* ``upgrade``
36
37Detailed descriptions are below:
38
39You can also run with a category argument such as ``upgrade`` to see a list of
40all commands in that category::
41
42 karbor-status upgrade
43
44These sections describe the available categories and arguments for
45:program:`karbor-status`.
46
47Upgrade
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.
diff --git a/doc/source/index.rst b/doc/source/index.rst
index c24ad09..601789e 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -27,6 +27,7 @@ Using Karbor
27 readme 27 readme
28 install/index 28 install/index
29 configuration/index 29 configuration/index
30 cli/index
30 admin/index 31 admin/index
31 32
32Available Plugins 33Available Plugins
diff --git a/karbor/cmd/status.py b/karbor/cmd/status.py
new file mode 100644
index 0000000..c1c10b9
--- /dev/null
+++ b/karbor/cmd/status.py
@@ -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
15import sys
16
17from oslo_config import cfg
18from oslo_upgradecheck import upgradecheck
19
20from karbor.i18n import _
21
22CONF = cfg.CONF
23
24
25class 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
47def main():
48 return upgradecheck.main(
49 CONF, project='karbor', upgrade_command=Checks())
50
51
52if __name__ == '__main__':
53 sys.exit(main())
diff --git a/karbor/tests/unit/cmd/__init__.py b/karbor/tests/unit/cmd/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/karbor/tests/unit/cmd/__init__.py
diff --git a/karbor/tests/unit/cmd/test_status.py b/karbor/tests/unit/cmd/test_status.py
new file mode 100644
index 0000000..31deffc
--- /dev/null
+++ b/karbor/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 karbor.cmd import status
18from karbor.tests 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__sample_check(self):
28 check_result = self.cmd._sample_check()
29 self.assertEqual(
30 Code.SUCCESS, check_result.code)
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 76556b4..9e7e88d 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -78,6 +78,7 @@ oslo.middleware==3.31.0
78oslo.policy==1.30.0 78oslo.policy==1.30.0
79oslo.serialization==2.18.0 79oslo.serialization==2.18.0
80oslo.service==1.24.0 80oslo.service==1.24.0
81oslo.upgradecheck==0.1.0
81oslo.utils==3.36.0 82oslo.utils==3.36.0
82oslo.versionedobjects==1.31.2 83oslo.versionedobjects==1.31.2
83oslotest==3.2.0 84oslotest==3.2.0
diff --git a/releasenotes/notes/add-upgrade-check-framework-7e4f4c1b31f15272.yaml b/releasenotes/notes/add-upgrade-check-framework-7e4f4c1b31f15272.yaml
new file mode 100644
index 0000000..de82be5
--- /dev/null
+++ b/releasenotes/notes/add-upgrade-check-framework-7e4f4c1b31f15272.yaml
@@ -0,0 +1,13 @@
1---
2prelude: >
3 Added new tool ``karbor-status upgrade check``.
4features:
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.
9upgrade:
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.
diff --git a/requirements.txt b/requirements.txt
index 159bd16..e803e2c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -24,6 +24,7 @@ oslo.middleware>=3.31.0 # Apache-2.0
24oslo.policy>=1.30.0 # Apache-2.0 24oslo.policy>=1.30.0 # Apache-2.0
25oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 25oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
26oslo.service!=1.28.1,>=1.24.0 # Apache-2.0 26oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
27oslo.upgradecheck>=0.1.0 # Apache-2.0
27oslo.versionedobjects>=1.31.2 # Apache-2.0 28oslo.versionedobjects>=1.31.2 # Apache-2.0
28Paste>=2.0.2 # MIT 29Paste>=2.0.2 # MIT
29PasteDeploy>=1.5.0 # MIT 30PasteDeploy>=1.5.0 # MIT
diff --git a/setup.cfg b/setup.cfg
index 63fc899..4a3e73e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,6 +31,7 @@ console_scripts =
31 karbor-manage = karbor.cmd.manage:main 31 karbor-manage = karbor.cmd.manage:main
32 karbor-operationengine = karbor.cmd.operationengine:main 32 karbor-operationengine = karbor.cmd.operationengine:main
33 karbor-protection = karbor.cmd.protection:main 33 karbor-protection = karbor.cmd.protection:main
34 karbor-status = karbor.cmd.status:main
34oslo.config.opts = 35oslo.config.opts =
35 karbor.common.opts = karbor.common.opts:list_opts 36 karbor.common.opts = karbor.common.opts:list_opts
36oslo.policy.enforcer = 37oslo.policy.enforcer =