Skip to content

Commit

Permalink
cephadm: fix issue joining to ad by using a virtual hostname
Browse files Browse the repository at this point in the history
The not-a-real-fqdn hostname that the containers got were causing
performance issues joining AD (and running testjoin and winbind).
Define a virtual hostname that can be passed in from the service or
automatically derived from the system's hostname.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
  • Loading branch information
phlogistonjohn committed Feb 12, 2024
1 parent a3e353b commit c924491
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/cephadm/cephadmlib/daemons/smb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import enum
import json
import pathlib
import logging
import pathlib
import socket

from typing import List, Dict, Tuple, Optional, Any

Expand Down Expand Up @@ -55,6 +56,7 @@ class Config:
custom_dns: List[str]
smb_port: int
ceph_config_entity: str
vhostname: str

def __init__(
self,
Expand All @@ -69,6 +71,7 @@ def __init__(
custom_dns: Optional[List[str]] = None,
smb_port: int = 0,
ceph_config_entity: str = 'client.admin',
vhostname: str = '',
) -> None:
self.instance_id = instance_id
self.source_config = source_config
Expand All @@ -80,6 +83,7 @@ def __init__(
self.custom_dns = custom_dns or []
self.smb_port = smb_port
self.ceph_config_entity = ceph_config_entity
self.vhostname = vhostname

def __str__(self) -> str:
return (
Expand All @@ -90,6 +94,15 @@ def __str__(self) -> str:
)


def _container_dns_args(cfg: Config) -> List[str]:
cargs = []
for dns in cfg.custom_dns:
cargs.append(f'--dns={dns}')
if cfg.vhostname:
cargs.append(f'--hostname={cfg.vhostname}')
return cargs


class SambaContainerCommon:
def __init__(
self,
Expand Down Expand Up @@ -136,6 +149,7 @@ def container_args(self) -> List[str]:
cargs = []
if self.cfg.smb_port:
cargs.append(f'--publish={self.cfg.smb_port}:{self.cfg.smb_port}')
cargs.extend(_container_dns_args(self.cfg))
return cargs


Expand Down Expand Up @@ -166,9 +180,7 @@ def args(self) -> List[str]:
return args

def container_args(self) -> List[str]:
cargs = []
for dns in self.cfg.custom_dns:
cargs.append(f'--dns={dns}')
cargs = _container_dns_args(self.cfg)
return cargs


Expand Down Expand Up @@ -230,6 +242,7 @@ def validate(self) -> None:
instance_features = configs.get('features', [])
files = data_utils.dict_get(configs, 'files', {})
ceph_config_entity = configs.get('config_auth_entity', '')
vhostname = configs.get('virtual_hostname', '')

if not instance_id:
raise Error('invalid instance (cluster) id')
Expand All @@ -244,6 +257,11 @@ def validate(self) -> None:
)
if Features.CLUSTERED.value in instance_features:
raise NotImplementedError('clustered instance')
if not vhostname:
# if a virtual hostname is not provided, generate one by prefixing
# the cluster/instanced id to the system hostname
hname = socket.getfqdn()
vhostname = f'{instance_id}-{hname}'

self._instance_cfg = Config(
instance_id=instance_id,
Expand All @@ -255,6 +273,7 @@ def validate(self) -> None:
samba_debug_level=6,
smb_port=self.smb_port,
ceph_config_entity=ceph_config_entity,
vhostname=vhostname,
)
self._files = files
logger.debug('SMB Instance Config: %s', self._instance_cfg)
Expand Down

0 comments on commit c924491

Please sign in to comment.