diff --git a/doc/source/man/heat-status.rst b/doc/source/man/heat-status.rst new file mode 100644 index 0000000000..9673bf2057 --- /dev/null +++ b/doc/source/man/heat-status.rst @@ -0,0 +1,78 @@ +=========== +heat-status +=========== + +Synopsis +======== + +:: + + heat-status [] + +Description +=========== + +:program:`heat-status` is a tool that provides routines for checking the +status of a Heat deployment. + +Options +======= + +The standard pattern for executing a :program:`heat-status` command is:: + + heat-status [] + +Run without arguments to see a list of available command categories:: + + heat-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:: + + heat-status upgrade + +These sections describe the available categories and arguments for +:program:`heat-status`. + +Upgrade +~~~~~~~ + +.. _heat-status-checks: + +``heat-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 databases and services. + + **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** + + **12.0.0 (Stein)** + + * Placeholder to be filled in with checks as they are added in Stein. diff --git a/doc/source/man/index.rst b/doc/source/man/index.rst index 1dbea361ef..f00ea5c7d8 100644 --- a/doc/source/man/index.rst +++ b/doc/source/man/index.rst @@ -24,3 +24,4 @@ Heat utilities heat-db-setup heat-keystone-setup heat-keystone-setup-domain + heat-status diff --git a/heat/cmd/status.py b/heat/cmd/status.py new file mode 100644 index 0000000000..9fb60efc24 --- /dev/null +++ b/heat/cmd/status.py @@ -0,0 +1,54 @@ +# Copyright (c) 2018 NEC, Corp. +# +# 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. + +import sys + +from oslo_config import cfg +from oslo_upgradecheck import upgradecheck + +from heat.common.i18n import _ + + +class Checks(upgradecheck.UpgradeCommands): + + """Upgrade checks for the heat-status upgrade check command + + Upgrade checks should be added as separate methods in this class + and added to _upgrade_checks tuple. + """ + + def _check_placeholder(self): + # This is just a placeholder for upgrade checks, it should be + # removed when the actual checks are added + return upgradecheck.Result(upgradecheck.Code.SUCCESS) + + # The format of the check functions is to return an + # oslo_upgradecheck.upgradecheck.Result + # object with the appropriate + # oslo_upgradecheck.upgradecheck.Code and details set. + # If the check hits warnings or failures then those should be stored + # in the returned Result's "details" attribute. The + # summary will be rolled up at the end of the check() method. + _upgrade_checks = ( + # In the future there should be some real checks added here + (_('Placeholder'), _check_placeholder), + ) + + +def main(): + return upgradecheck.main( + cfg.CONF, project='heat', upgrade_command=Checks()) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/heat/tests/cmd/__init__.py b/heat/tests/cmd/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/heat/tests/cmd/test_status.py b/heat/tests/cmd/test_status.py new file mode 100644 index 0000000000..ede3ba63b0 --- /dev/null +++ b/heat/tests/cmd/test_status.py @@ -0,0 +1,30 @@ +# Copyright (c) 2018 NEC, Corp. +# +# 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. + +from oslo_upgradecheck.upgradecheck import Code + +from heat.cmd import status +from heat.tests import common + + +class TestUpgradeChecks(common.HeatTestCase): + + def setUp(self): + super(TestUpgradeChecks, self).setUp() + self.cmd = status.Checks() + + def test__check_placeholder(self): + check_result = self.cmd._check_placeholder() + self.assertEqual( + Code.SUCCESS, check_result.code) diff --git a/lower-constraints.txt b/lower-constraints.txt index 97b759c52b..cd1b50d113 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -74,6 +74,7 @@ oslo.policy==1.30.0 oslo.reports==1.18.0 oslo.serialization==2.18.0 oslo.service==1.24.0 +oslo.upgradecheck==0.1.0 oslo.utils==3.33.0 oslo.versionedobjects==1.31.2 oslotest==3.2.0 diff --git a/releasenotes/notes/heat-status-upgrade-check-framework-ccbd67cee3994b88.yaml b/releasenotes/notes/heat-status-upgrade-check-framework-ccbd67cee3994b88.yaml new file mode 100644 index 0000000000..f7532b6fb3 --- /dev/null +++ b/releasenotes/notes/heat-status-upgrade-check-framework-ccbd67cee3994b88.yaml @@ -0,0 +1,13 @@ +--- +prelude: > + Added new tool ``heat-status upgrade check``. +features: + - | + New framework for ``heat-status upgrade check`` command is added. + This framework allows adding various checks which can be run before a + Heat upgrade to ensure if the upgrade can be performed safely. +upgrade: + - | + Operator can now use new CLI tool ``heat-status upgrade check`` + to check if Heat deployment can be safely upgraded from + N-1 to N release. diff --git a/requirements.txt b/requirements.txt index 5be9c7903a..b608910d6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,6 +26,7 @@ oslo.policy>=1.30.0 # Apache-2.0 oslo.reports>=1.18.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 osprofiler>=1.4.0 # Apache-2.0 oslo.versionedobjects>=1.31.2 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index 21078c38f0..3736405b4f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,6 +39,7 @@ console_scripts = heat-api-cfn = heat.cmd.api_cfn:main heat-engine = heat.cmd.engine:main heat-manage = heat.cmd.manage:main + heat-status = heat.cmd.status:main wsgi_scripts = heat-wsgi-api = heat.httpd.heat_api:init_application