mirror of
https://github.com/ceph/ceph
synced 2025-01-01 00:22:25 +00:00
mgr/orch: ServiceDescription: Make spec a requirement
Because, a ServiceDescription is superset of a spec Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
This commit is contained in:
parent
19479643ad
commit
b4c88196ff
@ -1868,18 +1868,25 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
|
||||
continue
|
||||
if dd.daemon_type == 'osd':
|
||||
continue # ignore OSDs for now
|
||||
spec = None
|
||||
if dd.service_name() in self.spec_store.specs:
|
||||
spec = self.spec_store.specs[dd.service_name()]
|
||||
else:
|
||||
spec = ServiceSpec(
|
||||
unmanaged=True,
|
||||
service_type=dd.daemon_type,
|
||||
service_id=dd.service_id(),
|
||||
placement=PlacementSpec(
|
||||
hosts=[dd.hostname]
|
||||
)
|
||||
)
|
||||
if n not in sm:
|
||||
sm[n] = orchestrator.ServiceDescription(
|
||||
service_name=n,
|
||||
last_refresh=dd.last_refresh,
|
||||
container_image_id=dd.container_image_id,
|
||||
container_image_name=dd.container_image_name,
|
||||
spec=spec,
|
||||
)
|
||||
if spec:
|
||||
if dd.service_name() in self.spec_store.specs:
|
||||
sm[n].size = self._get_spec_size(spec)
|
||||
sm[n].created = self.spec_store.spec_created[dd.service_name()]
|
||||
else:
|
||||
@ -1900,12 +1907,11 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
|
||||
if service_name is not None and service_name != n:
|
||||
continue
|
||||
sm[n] = orchestrator.ServiceDescription(
|
||||
service_name=n,
|
||||
spec=spec,
|
||||
size=self._get_spec_size(spec),
|
||||
running=0,
|
||||
)
|
||||
return [s for n, s in sm.items()]
|
||||
return list(sm.values())
|
||||
|
||||
@trivial_completion
|
||||
def list_daemons(self, service_name=None, daemon_type=None, daemon_id=None,
|
||||
|
@ -1274,14 +1274,17 @@ class DaemonDescription(object):
|
||||
return self.name().startswith(service_name + '.')
|
||||
return False
|
||||
|
||||
def service_name(self):
|
||||
def service_id(self):
|
||||
if self.daemon_type == 'rgw':
|
||||
v = self.daemon_id.split('.')
|
||||
s_name = '.'.join(v[0:2])
|
||||
return 'rgw.%s' % s_name
|
||||
return '.'.join(v[0:2])
|
||||
if self.daemon_type in ['mds', 'nfs']:
|
||||
_s_name = self.daemon_id.split('.')[0]
|
||||
return '%s.%s' % (self.daemon_type, _s_name)
|
||||
return self.daemon_id.split('.')[0]
|
||||
return self.daemon_type
|
||||
|
||||
def service_name(self):
|
||||
if self.daemon_type in ['rgw', 'mds', 'nfs']:
|
||||
return f'{self.daemon_type}.{self.service_id()}'
|
||||
return self.daemon_type
|
||||
|
||||
def __repr__(self):
|
||||
@ -1330,26 +1333,21 @@ class ServiceDescription(object):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
spec: ServiceSpec,
|
||||
container_image_id=None,
|
||||
container_image_name=None,
|
||||
service_name=None,
|
||||
rados_config_location=None,
|
||||
service_url=None,
|
||||
last_refresh=None,
|
||||
created=None,
|
||||
size=0,
|
||||
running=0,
|
||||
spec=None):
|
||||
running=0):
|
||||
# Not everyone runs in containers, but enough people do to
|
||||
# justify having the container_image_id (image hash) and container_image
|
||||
# (image name)
|
||||
self.container_image_id = container_image_id # image hash
|
||||
self.container_image_name = container_image_name # image friendly name
|
||||
|
||||
# The service_name is either a bare type (e.g., 'mgr') or
|
||||
# type.id combination (e.g., 'mds.fsname' or 'rgw.realm.zone').
|
||||
self.service_name = service_name
|
||||
|
||||
# Location of the service configuration when stored in rados
|
||||
# object. Format: "rados://<pool>/[<namespace/>]<object>"
|
||||
self.rados_config_location = rados_config_location
|
||||
|
@ -266,7 +266,6 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
|
||||
spec = {}
|
||||
spec['mon'] = orchestrator.ServiceDescription(
|
||||
service_name='mon',
|
||||
spec=ServiceSpec(
|
||||
'mon',
|
||||
placement=PlacementSpec(
|
||||
@ -278,7 +277,6 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
last_refresh=now,
|
||||
)
|
||||
spec['mgr'] = orchestrator.ServiceDescription(
|
||||
service_name='mgr',
|
||||
spec=ServiceSpec(
|
||||
'mgr',
|
||||
placement=PlacementSpec.from_string('count:1'),
|
||||
@ -289,7 +287,6 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
)
|
||||
if not cl['spec'].get('crashCollector', {}).get('disable', False):
|
||||
spec['crash'] = orchestrator.ServiceDescription(
|
||||
service_name='crash',
|
||||
spec=ServiceSpec(
|
||||
'crash',
|
||||
placement=PlacementSpec.from_string('*'),
|
||||
@ -313,9 +310,9 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
if fs['spec'].get('metadataServer', {}).get('activeStandby', False):
|
||||
total_mds = active * 2
|
||||
spec[svc] = orchestrator.ServiceDescription(
|
||||
service_name=svc,
|
||||
spec=ServiceSpec(
|
||||
svc,
|
||||
service_type='mds',
|
||||
service_id=fs['metadata']['name'],
|
||||
placement=PlacementSpec(count=active),
|
||||
),
|
||||
size=total_mds,
|
||||
@ -341,8 +338,8 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
ssl = False
|
||||
port = zone['spec']['gateway']['port'] or 80
|
||||
spec[svc] = orchestrator.ServiceDescription(
|
||||
service_name=svc,
|
||||
spec=RGWSpec(
|
||||
service_id=rgw_realm + '.' + rgw_zone,
|
||||
rgw_realm=rgw_realm,
|
||||
rgw_zone=rgw_zone,
|
||||
ssl=ssl,
|
||||
|
@ -210,7 +210,10 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
continue
|
||||
daemon_size = len(list(daemons))
|
||||
services.append(orchestrator.ServiceDescription(
|
||||
service_name=daemon_type, size=daemon_size, running=daemon_size))
|
||||
spec=ServiceSpec(
|
||||
service_type=service_type,
|
||||
),
|
||||
size=daemon_size, running=daemon_size))
|
||||
|
||||
def _filter_func(svc):
|
||||
if service_name is not None and service_name != svc.service_name:
|
||||
|
Loading…
Reference in New Issue
Block a user