mirror of
https://github.com/ceph/ceph
synced 2025-01-04 02:02:36 +00:00
mgr/cephadm: Fix haproxy not being recognized as a proper daemon
Turns out daemon types != service types: cephadm [WRN] Found unknown service type haproxy on host smithi019 cephadm [WRN] Found unknown service type keepalived on host smithi019 leading to `self.mgr.cache.get_daemons_by_service(spec.service_name())` not returning any daemons. Fixes: https://tracker.ceph.com/issues/51311 Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
This commit is contained in:
parent
d373d07a9c
commit
a8f1cf2edb
@ -405,8 +405,8 @@ class CephadmServe:
|
|||||||
if v:
|
if v:
|
||||||
setattr(sd, k, str_to_datetime(d[k]))
|
setattr(sd, k, str_to_datetime(d[k]))
|
||||||
sd.daemon_type = d['name'].split('.')[0]
|
sd.daemon_type = d['name'].split('.')[0]
|
||||||
if sd.daemon_type not in ServiceSpec.KNOWN_SERVICE_TYPES:
|
if sd.daemon_type not in orchestrator.KNOWN_DAEMON_TYPES:
|
||||||
logger.warning(f"Found unknown service type {sd.daemon_type} on host {host}")
|
logger.warning(f"Found unknown daemon type {sd.daemon_type} on host {host}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
sd.daemon_id = '.'.join(d['name'].split('.')[1:])
|
sd.daemon_id = '.'.join(d['name'].split('.')[1:])
|
||||||
|
@ -65,7 +65,8 @@ class IngressService(CephService):
|
|||||||
spec = cast(IngressSpec, self.mgr.spec_store[daemon_spec.service_name].spec)
|
spec = cast(IngressSpec, self.mgr.spec_store[daemon_spec.service_name].spec)
|
||||||
assert spec.backend_service
|
assert spec.backend_service
|
||||||
if spec.backend_service not in self.mgr.spec_store:
|
if spec.backend_service not in self.mgr.spec_store:
|
||||||
raise RuntimeError(f'{spec.service_name()} backend service {spec.backend_service} does not exist')
|
raise RuntimeError(
|
||||||
|
f'{spec.service_name()} backend service {spec.backend_service} does not exist')
|
||||||
backend_spec = self.mgr.spec_store[spec.backend_service].spec
|
backend_spec = self.mgr.spec_store[spec.backend_service].spec
|
||||||
daemons = self.mgr.cache.get_daemons_by_service(spec.backend_service)
|
daemons = self.mgr.cache.get_daemons_by_service(spec.backend_service)
|
||||||
deps = [d.name() for d in daemons]
|
deps = [d.name() for d in daemons]
|
||||||
@ -183,6 +184,11 @@ class IngressService(CephService):
|
|||||||
password = spec.keepalived_password
|
password = spec.keepalived_password
|
||||||
|
|
||||||
daemons = self.mgr.cache.get_daemons_by_service(spec.service_name())
|
daemons = self.mgr.cache.get_daemons_by_service(spec.service_name())
|
||||||
|
|
||||||
|
if not daemons:
|
||||||
|
raise OrchestratorError(
|
||||||
|
f'Failed to generate keepalived.conf: No daemons deployed for {spec.service_name()}')
|
||||||
|
|
||||||
deps = sorted([d.name() for d in daemons if d.daemon_type == 'haproxy'])
|
deps = sorted([d.name() for d in daemons if d.daemon_type == 'haproxy'])
|
||||||
|
|
||||||
host = daemon_spec.host
|
host = daemon_spec.host
|
||||||
|
@ -240,6 +240,11 @@ class TestCephadm(object):
|
|||||||
style='cephadm',
|
style='cephadm',
|
||||||
fsid='fsid',
|
fsid='fsid',
|
||||||
),
|
),
|
||||||
|
dict(
|
||||||
|
name='haproxy.test.bar',
|
||||||
|
style='cephadm',
|
||||||
|
fsid='fsid',
|
||||||
|
),
|
||||||
|
|
||||||
])
|
])
|
||||||
))
|
))
|
||||||
@ -248,8 +253,7 @@ class TestCephadm(object):
|
|||||||
with with_host(cephadm_module, 'test'):
|
with with_host(cephadm_module, 'test'):
|
||||||
CephadmServe(cephadm_module)._refresh_host_daemons('test')
|
CephadmServe(cephadm_module)._refresh_host_daemons('test')
|
||||||
dds = wait(cephadm_module, cephadm_module.list_daemons())
|
dds = wait(cephadm_module, cephadm_module.list_daemons())
|
||||||
assert len(dds) == 1
|
assert {d.name() for d in dds} == {'rgw.myrgw.foobar', 'haproxy.test.bar'}
|
||||||
assert dds[0].name() == 'rgw.myrgw.foobar'
|
|
||||||
|
|
||||||
@mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]'))
|
@mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]'))
|
||||||
def test_daemon_action(self, cephadm_module: CephadmOrchestrator):
|
def test_daemon_action(self, cephadm_module: CephadmOrchestrator):
|
||||||
@ -887,7 +891,8 @@ spec:
|
|||||||
placement=ps)
|
placement=ps)
|
||||||
unmanaged_spec = ServiceSpec.from_json(spec.to_json())
|
unmanaged_spec = ServiceSpec.from_json(spec.to_json())
|
||||||
unmanaged_spec.unmanaged = True
|
unmanaged_spec.unmanaged = True
|
||||||
cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({'enabled_modules': []})
|
cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({
|
||||||
|
'enabled_modules': []})
|
||||||
with with_service(cephadm_module, unmanaged_spec):
|
with with_service(cephadm_module, unmanaged_spec):
|
||||||
|
|
||||||
c = cephadm_module.add_daemon(spec)
|
c = cephadm_module.add_daemon(spec)
|
||||||
@ -1021,7 +1026,8 @@ spec:
|
|||||||
@mock.patch("subprocess.run", mock.MagicMock())
|
@mock.patch("subprocess.run", mock.MagicMock())
|
||||||
def test_apply_save(self, spec: ServiceSpec, meth, cephadm_module: CephadmOrchestrator):
|
def test_apply_save(self, spec: ServiceSpec, meth, cephadm_module: CephadmOrchestrator):
|
||||||
with with_host(cephadm_module, 'test'):
|
with with_host(cephadm_module, 'test'):
|
||||||
cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({'enabled_modules': []})
|
cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({
|
||||||
|
'enabled_modules': []})
|
||||||
with with_service(cephadm_module, spec, meth, 'test'):
|
with with_service(cephadm_module, spec, meth, 'test'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from ._interface import \
|
|||||||
DaemonDescription, DaemonDescriptionStatus, \
|
DaemonDescription, DaemonDescriptionStatus, \
|
||||||
OrchestratorEvent, set_exception_subject, \
|
OrchestratorEvent, set_exception_subject, \
|
||||||
InventoryHost, DeviceLightLoc, \
|
InventoryHost, DeviceLightLoc, \
|
||||||
UpgradeStatusSpec, daemon_type_to_service, service_to_daemon_types
|
UpgradeStatusSpec, daemon_type_to_service, service_to_daemon_types, KNOWN_DAEMON_TYPES
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -736,6 +736,10 @@ def service_to_daemon_types(stype: str) -> List[str]:
|
|||||||
return mapping[stype]
|
return mapping[stype]
|
||||||
|
|
||||||
|
|
||||||
|
KNOWN_DAEMON_TYPES: List[str] = list(
|
||||||
|
sum((service_to_daemon_types(t) for t in ServiceSpec.KNOWN_SERVICE_TYPES), []))
|
||||||
|
|
||||||
|
|
||||||
class UpgradeStatusSpec(object):
|
class UpgradeStatusSpec(object):
|
||||||
# Orchestrator's report on what's going on with any ongoing upgrade
|
# Orchestrator's report on what's going on with any ongoing upgrade
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user