diff --git a/ceph/__init__.py b/ceph/__init__.py index f29adfc..ad67965 100644 --- a/ceph/__init__.py +++ b/ceph/__init__.py @@ -40,6 +40,7 @@ from charmhelpers.core.host import ( service_start, service_stop, CompareHostReleases, + is_container, ) from charmhelpers.core.hookenv import ( cached, @@ -1583,7 +1584,7 @@ def upgrade_monitor(new_version): service_stop('ceph-mon@{}'.format(mon_id)) else: service_stop('ceph-mon-all') - apt_install(packages=PACKAGES, fatal=True) + apt_install(packages=determine_packages(), fatal=True) # Ensure the files and directories under /var/lib/ceph is chowned # properly as part of the move to the Jewel release, which moved the @@ -1767,7 +1768,7 @@ def upgrade_osd(new_version): try: # Upgrade the packages before restarting the daemons. status_set('maintenance', 'Upgrading packages to %s' % new_version) - apt_install(packages=PACKAGES, fatal=True) + apt_install(packages=determine_packages(), fatal=True) # If the upgrade does not need an ownership update of any of the # directories in the osd service directory, then simply restart @@ -2105,3 +2106,14 @@ def reweight_osd(osd_num, new_weight): log("ceph osd tree command failed with message: {}".format( e.message)) raise + + +def determine_packages(): + ''' + Determines packages for installation. + + @returns: list of ceph packages + ''' + if is_container(): + PACKAGES.remove('ntp') + return PACKAGES diff --git a/unit_tests/test_ceph.py b/unit_tests/test_ceph.py index 69d5d90..2f9979b 100644 --- a/unit_tests/test_ceph.py +++ b/unit_tests/test_ceph.py @@ -322,6 +322,15 @@ class CephTestCase(unittest.TestCase): mock_reweight.assert_called_once_with( ['ceph', 'osd', 'crush', 'reweight', 'osd.0', '1'], stderr=-2) + @mock.patch.object(ceph, 'is_container') + def test_determine_packages(self, mock_is_container): + mock_is_container.return_value = False + self.assertTrue('ntp' in ceph.determine_packages()) + self.assertEqual(ceph.PACKAGES, ceph.determine_packages()) + + mock_is_container.return_value = True + self.assertFalse('ntp' in ceph.determine_packages()) + class CephVersionTestCase(unittest.TestCase): @mock.patch.object(ceph, 'get_os_codename_install_source')