Skip to content

Commit

Permalink
mgr/cepahdm: add various touch points to enable smb service
Browse files Browse the repository at this point in the history
Add the smb service by name or by type to one of the many, many touch
points in the orchestrator and cephadm packages needed to get the
orchestrator aware of smb.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
  • Loading branch information
phlogistonjohn committed Mar 21, 2024
1 parent a88cf50 commit c5e4912
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
NodeExporterService, SNMPGatewayService, LokiService, PromtailService
from .services.jaeger import ElasticSearchService, JaegerAgentService, JaegerCollectorService, JaegerQueryService
from .services.node_proxy import NodeProxy
from .services.smb import SMBService
from .schedule import HostAssignment
from .inventory import Inventory, SpecStore, HostCache, AgentCache, EventStore, \
ClientKeyringStore, ClientKeyringSpec, TunedProfileStore, NodeProxyCache
Expand Down Expand Up @@ -687,6 +688,7 @@ def __init__(self, *args: Any, **kwargs: Any):
PromtailService,
RbdMirrorService,
RgwService,
SMBService,
SNMPGatewayService,
]

Expand Down Expand Up @@ -3275,7 +3277,8 @@ def _apply_service_spec(self, spec: ServiceSpec) -> str:
'elasticsearch': PlacementSpec(count=1),
'jaeger-agent': PlacementSpec(host_pattern='*'),
'jaeger-collector': PlacementSpec(count=1),
'jaeger-query': PlacementSpec(count=1)
'jaeger-query': PlacementSpec(count=1),
SMBService.TYPE: PlacementSpec(count=1),
}
spec.placement = defaults[spec.service_type]
elif spec.service_type in ['mon', 'mgr'] and \
Expand Down Expand Up @@ -3405,6 +3408,10 @@ def apply_container(self, spec: ServiceSpec) -> str:
def apply_snmp_gateway(self, spec: ServiceSpec) -> str:
return self._apply(spec)

@handle_orch_error
def apply_smb(self, spec: ServiceSpec) -> str:
return self._apply(spec)

@handle_orch_error
def set_unmanaged(self, service_name: str, value: bool) -> str:
return self.spec_store.set_unmanaged(service_name, value)
Expand Down
4 changes: 2 additions & 2 deletions src/pybind/mgr/cephadm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CephadmNoImage(Enum):
# these daemons do not use the ceph image. There are other daemons
# that also don't use the ceph image, but we only care about those
# that are part of the upgrade order here
NON_CEPH_IMAGE_TYPES = MONITORING_STACK_TYPES + ['nvmeof']
NON_CEPH_IMAGE_TYPES = MONITORING_STACK_TYPES + ['nvmeof', 'smb']

# Used for _run_cephadm used for check-host etc that don't require an --image parameter
cephadmNoImage = CephadmNoImage.token
Expand Down Expand Up @@ -66,7 +66,7 @@ def name_to_config_section(name: str) -> ConfEntity:
Map from daemon names to ceph entity names (as seen in config)
"""
daemon_type = name.split('.', 1)[0]
if daemon_type in ['rgw', 'rbd-mirror', 'nfs', 'crash', 'iscsi', 'ceph-exporter', 'nvmeof']:
if daemon_type in ['rgw', 'rbd-mirror', 'nfs', 'crash', 'iscsi', 'ceph-exporter', 'nvmeof', 'smb']:
return ConfEntity('client.' + name)
elif daemon_type in ['mon', 'osd', 'mds', 'mgr', 'client']:
return ConfEntity(name)
Expand Down
12 changes: 10 additions & 2 deletions src/pybind/mgr/orchestrator/_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Protocol: # type: ignore
NFSServiceSpec,
NvmeofServiceSpec,
RGWSpec,
SMBSpec,
SNMPGatewaySpec,
ServiceSpec,
TunedProfileSpec,
Expand Down Expand Up @@ -582,6 +583,7 @@ def apply(self, specs: Sequence["GenericSpec"], no_overwrite: bool = False) -> L
'ingress': self.apply_ingress,
'snmp-gateway': self.apply_snmp_gateway,
'host': self.add_host,
'smb': self.apply_smb,
}

def merge(l: OrchResult[List[str]], r: OrchResult[str]) -> OrchResult[List[str]]: # noqa: E741
Expand Down Expand Up @@ -819,6 +821,10 @@ def apply_snmp_gateway(self, spec: SNMPGatewaySpec) -> OrchResult[str]:
"""Update an existing snmp gateway service"""
raise NotImplementedError()

def apply_smb(self, spec: SMBSpec) -> OrchResult[str]:
"""Update a smb gateway service"""
raise NotImplementedError()

def apply_tuned_profiles(self, specs: List[TunedProfileSpec], no_overwrite: bool) -> OrchResult[str]:
"""Add or update an existing tuned profile"""
raise NotImplementedError()
Expand Down Expand Up @@ -917,7 +923,8 @@ def daemon_type_to_service(dtype: str) -> str:
'elasticsearch': 'elasticsearch',
'jaeger-agent': 'jaeger-agent',
'jaeger-collector': 'jaeger-collector',
'jaeger-query': 'jaeger-query'
'jaeger-query': 'jaeger-query',
'smb': 'smb',
}
return mapping[dtype]

Expand Down Expand Up @@ -951,7 +958,8 @@ def service_to_daemon_types(stype: str) -> List[str]:
'jaeger-agent': ['jaeger-agent'],
'jaeger-collector': ['jaeger-collector'],
'jaeger-query': ['jaeger-query'],
'jaeger-tracing': ['elasticsearch', 'jaeger-query', 'jaeger-collector', 'jaeger-agent']
'jaeger-tracing': ['elasticsearch', 'jaeger-query', 'jaeger-collector', 'jaeger-agent'],
'smb': ['smb'],
}
return mapping[stype]

Expand Down
37 changes: 37 additions & 0 deletions src/pybind/mgr/orchestrator/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
OrchestratorError,
OrchestratorValidationError,
RGWSpec,
SMBSpec,
SNMPGatewaySpec,
ServiceDescription,
TunedProfileSpec,
Expand Down Expand Up @@ -1820,6 +1821,42 @@ def _apply_jaeger(self,
specs: List[ServiceSpec] = spec.get_tracing_specs()
return self._apply_misc(specs, dry_run, format, no_overwrite)

@_cli_write_command('orch apply smb')
def _apply_smb(
self,
cluster_id: str,
config_uri: str,
features: str = '',
join_sources: Optional[List[str]] = None,
custom_dns: Optional[List[str]] = None,
include_ceph_users: Optional[List[str]] = None,
placement: Optional[str] = None,
unmanaged: bool = False,
dry_run: bool = False,
format: Format = Format.plain,
no_overwrite: bool = False,
) -> HandleCommandResult:
"""Apply an SMB network file system gateway service configuration."""

_features = features.replace(',', ' ').split()
spec = SMBSpec(
service_id=cluster_id,
placement=PlacementSpec.from_string(placement),
unmanaged=unmanaged,
preview_only=dry_run,
cluster_id=cluster_id,
features=_features,
config_uri=config_uri,
join_sources=join_sources,
custom_dns=custom_dns,
include_ceph_users=include_ceph_users,
)

spec.validate() # force any validation exceptions to be caught correctly
# The previous comment makes no sense to JJM. But when in rome.

return self._apply_misc([spec], dry_run, format, no_overwrite)

@_cli_write_command('orch set-unmanaged')
def _set_unmanaged(self, service_name: str) -> HandleCommandResult:
"""Set 'unmanaged: true' for the given service name"""
Expand Down

0 comments on commit c5e4912

Please sign in to comment.