Browse Source

Add tricircle-status upgrade check command framework

This adds basic framework for tricircle-status upgrade check commands.
For now it has only "check_placeholder" check implemented.
Real checks can be added to this tool in the future.
Story: 2003657
Task: 26160

Change-Id: I33c5cb6b89852749f4c1915ed70315d502774b64
changes/70/615470/3
whoami-rajat 3 years ago
committed by Matt Riedemann
parent
commit
96f8886a6e
8 changed files with 187 additions and 0 deletions
  1. +9
    -0
      doc/source/admin/cli.rst
  2. +78
    -0
      doc/source/admin/tricircle-status.rst
  3. +13
    -0
      releasenotes/notes/tricircle-status-upgrade-check-framework-13ee546a958d17f7.yaml
  4. +1
    -0
      requirements.txt
  5. +1
    -0
      setup.cfg
  6. +54
    -0
      tricircle/cmd/status.py
  7. +0
    -0
      tricircle/tests/unit/cmd/__init__.py
  8. +31
    -0
      tricircle/tests/unit/cmd/test_status.py

+ 9
- 0
doc/source/admin/cli.rst View File

@ -14,3 +14,12 @@ The CLI for Tricircle can be executed as follows ::
openstack multiregion networking <command> [<command-arguments>]
All commands will issue request to Tricircle Admin API.
Management commands
===================
.. toctree::
:maxdepth: 1
tricircle-status

+ 78
- 0
doc/source/admin/tricircle-status.rst View File

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

+ 13
- 0
releasenotes/notes/tricircle-status-upgrade-check-framework-13ee546a958d17f7.yaml View File

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

+ 1
- 0
requirements.txt View File

@ -40,6 +40,7 @@ oslo.policy>=1.30.0 # Apache-2.0
oslo.rootwrap>=5.8.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.1 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
sqlalchemy-migrate>=0.11.0 # Apache-2.0


+ 1
- 0
setup.cfg View File

@ -48,6 +48,7 @@ output_file = tricircle/locale/tricircle.pot
console_scripts =
tricircle-api = tricircle.cmd.api:main
tricircle-db-manage = tricircle.cmd.manage:main
tricircle-status = tricircle.cmd.status:main
tricircle-xjob = tricircle.cmd.xjob:main
wsgi_scripts =
tricircle-api-wsgi = tricircle.api.wsgi:init_application


+ 54
- 0
tricircle/cmd/status.py View File

@ -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 tricircle.common.i18n import _
class Checks(upgradecheck.UpgradeCommands):
"""Upgrade checks for the tricircle-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='tricircle', upgrade_command=Checks())
if __name__ == '__main__':
sys.exit(main())

+ 0
- 0
tricircle/tests/unit/cmd/__init__.py View File


+ 31
- 0
tricircle/tests/unit/cmd/test_status.py 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 tricircle.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)

Loading…
Cancel
Save