Merge "Add freezer-manager-status upgrade check command framework"

This commit is contained in:
Zuul 2018-10-29 03:02:49 +00:00 committed by Gerrit Code Review
commit e1c01f8467
10 changed files with 186 additions and 1 deletions

View File

@ -0,0 +1,78 @@
======================
freezer-manager-status
======================
Synopsis
========
::
freezer-manager-status <category> <command> [<args>]
Description
===========
:program:`freezer-manager-status` is a tool that provides routines for checking the
status of a Freezer API deployment.
Options
=======
The standard pattern for executing a :program:`freezer-manager-status` command is::
freezer-manager-status <category> <command> [<args>]
Run without arguments to see a list of available command categories::
freezer-manager-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::
freezer-manager-status upgrade
These sections describe the available categories and arguments for
:program:`freezer-manager-status`.
Upgrade
~~~~~~~
.. _freezer-manager-status-checks:
``freezer-manager-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**
**7.0.0 (Stein)**
* Placeholder to be filled in with checks as they are added in Stein.

7
doc/source/cli/index.rst Normal file
View File

@ -0,0 +1,7 @@
CLI Reference
=============
.. toctree::
:maxdepth: 1
freezer-manager-status

View File

@ -11,6 +11,7 @@ Contents:
.. toctree::
:maxdepth: 2
cli/index
Indices and tables

52
freezer_api/cmd/status.py Normal file
View File

@ -0,0 +1,52 @@
# 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 freezer_api.common._i18n import _
class Checks(upgradecheck.UpgradeCommands):
"""Various 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='freezer-api', upgrade_command=Checks())
if __name__ == '__main__':
sys.exit(main())

View File

View File

@ -0,0 +1,31 @@
# 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 unittest
from oslo_upgradecheck.upgradecheck import Code
from freezer_api.cmd import status
class TestUpgradeChecks(unittest.TestCase):
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)

View File

@ -44,6 +44,7 @@ oslo.log==3.36.0
oslo.middleware==3.31.0
oslo.policy==1.30.0
oslo.serialization==2.25.0
oslo.upgradecheck==0.1.0
oslo.utils==3.36.0
oslosphinx==4.7.0
Paste==2.0.2

View File

@ -0,0 +1,13 @@
---
prelude: >
Added new tool ``freezer-manager-status upgrade check``.
features:
- |
New framework for ``freezer-manager-status upgrade check`` command is added.
This framework allows adding various checks which can be run before a
Freezer API upgrade to ensure if the upgrade can be performed safely.
upgrade:
- |
Operator can now use new CLI tool ``freezer-manager-status upgrade check``
to check if Freezer API deployment can be safely upgraded from
N-1 to N release.

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
elasticsearch<=3.0.0,>=2.0.0 # Apache-2.0
elasticsearch<3.0.0,>=2.0.0 # Apache-2.0
falcon>=1.0.0 # Apache-2.0
jsonschema<3.0.0,>=2.6.0 # MIT
keystonemiddleware>=4.17.0 # Apache-2.0
@ -14,4 +14,5 @@ oslo.i18n>=3.15.3 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0
oslo.upgradecheck>=0.1.0 # Apache-2.0
six>=1.10.0 # MIT

View File

@ -52,6 +52,7 @@ oslo.policy.policies =
console_scripts =
freezer-api = freezer_api.cmd.api:main
freezer-manage = freezer_api.cmd.manage:main
freezer-manager-status = freeer_api.cmd.status:main
wsgi_scripts =
freezer-api-wsgi = freezer_api.service:initialize_app