Remove chrony if inside a container

When running ceph-mon in containers, best practice is
to have chrony/ntp configured and installed on the bare
metal and then have the container trust the system
clock, as the container should not manage the system
clock.

The chrony package get installed automatically as
part of the dependencies of other packages, which
gets removed in this change.

ceph-mon charm will use this change here to remove
the chrony package.

Change-Id: Ie3c9c5899c1d46edd21c32868938d3290db321e7
Closes-Bug: #1852441
This commit is contained in:
Ponnuvel Palaniyappan 2020-06-30 17:16:25 +01:00
parent af0eac506d
commit 8648c73dd5
1 changed files with 25 additions and 1 deletions

View File

@ -41,6 +41,7 @@ from charmhelpers.core.host import (
service_stop,
CompareHostReleases,
write_file,
is_container,
)
from charmhelpers.core.hookenv import (
cached,
@ -54,8 +55,12 @@ from charmhelpers.core.hookenv import (
storage_list,
)
from charmhelpers.fetch import (
add_source,
apt_cache,
add_source, apt_install, apt_update
apt_install,
apt_purge,
apt_update,
filter_missing_packages
)
from charmhelpers.contrib.storage.linux.ceph import (
get_mon_map,
@ -85,6 +90,9 @@ PACKAGES = ['ceph', 'gdisk',
'radosgw', 'xfsprogs',
'lvm2', 'parted', 'smartmontools']
REMOVE_PACKAGES = []
CHRONY_PACKAGE = 'chrony'
CEPH_KEY_MANAGER = 'ceph'
VAULT_KEY_MANAGER = 'vault'
KEY_MANAGERS = [
@ -2209,6 +2217,9 @@ def upgrade_monitor(new_version, kick_function=None):
else:
service_stop('ceph-mon-all')
apt_install(packages=determine_packages(), fatal=True)
rm_packages = determine_packages_to_remove()
if rm_packages:
apt_purge(packages=rm_packages, fatal=True)
kick_function()
owner = ceph_user()
@ -3252,6 +3263,19 @@ def determine_packages():
return packages
def determine_packages_to_remove():
"""Determines packages for removal
:returns: list of packages to be removed
"""
rm_packages = REMOVE_PACKAGES.copy()
if is_container():
install_list = filter_missing_packages(CHRONY_PACKAGE)
if not install_list:
rm_packages.append(CHRONY_PACKAGE)
return rm_packages
def bootstrap_manager():
hostname = socket.gethostname()
path = '/var/lib/ceph/mgr/ceph-{}'.format(hostname)