cephadm: add more ContainerDeamonForm methods to the monitoring class

Add methods customize_{container_args,process_args} & default_entrypoint
to the monitoring daemon type class. Use those methods in the
get_container function.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2023-11-05 11:09:27 -05:00
parent c701621ad9
commit c423850fce

View File

@ -872,6 +872,31 @@ class Monitoring(ContainerDaemonForm):
data_dir = self.identity.data_dir(ctx.data_dir)
mounts.update(self._get_container_mounts(data_dir))
def customize_container_args(
self, ctx: CephadmContext, args: List[str]
) -> None:
uid, _ = self.uid_gid(ctx)
monitoring_args = [
'--user',
str(uid),
# FIXME: disable cpu/memory limits for the time being (not supported
# by ubuntu 18.04 kernel!)
]
args.extend(monitoring_args)
if self.identity.daemon_type == 'node-exporter':
# in order to support setting '--path.procfs=/host/proc','--path.sysfs=/host/sys',
# '--path.rootfs=/rootfs' for node-exporter we need to disable selinux separation
# between the node-exporter container and the host to avoid selinux denials
args.extend(['--security-opt', 'label=disable'])
def customize_process_args(
self, ctx: CephadmContext, args: List[str]
) -> None:
args.extend(self.get_daemon_args())
def default_entrypoint(self) -> str:
return ''
##################################
@ -2939,22 +2964,10 @@ def get_container(
name = ident.daemon_name
ceph_args = ['-n', name, '-f']
elif daemon_type in Monitoring.components:
entrypoint = ''
uid, gid = Monitoring.extract_uid_gid(ctx, daemon_type)
monitoring_args = [
'--user',
str(uid),
# FIXME: disable cpu/memory limits for the time being (not supported
# by ubuntu 18.04 kernel!)
]
container_args.extend(monitoring_args)
if daemon_type == 'node-exporter':
# in order to support setting '--path.procfs=/host/proc','--path.sysfs=/host/sys',
# '--path.rootfs=/rootfs' for node-exporter we need to disable selinux separation
# between the node-exporter container and the host to avoid selinux denials
container_args.extend(['--security-opt', 'label=disable'])
monitoring = Monitoring.create(ctx, ident)
d_args.extend(monitoring.get_daemon_args())
entrypoint = monitoring.default_entrypoint()
monitoring.customize_container_args(ctx, container_args)
monitoring.customize_process_args(ctx, d_args)
mounts = get_container_mounts(ctx, ident)
elif daemon_type in Tracing.components:
tracing = Tracing.create(ctx, ident)