From 1729c889c2d81917c3e56189e05f3f91949208f9 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Fri, 21 Sep 2018 14:37:48 -0500 Subject: [PATCH] Base framework for cinder-status upgrade check This adds the cinder-status CLI for performing upgrade checks as part of the Stein cycle upgrade-checkers goal. It only includes a placeholder for actual checks. Follow up patches will need to be added for anything we identify as needing specific checking. Story: 2003657 Task: 26123 Change-Id: I2e532d313d12e60848b17e869882e52ec456929b Signed-off-by: Sean McGinnis --- cinder/cmd/status.py | 47 +++++++++ doc/source/cli/cinder-status.rst | 98 +++++++++++++++++++ doc/source/cli/index.rst | 1 + doc/source/conf.py | 4 +- lower-constraints.txt | 1 + .../upgrade-checks-e58c4a81c857847d.yaml | 10 ++ requirements.txt | 1 + setup.cfg | 1 + 8 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 cinder/cmd/status.py create mode 100644 doc/source/cli/cinder-status.rst create mode 100644 releasenotes/notes/upgrade-checks-e58c4a81c857847d.yaml diff --git a/cinder/cmd/status.py b/cinder/cmd/status.py new file mode 100644 index 00000000000..3f0a8c7aa52 --- /dev/null +++ b/cinder/cmd/status.py @@ -0,0 +1,47 @@ +# Copyright 2018 Huawei Technologies Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""CLI interface for cinder status commands.""" + +import sys + +from oslo_config import cfg +from oslo_upgradecheck import upgradecheck as uc + +CONF = cfg.CONF + +SUCCESS = uc.Code.SUCCESS +FAILURE = uc.Code.FAILURE +WARNING = uc.Code.WARNING + + +class Checks(uc.UpgradeCommands): + """Upgrade checks to run.""" + + def _check_placeholder(self): + """This is just a placeholder to test the test framework.""" + return uc.Result(SUCCESS, 'Some details') + + _upgrade_checks = ( + ('Placeholder', _check_placeholder), + ) + + +def main(): + return uc.main(CONF, 'cinder', Checks()) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/doc/source/cli/cinder-status.rst b/doc/source/cli/cinder-status.rst new file mode 100644 index 00000000000..f28a2458f28 --- /dev/null +++ b/doc/source/cli/cinder-status.rst @@ -0,0 +1,98 @@ +============= +cinder-status +============= + +---------------------------------------- +CLI interface for cinder status commands +---------------------------------------- + +:Author: openstack@lists.openstack.org +:Copyright: OpenStack Foundation +:Manual section: 1 +:Manual group: cloud computing + +Synopsis +======== + +:: + + cinder-status [] + +Description +=========== + +:program:`cinder-status` is a tool that provides routines for checking the +status of a Cinder deployment. + +Options +======= + +The standard pattern for executing a :program:`cinder-status` command is:: + + cinder-status [] + +Run without arguments to see a list of available command categories:: + + cinder-status + +Categories are: + +* ``upgrade`` + +Detailed descriptions are below. + +You can also run with a category argument such as ``upgrade`` to see a list of +all commands in that category:: + + cinder-status upgrade + +These sections describe the available categories and arguments for +:program:`cinder-status`. + +Upgrade +~~~~~~~ + +.. _cinder-status-checks: + +``cinder-status upgrade check`` + Performs a release-specific readiness check before restarting services with + new code. This command expects to have complete configuration and access + to the database. It may also make requests to other services' REST API via + the Keystone service catalog. + + **Return Codes** + + .. list-table:: + :widths: 20 80 + :header-rows: 1 + + * - Return code + - Description + * - 0 + - All upgrade readiness checks passed successfully and there is nothing + to do. + * - 1 + - At least one check encountered an issue and requires further + investigation. This is considered a warning but the upgrade may be OK. + * - 2 + - There was an upgrade status check failure that needs to be + investigated. This should be considered something that stops an + upgrade. + * - 255 + - An unexpected error occurred. + + **History of Checks** + + **14.0.0 (Stein)** + + * Placeholder to be filled in with checks as they are added in Stein. + +See Also +======== + +* `OpenStack Cinder `_ + +Bugs +==== + +* Cinder bugs are managed at `Launchpad `_ diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst index c3e9c9c38eb..8eec95ae5e7 100644 --- a/doc/source/cli/index.rst +++ b/doc/source/cli/index.rst @@ -15,6 +15,7 @@ Cinder database. :maxdepth: 1 cinder-manage + cinder-status Additional Tools and Information -------------------------------- diff --git a/doc/source/conf.py b/doc/source/conf.py index 89df5368c9d..00008f87f3e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -150,7 +150,9 @@ modindex_common_prefix = ['cinder.'] man_pages = [ ('cli/cinder-manage', 'cinder-manage', u'Cloud controller fabric', - [u'OpenStack'], 1) + [u'OpenStack'], 1), + ('cli/cinder-status', 'cinder-status', u'Upgrade checking utility', + [u'OpenStack'], 1), ] # -- Options for HTML output -------------------------------------------------- diff --git a/lower-constraints.txt b/lower-constraints.txt index 5fcf945cad8..3f912342b99 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -163,3 +163,4 @@ voluptuous==0.11.1 warlock==1.3.0 WebOb==1.7.1 wrapt==1.10.11 +oslo.upgradecheck==0.1.0 diff --git a/releasenotes/notes/upgrade-checks-e58c4a81c857847d.yaml b/releasenotes/notes/upgrade-checks-e58c4a81c857847d.yaml new file mode 100644 index 00000000000..6a4a5ebc708 --- /dev/null +++ b/releasenotes/notes/upgrade-checks-e58c4a81c857847d.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + [`Community Goal `_] + Support has been added for developers to write pre-upgrade checks. + Operators can run these checks using ``cinder-status upgrade check``. + This allows operators to be more confident when upgrading their deployments + by having a tool that automates programmable checks against the deployment + configuration or dataset. + diff --git a/requirements.txt b/requirements.txt index 9015dd69d07..347ccac2fab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,6 +30,7 @@ oslo.reports>=1.18.0 # Apache-2.0 oslo.rootwrap>=5.8.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.service!=1.28.1,>=1.24.0 # Apache-2.0 +oslo.upgradecheck>=0.1.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 oslo.versionedobjects>=1.31.2 # Apache-2.0 osprofiler>=1.4.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index 1ce900a58d0..24ada81f6ce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,6 +67,7 @@ console_scripts = cinder-rootwrap = oslo_rootwrap.cmd:main cinder-rtstool = cinder.cmd.rtstool:main cinder-scheduler = cinder.cmd.scheduler:main + cinder-status = cinder.cmd.status:main cinder-volume = cinder.cmd.volume:main cinder-volume-usage-audit = cinder.cmd.volume_usage_audit:main wsgi_scripts =