Add "monasca-status upgrade check" for pre-upgrade

Add a tool to run before upgrading a Monasca installation
that will check for potential issues and report on readiness to upgrade.

For Monasca, this initial version effectively does nothing, but gives a
framework for future checks to be included.

This is a community-wide story for Stein [1].

Story: 2003657
Task: 26142

[1] https://governance.openstack.org/tc/goals/stein/upgrade-checkers.html

Change-Id: I799602caa4029d67f59307bf1ca0d1e8f254d415
This commit is contained in:
Joseph Davis 2018-09-18 11:18:09 -07:00
parent d1fd496953
commit 22be5aa57f
8 changed files with 158 additions and 0 deletions

View File

@ -2,3 +2,52 @@
Command Line Interface Command Line Interface
====================== ======================
monasca (python-monascaclient)
==============================
This is the main command line interface for working with the
Monasca services, including retrieving metrics from storage.
See the https://docs.openstack.org/python-monascaclient/latest/ for details.
monasca_db
==========
CLI for Monasca database management.
::
usage: api [-h] [--config-dir DIR] [--config-file PATH] [--version]
{fingerprint,detect-revision,stamp,upgrade,version} ...
monasca-status
==============
CLI for checking the status of Monasca.
Use the command `monasca-status upgrade check` to check
the readiness of the system for an upgrade.
**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**
Introduced in the Stein cycle as part of the OpenStack Community wide goal.
https://governance.openstack.org/tc/goals/stein/upgrade-checkers.html

View File

@ -66,6 +66,7 @@ oslo.middleware==3.31.0
oslo.policy==1.30.0 oslo.policy==1.30.0
oslo.serialization==2.18.0 oslo.serialization==2.18.0
oslo.utils==3.33.0 oslo.utils==3.33.0
oslo.upgradecheck==0.1.0 # Apache-2.0
oslotest==3.2.0 oslotest==3.2.0
paramiko==2.0.0 paramiko==2.0.0
PasteDeploy==1.5.0 PasteDeploy==1.5.0

61
monasca_api/cmd/status.py Normal file
View File

@ -0,0 +1,61 @@
# Copyright (c) 2018 SUSE LLC
#
# 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 monasca status commands.
https://governance.openstack.org/tc/goals/stein/upgrade-checkers.html
"""
import sys
from oslo_config import cfg
from oslo_upgradecheck import upgradecheck
def _(message):
# TODO(joadavis): simplified localization, Monasca not using oslo_i18n
return message
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='monasca', upgrade_command=Checks())
if __name__ == '__main__':
sys.exit(main())

View File

View File

@ -0,0 +1,33 @@
# Copyright (c) 2018 NEC, Corp.
# Copyright (c) 2018 SUSE LLC
#
# 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 monasca_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,
"Placeholder should always succeed.")

View File

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

View File

@ -8,6 +8,7 @@ oslo.log>=3.36.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0 oslo.middleware>=3.31.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0 oslo.policy>=1.30.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.upgradecheck>=0.1.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0
python-keystoneclient>=3.8.0 # Apache-2.0 python-keystoneclient>=3.8.0 # Apache-2.0

View File

@ -36,6 +36,7 @@ cassandra =
console_scripts = console_scripts =
monasca-api = monasca_api.api.server:launch monasca-api = monasca_api.api.server:launch
monasca_db = monasca_api.cmd.monasca_db:main monasca_db = monasca_api.cmd.monasca_db:main
monasca-status = monasca_api.cmd.status:main
wsgi_scripts = wsgi_scripts =
monasca-api-wsgi = monasca_api.api.wsgi:main monasca-api-wsgi = monasca_api.api.wsgi:main