Upgrades, show appropriate error if nailgun isn't running

Show a message to user for what to do if nailgun isn't
running when user starts the upgrade.

Change-Id: Iaabd281c43369884192fc34c85a293b70a9052ac
Closes-bug: #1366848
This commit is contained in:
Evgeniy L 2014-09-08 19:21:07 +04:00
parent 7683df5722
commit d97c8f5e4c
5 changed files with 36 additions and 1 deletions

View File

@ -17,6 +17,7 @@
import abc
import logging
import requests
import six
from fuel_upgrade import errors
@ -55,7 +56,13 @@ class CheckNoRunningTasks(BaseBeforeUpgradeChecker):
running tasks
"""
logger.info('Check nailgun tasks')
try:
tasks = self.nailgun_client.get_tasks()
except requests.ConnectionError:
raise errors.NailgunIsNotRunningError(
'Cannot connect to rest api service')
logger.debug('Nailgun tasks {0}'.format(tasks))
running_tasks = filter(

View File

@ -64,6 +64,8 @@ def handle_exception(exc):
print(messages.docker_is_dead)
elif isinstance(exc, errors.UpgradeVerificationError):
print(messages.health_checker_failed)
elif isinstance(exc, errors.NailgunIsNotRunningError):
print(messages.nailgun_is_not_running)
sys.exit(-1)

View File

@ -75,3 +75,7 @@ class WrongVersionError(FuelUpgradeException):
class UnsupportedActionTypeError(FuelUpgradeException):
pass
class NailgunIsNotRunningError(FuelUpgradeException):
pass

View File

@ -37,6 +37,15 @@ https://bugs.launchpad.net/fuel/+bug/1359725
"""
nailgun_is_not_running = """
REST API service (nailgun) is not running. Unable to verify that
there are no running tasks.
Use `--no-check` as a parameter for upgrade script to skip all
pre-upgrade checks.
"""
health_checker_failed = """
Couldn't start some of the services, try to run upgrade again.
"""

View File

@ -16,6 +16,8 @@
import mock
import requests
from fuel_upgrade.before_upgrade_checker import CheckFreeSpace
from fuel_upgrade.before_upgrade_checker import CheckNoRunningTasks
from fuel_upgrade.before_upgrade_checker import CheckUpgradeVersions
@ -56,6 +58,17 @@ class TestCheckNoRunningTasks(BaseTestCase):
checker.check()
self.called_once(get_tasks_mock)
@mock.patch('fuel_upgrade.before_upgrade_checker.NailgunClient.get_tasks',
side_effect=requests.ConnectionError(''))
def test_check_raises_error_if_nailgun_is_not_running(
self, get_tasks_mock):
checker = CheckNoRunningTasks(self.config)
self.assertRaisesRegexp(
errors.NailgunIsNotRunningError,
'Cannot connect to rest api service',
checker.check)
self.called_once(get_tasks_mock)
@mock.patch('fuel_upgrade.before_upgrade_checker.utils.find_mount_point',
side_effect=['/var', '/var', '/etc'])