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:
parent
af0eac506d
commit
8648c73dd5
@ -41,6 +41,7 @@ from charmhelpers.core.host import (
|
|||||||
service_stop,
|
service_stop,
|
||||||
CompareHostReleases,
|
CompareHostReleases,
|
||||||
write_file,
|
write_file,
|
||||||
|
is_container,
|
||||||
)
|
)
|
||||||
from charmhelpers.core.hookenv import (
|
from charmhelpers.core.hookenv import (
|
||||||
cached,
|
cached,
|
||||||
@ -54,8 +55,12 @@ from charmhelpers.core.hookenv import (
|
|||||||
storage_list,
|
storage_list,
|
||||||
)
|
)
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
|
add_source,
|
||||||
apt_cache,
|
apt_cache,
|
||||||
add_source, apt_install, apt_update
|
apt_install,
|
||||||
|
apt_purge,
|
||||||
|
apt_update,
|
||||||
|
filter_missing_packages
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.storage.linux.ceph import (
|
from charmhelpers.contrib.storage.linux.ceph import (
|
||||||
get_mon_map,
|
get_mon_map,
|
||||||
@ -85,6 +90,9 @@ PACKAGES = ['ceph', 'gdisk',
|
|||||||
'radosgw', 'xfsprogs',
|
'radosgw', 'xfsprogs',
|
||||||
'lvm2', 'parted', 'smartmontools']
|
'lvm2', 'parted', 'smartmontools']
|
||||||
|
|
||||||
|
REMOVE_PACKAGES = []
|
||||||
|
CHRONY_PACKAGE = 'chrony'
|
||||||
|
|
||||||
CEPH_KEY_MANAGER = 'ceph'
|
CEPH_KEY_MANAGER = 'ceph'
|
||||||
VAULT_KEY_MANAGER = 'vault'
|
VAULT_KEY_MANAGER = 'vault'
|
||||||
KEY_MANAGERS = [
|
KEY_MANAGERS = [
|
||||||
@ -2209,6 +2217,9 @@ def upgrade_monitor(new_version, kick_function=None):
|
|||||||
else:
|
else:
|
||||||
service_stop('ceph-mon-all')
|
service_stop('ceph-mon-all')
|
||||||
apt_install(packages=determine_packages(), fatal=True)
|
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()
|
kick_function()
|
||||||
|
|
||||||
owner = ceph_user()
|
owner = ceph_user()
|
||||||
@ -3252,6 +3263,19 @@ def determine_packages():
|
|||||||
return 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():
|
def bootstrap_manager():
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
path = '/var/lib/ceph/mgr/ceph-{}'.format(hostname)
|
path = '/var/lib/ceph/mgr/ceph-{}'.format(hostname)
|
||||||
|
Loading…
Reference in New Issue
Block a user