Add framework for aodh-status upgrade check

This commit adds the functionality of aodh-status CLI for performing
upgrade checks as part of the Stein cycle upgrade-checkers goal.
It only includes a sample check which must be replaced by real checks in
future.

Change-Id: I21e331266ab061a41d0ffe3c179b10f777af44f5
Story: 2003657
Task: 27733
This commit is contained in:
akhiljain23 2018-10-31 10:10:44 +05:30 committed by Lingxian Kong
parent a662f053c4
commit bef0f9bfd0
9 changed files with 193 additions and 0 deletions

53
aodh/cmd/status.py Normal file
View File

@ -0,0 +1,53 @@
# 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 aodh.i18n import _
CONF = cfg.CONF
class Checks(upgradecheck.UpgradeCommands):
"""Contains upgrade checks
Various upgrade checks should be added as separate methods in this class
and added to _upgrade_checks tuple.
"""
def _sample_check(self):
"""This is sample check added to test the upgrade check framework
It needs to be removed after adding any real upgrade check
"""
return upgradecheck.Result(upgradecheck.Code.SUCCESS, 'Sample detail')
_upgrade_checks = (
# Sample check added for now.
# Whereas in future real checks must be added here in tuple
(_('Sample Check'), _sample_check),
)
def main():
return upgradecheck.main(
CONF, project='aodh', upgrade_command=Checks())
if __name__ == '__main__':
sys.exit(main())

View File

View File

@ -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 aodh.cmd import status
from aodh.tests import base
class TestUpgradeChecks(base.BaseTestCase):
def setUp(self):
super(TestUpgradeChecks, self).setUp()
self.cmd = status.Checks()
def test__sample_check(self):
check_result = self.cmd._sample_check()
self.assertEqual(
Code.SUCCESS, check_result.code)

View File

@ -0,0 +1,83 @@
===========
aodh-status
===========
--------------------------------------
CLI interface for Aodh status commands
--------------------------------------
Synopsis
========
::
aodh-status <category> <command> [<args>]
Description
===========
:program:`aodh-status` is a tool that provides routines for checking the
status of a Aodh deployment.
Options
=======
The standard pattern for executing a :program:`aodh-status` command is::
aodh-status <category> <command> [<args>]
Run without arguments to see a list of available command categories::
aodh-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::
aodh-status upgrade
These sections describe the available categories and arguments for
:program:`aodh-status`.
Upgrade
~~~~~~~
.. _aodh-status-checks:
``aodh-status upgrade check``
Performs a release-specific readiness check before restarting services with
new code. For example, missing or changed configuration options,
incompatible object states, or other conditions that could lead to
failures while upgrading.
**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**
**8.0.0 (Stein)**
* Sample check to be filled in with checks as they are added in Stein.

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

@ -0,0 +1,11 @@
======================
Aodh CLI Documentation
======================
In this section you will find information on Aodhs command line
interface.
.. toctree::
:maxdepth: 1
aodh-status

View File

@ -29,6 +29,7 @@ collected by Ceilometer or Gnocchi.
contributor/index
admin/index
configuration/index
cli/index
.. toctree::
:maxdepth: 1

View File

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

View File

@ -15,6 +15,7 @@ oslo.config>=2.6.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0
oslo.log>=1.2.0 # Apache-2.0
oslo.policy>=0.5.0 # Apache-2.0
oslo.upgradecheck>=0.1.1 # Apache-2.0
PasteDeploy>=1.5.0
pbr>=2.0.0 # Apache-2.0
pecan>=0.8.0

View File

@ -100,6 +100,7 @@ console_scripts =
aodh-notifier = aodh.cmd.alarm:notifier
aodh-listener = aodh.cmd.alarm:listener
aodh-config-generator = aodh.cmd:config_generator
aodh-status = aodh.cmd.status:main
oslo.config.opts =
aodh = aodh.opts:list_opts