Only check for upgrades if bootstrapped

Only check for upgrade requests if the local unit is installed
and bootstrapped, avoiding attempts to upgrade on initial
execution of config-changed for trusty UCA pockets.

Note that the upgrade process relies on a running ceph cluster.

Change-Id: Ia3efe2f8cfdac4317809681e7d169725c6bd9ef2
Closes-Bug: 1662943
This commit is contained in:
Chris MacNaughton 2017-02-16 14:59:46 -05:00 committed by James Page
parent 459ccae83d
commit d3cf8bb3ab
2 changed files with 38 additions and 1 deletions

View File

@ -108,6 +108,10 @@ def pretty_print_upgrade_paths():
def check_for_upgrade():
if not ceph.is_bootstrapped():
log("Ceph is not bootstrapped, skipping upgrade checks.")
return
release_info = host.lsb_release()
if not release_info['DISTRIB_CODENAME'] == 'trusty':
log("Invalid upgrade path from {}. Only trusty is currently "

View File

@ -17,6 +17,8 @@ def config_side_effect(*args):
class UpgradeRollingTestCase(unittest.TestCase):
@patch('ceph_hooks.ceph.is_bootstrapped')
@patch('ceph_hooks.log')
@patch('ceph_hooks.ceph.roll_monitor_cluster')
@patch('ceph_hooks.ceph.wait_for_all_monitors_to_upgrade')
@ -29,7 +31,9 @@ class UpgradeRollingTestCase(unittest.TestCase):
hookenv,
wait_for_mons,
roll_monitor_cluster,
log):
log,
is_bootstrapped):
is_bootstrapped.return_value = True
host.lsb_release.return_value = {
'DISTRIB_CODENAME': 'trusty',
}
@ -60,3 +64,32 @@ class UpgradeRollingTestCase(unittest.TestCase):
'upgrade path. Proceeding.')
]
)
@patch('ceph_hooks.ceph.is_bootstrapped')
@patch('ceph_hooks.log')
@patch('ceph_hooks.ceph.roll_monitor_cluster')
@patch('ceph_hooks.ceph.wait_for_all_monitors_to_upgrade')
@patch('ceph_hooks.hookenv')
@patch('ceph_hooks.host')
@patch('ceph_hooks.ceph.roll_osd_cluster')
def test_check_for_upgrade_not_bootstrapped(self,
roll_osd_cluster,
host,
hookenv,
wait_for_mons,
roll_monitor_cluster,
log,
is_bootstrapped):
is_bootstrapped.return_value = False
host.lsb_release.return_value = {
'DISTRIB_CODENAME': 'trusty',
}
previous_mock = MagicMock().return_value
previous_mock.previous.return_value = "cloud:trusty-juno"
hookenv.config.side_effect = [previous_mock,
config_side_effect('source')]
check_for_upgrade()
roll_osd_cluster.assert_not_called()
roll_monitor_cluster.assert_not_called()