diff options
Diffstat (limited to 'src/cephadm/cephadmlib/daemons')
-rw-r--r-- | src/cephadm/cephadmlib/daemons/ingress.py | 30 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/mgmt_gateway.py | 6 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/monitoring.py | 49 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/nfs.py | 15 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/nvmeof.py | 46 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/oauth2_proxy.py | 6 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/smb.py | 4 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/snmp.py | 4 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/tracing.py | 15 |
9 files changed, 89 insertions, 86 deletions
diff --git a/src/cephadm/cephadmlib/daemons/ingress.py b/src/cephadm/cephadmlib/daemons/ingress.py index 8f4f6b08991..645654b59c8 100644 --- a/src/cephadm/cephadmlib/daemons/ingress.py +++ b/src/cephadm/cephadmlib/daemons/ingress.py @@ -2,10 +2,7 @@ import os from typing import Dict, List, Optional, Tuple, Union -from ceph.cephadm.images import ( - DEFAULT_HAPROXY_IMAGE, - DEFAULT_KEEPALIVED_IMAGE, -) +from ceph.cephadm.images import DefaultImages from ..constants import ( DATA_DIR_MODE, ) @@ -27,7 +24,7 @@ class HAproxy(ContainerDaemonForm): daemon_type = 'haproxy' required_files = ['haproxy.cfg'] - default_image = DEFAULT_HAPROXY_IMAGE + default_image = DefaultImages.HAPROXY.image_ref @classmethod def for_daemon_type(cls, daemon_type: str) -> bool: @@ -82,8 +79,7 @@ class HAproxy(ContainerDaemonForm): def get_daemon_args(self) -> List[str]: return ['haproxy', '-f', '/var/lib/haproxy/haproxy.cfg'] - def validate(self): - # type: () -> None + def validate(self) -> None: if not is_fsid(self.fsid): raise Error('not an fsid: %s' % self.fsid) if not self.daemon_id: @@ -99,12 +95,10 @@ class HAproxy(ContainerDaemonForm): 'required file missing from config-json: %s' % fname ) - def get_daemon_name(self): - # type: () -> str + def get_daemon_name(self) -> str: return '%s.%s' % (self.daemon_type, self.daemon_id) - def get_container_name(self, desc=None): - # type: (Optional[str]) -> str + def get_container_name(self, desc: Optional[str] = None) -> str: cname = 'ceph-%s-%s' % (self.fsid, self.get_daemon_name()) if desc: cname = '%s-%s' % (cname, desc) @@ -158,7 +152,7 @@ class Keepalived(ContainerDaemonForm): daemon_type = 'keepalived' required_files = ['keepalived.conf'] - default_image = DEFAULT_KEEPALIVED_IMAGE + default_image = DefaultImages.KEEPALIVED.image_ref @classmethod def for_daemon_type(cls, daemon_type: str) -> bool: @@ -212,8 +206,7 @@ class Keepalived(ContainerDaemonForm): # populate files from the config-json populate_files(data_dir, self.files, uid, gid) - def validate(self): - # type: () -> None + def validate(self) -> None: if not is_fsid(self.fsid): raise Error('not an fsid: %s' % self.fsid) if not self.daemon_id: @@ -229,20 +222,17 @@ class Keepalived(ContainerDaemonForm): 'required file missing from config-json: %s' % fname ) - def get_daemon_name(self): - # type: () -> str + def get_daemon_name(self) -> str: return '%s.%s' % (self.daemon_type, self.daemon_id) - def get_container_name(self, desc=None): - # type: (Optional[str]) -> str + def get_container_name(self, desc: Optional[str] = None) -> str: cname = 'ceph-%s-%s' % (self.fsid, self.get_daemon_name()) if desc: cname = '%s-%s' % (cname, desc) return cname @staticmethod - def get_container_envs(): - # type: () -> List[str] + def get_container_envs() -> List[str]: envs = [ 'KEEPALIVED_AUTOCONF=false', 'KEEPALIVED_CONF=/etc/keepalived/keepalived.conf', diff --git a/src/cephadm/cephadmlib/daemons/mgmt_gateway.py b/src/cephadm/cephadmlib/daemons/mgmt_gateway.py index 85f72495909..2be18809aa3 100644 --- a/src/cephadm/cephadmlib/daemons/mgmt_gateway.py +++ b/src/cephadm/cephadmlib/daemons/mgmt_gateway.py @@ -11,7 +11,7 @@ from ..context_getters import fetch_configs from ..daemon_form import register as register_daemon_form from ..daemon_identity import DaemonIdentity from ..deployment_utils import to_deployment_container -from ceph.cephadm.images import DEFAULT_NGINX_IMAGE +from ceph.cephadm.images import DefaultImages from ..data_utils import dict_get, is_fsid from ..file_utils import populate_files, makedirs, recursive_chown from ..exceptions import Error @@ -32,7 +32,7 @@ class MgmtGateway(ContainerDaemonForm): 'nginx_internal.key', ] - default_image = DEFAULT_NGINX_IMAGE + default_image = DefaultImages.NGINX.image_ref @classmethod def for_daemon_type(cls, daemon_type: str) -> bool: @@ -44,7 +44,7 @@ class MgmtGateway(ContainerDaemonForm): fsid: str, daemon_id: str, config_json: Dict, - image: str = DEFAULT_NGINX_IMAGE, + image: str = DefaultImages.NGINX.image_ref, ): self.ctx = ctx self.fsid = fsid diff --git a/src/cephadm/cephadmlib/daemons/monitoring.py b/src/cephadm/cephadmlib/daemons/monitoring.py index 710093f0f46..4ba00daaefb 100644 --- a/src/cephadm/cephadmlib/daemons/monitoring.py +++ b/src/cephadm/cephadmlib/daemons/monitoring.py @@ -3,14 +3,7 @@ import os from typing import Dict, List, Tuple from ..call_wrappers import call, CallVerbosity -from ceph.cephadm.images import ( - DEFAULT_ALERTMANAGER_IMAGE, - DEFAULT_GRAFANA_IMAGE, - DEFAULT_LOKI_IMAGE, - DEFAULT_NODE_EXPORTER_IMAGE, - DEFAULT_PROMETHEUS_IMAGE, - DEFAULT_PROMTAIL_IMAGE, -) +from ceph.cephadm.images import DefaultImages from ..constants import ( UID_NOBODY, GID_NOGROUP, @@ -23,7 +16,13 @@ from ..daemon_form import register as register_daemon_form from ..daemon_identity import DaemonIdentity from ..deployment_utils import to_deployment_container from ..exceptions import Error -from ..net_utils import get_fqdn, get_hostname, get_ip_addresses, wrap_ipv6 +from ..net_utils import ( + get_fqdn, + get_hostname, + get_ip_addresses, + wrap_ipv6, + EndPoint, +) @register_daemon_form @@ -43,7 +42,7 @@ class Monitoring(ContainerDaemonForm): components = { 'prometheus': { - 'image': DEFAULT_PROMETHEUS_IMAGE, + 'image': DefaultImages.PROMETHEUS.image_ref, 'cpus': '2', 'memory': '4GB', 'args': [ @@ -55,7 +54,7 @@ class Monitoring(ContainerDaemonForm): ], }, 'loki': { - 'image': DEFAULT_LOKI_IMAGE, + 'image': DefaultImages.LOKI.image_ref, 'cpus': '1', 'memory': '1GB', 'args': [ @@ -64,7 +63,7 @@ class Monitoring(ContainerDaemonForm): 'config-json-files': ['loki.yml'], }, 'promtail': { - 'image': DEFAULT_PROMTAIL_IMAGE, + 'image': DefaultImages.PROMTAIL.image_ref, 'cpus': '1', 'memory': '1GB', 'args': [ @@ -75,13 +74,13 @@ class Monitoring(ContainerDaemonForm): ], }, 'node-exporter': { - 'image': DEFAULT_NODE_EXPORTER_IMAGE, + 'image': DefaultImages.NODE_EXPORTER.image_ref, 'cpus': '1', 'memory': '1GB', 'args': ['--no-collector.timex'], }, 'grafana': { - 'image': DEFAULT_GRAFANA_IMAGE, + 'image': DefaultImages.GRAFANA.image_ref, 'cpus': '2', 'memory': '4GB', 'args': [], @@ -93,14 +92,9 @@ class Monitoring(ContainerDaemonForm): ], }, 'alertmanager': { - 'image': DEFAULT_ALERTMANAGER_IMAGE, + 'image': DefaultImages.ALERTMANAGER.image_ref, 'cpus': '2', 'memory': '2GB', - 'args': [ - '--cluster.listen-address=:{}'.format( - port_map['alertmanager'][1] - ), - ], 'config-json-files': [ 'alertmanager.yml', ], @@ -255,11 +249,14 @@ class Monitoring(ContainerDaemonForm): ip = meta['ip'] if 'ports' in meta and meta['ports']: port = meta['ports'][0] - if daemon_type == 'prometheus': - config = fetch_configs(ctx) + config = fetch_configs(ctx) + if daemon_type in ['prometheus', 'alertmanager']: ip_to_bind_to = config.get('ip_to_bind_to', '') if ip_to_bind_to: ip = ip_to_bind_to + web_listen_addr = str(EndPoint(ip, port)) + r += [f'--web.listen-address={web_listen_addr}'] + if daemon_type == 'prometheus': retention_time = config.get('retention_time', '15d') retention_size = config.get( 'retention_size', '0' @@ -283,9 +280,11 @@ class Monitoring(ContainerDaemonForm): r += ['--web.route-prefix=/prometheus/'] else: r += [f'--web.external-url={scheme}://{host}:{port}'] - r += [f'--web.listen-address={ip}:{port}'] if daemon_type == 'alertmanager': - config = fetch_configs(ctx) + clus_listen_addr = str( + EndPoint(ip, self.port_map[daemon_type][1]) + ) + r += [f'--cluster.listen-address={clus_listen_addr}'] use_url_prefix = config.get('use_url_prefix', False) peers = config.get('peers', list()) # type: ignore for peer in peers: @@ -301,13 +300,11 @@ class Monitoring(ContainerDaemonForm): if daemon_type == 'promtail': r += ['--config.expand-env'] if daemon_type == 'prometheus': - config = fetch_configs(ctx) try: r += [f'--web.config.file={config["web_config"]}'] except KeyError: pass if daemon_type == 'node-exporter': - config = fetch_configs(ctx) try: r += [f'--web.config.file={config["web_config"]}'] except KeyError: diff --git a/src/cephadm/cephadmlib/daemons/nfs.py b/src/cephadm/cephadmlib/daemons/nfs.py index f09374d5f46..70ccea65b5b 100644 --- a/src/cephadm/cephadmlib/daemons/nfs.py +++ b/src/cephadm/cephadmlib/daemons/nfs.py @@ -42,9 +42,13 @@ class NFSGanesha(ContainerDaemonForm): return cls.daemon_type == daemon_type def __init__( - self, ctx, fsid, daemon_id, config_json, image=DEFAULT_IMAGE - ): - # type: (CephadmContext, str, Union[int, str], Dict, str) -> None + self, + ctx: CephadmContext, + fsid: str, + daemon_id: Union[int, str], + config_json: Dict, + image: str = DEFAULT_IMAGE, + ) -> None: self.ctx = ctx self.fsid = fsid self.daemon_id = daemon_id @@ -62,8 +66,9 @@ class NFSGanesha(ContainerDaemonForm): self.validate() @classmethod - def init(cls, ctx, fsid, daemon_id): - # type: (CephadmContext, str, Union[int, str]) -> NFSGanesha + def init( + cls, ctx: CephadmContext, fsid: str, daemon_id: Union[int, str] + ) -> 'NFSGanesha': return cls(ctx, fsid, daemon_id, fetch_configs(ctx), ctx.image) @classmethod diff --git a/src/cephadm/cephadmlib/daemons/nvmeof.py b/src/cephadm/cephadmlib/daemons/nvmeof.py index 2c20a900f45..51b085df2a7 100644 --- a/src/cephadm/cephadmlib/daemons/nvmeof.py +++ b/src/cephadm/cephadmlib/daemons/nvmeof.py @@ -8,7 +8,7 @@ from ..container_types import CephContainer from ..context_getters import fetch_configs, get_config_and_keyring from ..daemon_form import register as register_daemon_form from ..daemon_identity import DaemonIdentity -from ceph.cephadm.images import DEFAULT_NVMEOF_IMAGE +from ceph.cephadm.images import DefaultImages from ..context import CephadmContext from ..data_utils import dict_get, is_fsid from ..deployment_utils import to_deployment_container @@ -26,16 +26,20 @@ class CephNvmeof(ContainerDaemonForm): daemon_type = 'nvmeof' required_files = ['ceph-nvmeof.conf'] - default_image = DEFAULT_NVMEOF_IMAGE + default_image = DefaultImages.NVMEOF.image_ref @classmethod def for_daemon_type(cls, daemon_type: str) -> bool: return cls.daemon_type == daemon_type def __init__( - self, ctx, fsid, daemon_id, config_json, image=DEFAULT_NVMEOF_IMAGE - ): - # type: (CephadmContext, str, Union[int, str], Dict, str) -> None + self, + ctx: CephadmContext, + fsid: str, + daemon_id: Union[int, str], + config_json: Dict, + image: str = DefaultImages.NVMEOF.image_ref, + ) -> None: self.ctx = ctx self.fsid = fsid self.daemon_id = daemon_id @@ -48,8 +52,9 @@ class CephNvmeof(ContainerDaemonForm): self.validate() @classmethod - def init(cls, ctx, fsid, daemon_id): - # type: (CephadmContext, str, Union[int, str]) -> CephNvmeof + def init( + cls, ctx: CephadmContext, fsid: str, daemon_id: Union[int, str] + ) -> 'CephNvmeof': return cls(ctx, fsid, daemon_id, fetch_configs(ctx), ctx.image) @classmethod @@ -73,13 +78,18 @@ class CephNvmeof(ContainerDaemonForm): os.path.join(data_dir, 'ceph-nvmeof.conf') ] = '/src/ceph-nvmeof.conf:z' mounts[os.path.join(data_dir, 'configfs')] = '/sys/kernel/config' - mounts['/dev/hugepages'] = '/dev/hugepages' - mounts['/dev/vfio/vfio'] = '/dev/vfio/vfio' mounts[log_dir] = '/var/log/ceph:z' if mtls_dir: mounts[mtls_dir] = '/src/mtls:z' return mounts + def _get_huge_pages_mounts(self, files: Dict[str, str]) -> Dict[str, str]: + mounts = dict() + if 'spdk_mem_size' not in files: + mounts['/dev/hugepages'] = '/dev/hugepages' + mounts['/dev/vfio/vfio'] = '/dev/vfio/vfio' + return mounts + def _get_tls_cert_key_mounts( self, data_dir: str, files: Dict[str, str] ) -> Dict[str, str]: @@ -90,6 +100,7 @@ class CephNvmeof(ContainerDaemonForm): 'client_cert', 'client_key', 'root_ca_cert', + 'encryption_key', ]: if fn in files: mounts[ @@ -111,6 +122,7 @@ class CephNvmeof(ContainerDaemonForm): ) else: mounts.update(self._get_container_mounts(data_dir, log_dir)) + mounts.update(self._get_huge_pages_mounts(self.files)) mounts.update(self._get_tls_cert_key_mounts(data_dir, self.files)) def customize_container_binds( @@ -198,11 +210,13 @@ class CephNvmeof(ContainerDaemonForm): ) return cmd.split() - @staticmethod - def get_sysctl_settings() -> List[str]: - return [ - 'vm.nr_hugepages = 4096', - ] + def get_sysctl_settings(self) -> List[str]: + if 'spdk_mem_size' not in self.files: + return [ + 'vm.nr_hugepages = 4096', + ] + else: + return [] def container(self, ctx: CephadmContext) -> CephContainer: ctr = daemon_to_container(ctx, self) @@ -222,4 +236,6 @@ class CephNvmeof(ContainerDaemonForm): args.append(ctx.container_engine.unlimited_pids_option) args.extend(['--ulimit', 'memlock=-1:-1']) args.extend(['--ulimit', 'nofile=10240']) - args.extend(['--cap-add=SYS_ADMIN', '--cap-add=CAP_SYS_NICE']) + args.extend(['--cap-add=CAP_SYS_NICE']) + if 'spdk_mem_size' not in self.files: + args.extend(['--cap-add=SYS_ADMIN']) diff --git a/src/cephadm/cephadmlib/daemons/oauth2_proxy.py b/src/cephadm/cephadmlib/daemons/oauth2_proxy.py index 14202111c14..c4f4ec5562f 100644 --- a/src/cephadm/cephadmlib/daemons/oauth2_proxy.py +++ b/src/cephadm/cephadmlib/daemons/oauth2_proxy.py @@ -11,7 +11,7 @@ from ..context_getters import fetch_configs from ..daemon_form import register as register_daemon_form from ..daemon_identity import DaemonIdentity from ..deployment_utils import to_deployment_container -from ceph.cephadm.images import DEFAULT_OAUTH2_PROXY_IMAGE +from ceph.cephadm.images import DefaultImages from ..constants import UID_NOBODY, GID_NOGROUP from ..data_utils import dict_get, is_fsid from ..file_utils import populate_files, makedirs, recursive_chown @@ -25,7 +25,7 @@ logger = logging.getLogger() class OAuth2Proxy(ContainerDaemonForm): """Define the configs for the jaeger tracing containers""" - default_image = DEFAULT_OAUTH2_PROXY_IMAGE + default_image = DefaultImages.OAUTH2_PROXY.image_ref daemon_type = 'oauth2-proxy' required_files = [ 'oauth2-proxy.conf', @@ -43,7 +43,7 @@ class OAuth2Proxy(ContainerDaemonForm): fsid: str, daemon_id: str, config_json: Dict, - image: str = DEFAULT_OAUTH2_PROXY_IMAGE, + image: str = DefaultImages.OAUTH2_PROXY.image_ref, ): self.ctx = ctx self.fsid = fsid diff --git a/src/cephadm/cephadmlib/daemons/smb.py b/src/cephadm/cephadmlib/daemons/smb.py index 33d43cbe6ce..0efde198812 100644 --- a/src/cephadm/cephadmlib/daemons/smb.py +++ b/src/cephadm/cephadmlib/daemons/smb.py @@ -14,7 +14,7 @@ from .. import data_utils from .. import deployment_utils from .. import file_utils from ..call_wrappers import call, CallVerbosity -from ceph.cephadm.images import DEFAULT_SAMBA_IMAGE +from ceph.cephadm.images import DefaultImages from ..container_daemon_form import ContainerDaemonForm, daemon_to_container from ..container_engines import Podman from ..container_types import ( @@ -368,7 +368,7 @@ class SMB(ContainerDaemonForm): daemon_type = 'smb' daemon_base = '/usr/sbin/smbd' - default_image = DEFAULT_SAMBA_IMAGE + default_image = DefaultImages.SAMBA.image_ref @classmethod def for_daemon_type(cls, daemon_type: str) -> bool: diff --git a/src/cephadm/cephadmlib/daemons/snmp.py b/src/cephadm/cephadmlib/daemons/snmp.py index ab84a302f2c..0557a2ef972 100644 --- a/src/cephadm/cephadmlib/daemons/snmp.py +++ b/src/cephadm/cephadmlib/daemons/snmp.py @@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union from urllib.error import HTTPError, URLError from urllib.request import urlopen -from ceph.cephadm.images import DEFAULT_SNMP_GATEWAY_IMAGE +from ceph.cephadm.images import DefaultImages from ..container_daemon_form import ContainerDaemonForm, daemon_to_container from ..container_types import CephContainer from ..context import CephadmContext @@ -24,7 +24,7 @@ class SNMPGateway(ContainerDaemonForm): daemon_type = 'snmp-gateway' SUPPORTED_VERSIONS = ['V2c', 'V3'] - default_image = DEFAULT_SNMP_GATEWAY_IMAGE + default_image = DefaultImages.SNMP_GATEWAY.image_ref DEFAULT_PORT = 9464 env_filename = 'snmp-gateway.conf' diff --git a/src/cephadm/cephadmlib/daemons/tracing.py b/src/cephadm/cephadmlib/daemons/tracing.py index 4cf74339455..44548a61d14 100644 --- a/src/cephadm/cephadmlib/daemons/tracing.py +++ b/src/cephadm/cephadmlib/daemons/tracing.py @@ -2,12 +2,7 @@ import logging from typing import Any, Dict, List, Tuple -from ceph.cephadm.images import ( - DEFAULT_ELASTICSEARCH_IMAGE, - DEFAULT_JAEGER_AGENT_IMAGE, - DEFAULT_JAEGER_COLLECTOR_IMAGE, - DEFAULT_JAEGER_QUERY_IMAGE, -) +from ceph.cephadm.images import DefaultImages from ..container_daemon_form import ContainerDaemonForm, daemon_to_container from ..container_types import CephContainer from ..context import CephadmContext @@ -27,17 +22,17 @@ class Tracing(ContainerDaemonForm): components: Dict[str, Dict[str, Any]] = { 'elasticsearch': { - 'image': DEFAULT_ELASTICSEARCH_IMAGE, + 'image': DefaultImages.ELASTICSEARCH.image_ref, 'envs': ['discovery.type=single-node'], }, 'jaeger-agent': { - 'image': DEFAULT_JAEGER_AGENT_IMAGE, + 'image': DefaultImages.JAEGER_AGENT.image_ref, }, 'jaeger-collector': { - 'image': DEFAULT_JAEGER_COLLECTOR_IMAGE, + 'image': DefaultImages.JAEGER_COLLECTOR.image_ref, }, 'jaeger-query': { - 'image': DEFAULT_JAEGER_QUERY_IMAGE, + 'image': DefaultImages.JAEGER_QUERY.image_ref, }, } # type: ignore |