diff --git a/doc/source/cli/index.rst b/doc/source/cli/index.rst new file mode 100644 index 000000000..ea7acc928 --- /dev/null +++ b/doc/source/cli/index.rst @@ -0,0 +1,7 @@ +CLI Reference +============= + +.. toctree:: + :maxdepth: 1 + + solum-status diff --git a/doc/source/cli/solum-status.rst b/doc/source/cli/solum-status.rst new file mode 100644 index 000000000..86b429c7c --- /dev/null +++ b/doc/source/cli/solum-status.rst @@ -0,0 +1,78 @@ +============ +solum-status +============ + +Synopsis +======== + +:: + + solum-status [] + +Description +=========== + +:program:`solum-status` is a tool that provides routines for checking the +status of a Solum deployment. + +Options +======= + +The standard pattern for executing a :program:`solum-status` command is:: + + solum-status [] + +Run without arguments to see a list of available command categories:: + + solum-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:: + + solum-status upgrade + +These sections describe the available categories and arguments for +:program:`solum-status`. + +Upgrade +~~~~~~~ + +.. _solum-status-checks: + +``solum-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** + + **5.8.0 (Stein)** + + * 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 354dcc2cd..b5225af90 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -13,6 +13,7 @@ Contents: admin/index contributor/index man/index + cli/index Indices and tables ================== diff --git a/lower-constraints.txt b/lower-constraints.txt index 48535b4c8..f618a2f5e 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -76,6 +76,7 @@ oslo.policy==1.34.0 oslo.rootwrap==5.13.0 oslo.serialization==2.25.0 oslo.service==1.30.0 +oslo.upgradecheck==0.1.0 oslo.utils==3.36.0 oslotest==3.3.0 packaging==17.1 diff --git a/releasenotes/notes/solum-status-upgrade-check-framework-a3cf2c739f0dad5d.yaml b/releasenotes/notes/solum-status-upgrade-check-framework-a3cf2c739f0dad5d.yaml new file mode 100644 index 000000000..6e22c74f3 --- /dev/null +++ b/releasenotes/notes/solum-status-upgrade-check-framework-a3cf2c739f0dad5d.yaml @@ -0,0 +1,13 @@ +--- +prelude: > + Added new tool ``solum-status upgrade check``. +features: + - | + New framework for ``solum-status upgrade check`` command is added. + This framework allows adding various checks which can be run before a + Solum upgrade to ensure if the upgrade can be performed safely. +upgrade: + - | + Operator can now use new CLI tool ``solum-status upgrade check`` + to check if Solum deployment can be safely upgraded from + N-1 to N release. diff --git a/requirements.txt b/requirements.txt index 88488b09b..9fb8d2e97 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,7 @@ oslo.db>=4.35.0 # Apache-2.0 oslo.messaging>=5.36.0 # Apache-2.0 oslo.middleware>=3.35.0 # Apache-2.0 oslo.serialization>=2.25.0 # Apache-2.0 +oslo.upgradecheck>=0.1.0 # Apache-2.0 oslo.utils>=3.36.0 # Apache-2.0 oslo.log>=3.37.0 # Apache-2.0 oslo.rootwrap>=5.13.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index 9dea1a97b..135cfae68 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,6 +44,7 @@ console_scripts = solum-deployer = solum.cmd.deployer:main solum-worker = solum.cmd.worker:main solum-rootwrap = oslo_rootwrap.cmd:main + solum-status = solum.cmd.status:main wsgi_scripts = solum-wsgi-api = solum.httpd.solum_api:init_application diff --git a/solum/cmd/status.py b/solum/cmd/status.py new file mode 100644 index 000000000..142b54c32 --- /dev/null +++ b/solum/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 solum.i18n import _ + + +class Checks(upgradecheck.UpgradeCommands): + + """Upgrade checks for the solum-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='solum', upgrade_command=Checks()) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/solum/tests/cmd/__init__.py b/solum/tests/cmd/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/solum/tests/cmd/test_status.py b/solum/tests/cmd/test_status.py new file mode 100644 index 000000000..47bf22063 --- /dev/null +++ b/solum/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 solum.cmd import status +from solum.tests import base + + +class TestUpgradeChecks(base.BaseTestCase): + + 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)