for dd in dds
]
- def _daemon_action(self, daemon_type: str, daemon_id: str, host: str, action: str, image: Optional[str] = None) -> str:
- dd = DaemonDescription(
- hostname=host,
- daemon_type=daemon_type,
- daemon_id=daemon_id
- )
- daemon_spec: CephadmDaemonDeploySpec = CephadmDaemonDeploySpec(
- host=host,
- daemon_id=daemon_id,
- daemon_type=daemon_type,
- service_name=dd.service_name(),
- )
-
- self._daemon_action_set_image(action, image, daemon_type, daemon_id)
-
- if action == 'redeploy' and self.daemon_is_self(daemon_type, daemon_id):
+ def _daemon_action(self,
+ daemon_spec: CephadmDaemonDeploySpec,
+ action: str,
+ image: Optional[str] = None) -> str:
+ self._daemon_action_set_image(action, image, daemon_spec.daemon_type,
+ daemon_spec.daemon_id)
+
+ if action == 'redeploy' and self.daemon_is_self(daemon_spec.daemon_type,
+ daemon_spec.daemon_id):
self.mgr_service.fail_over()
return '' # unreachable
if action == 'redeploy' or action == 'reconfig':
- if daemon_type != 'osd':
+ if daemon_spec.daemon_type != 'osd':
daemon_spec = self.cephadm_services[daemon_type_to_service(
- daemon_type)].prepare_create(daemon_spec)
+ daemon_spec.daemon_type)].prepare_create(daemon_spec)
return CephadmServe(self)._create_daemon(daemon_spec, reconfig=(action == 'reconfig'))
actions = {
for a in actions[action]:
try:
out, err, code = CephadmServe(self)._run_cephadm(
- host, name, 'unit',
+ daemon_spec.host, name, 'unit',
['--name', name, a])
except Exception:
- self.log.exception(f'`{host}: cephadm unit {name} {a}` failed')
+ self.log.exception(f'`{daemon_spec.host}: cephadm unit {name} {a}` failed')
self.cache.invalidate_host_daemons(daemon_spec.host)
msg = "{} {} from host '{}'".format(action, name, daemon_spec.host)
self.events.for_daemon(name, 'INFO', msg)
and action == 'reconfig':
action = 'redeploy'
try:
- self.mgr._daemon_action(
- daemon_type=dd.daemon_type,
- daemon_id=dd.daemon_id,
- host=dd.hostname,
- action=action
- )
+ daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(dd)
+ self.mgr._daemon_action(daemon_spec, action=action)
self.mgr.cache.rm_scheduled_daemon_action(dd.hostname, dd.name())
except OrchestratorError as e:
self.mgr.events.from_orch_error(e)
return files
+ @staticmethod
+ def from_daemon_description(dd: DaemonDescription) -> 'CephadmDaemonDeploySpec':
+ assert dd.hostname
+ assert dd.daemon_id
+ assert dd.daemon_type
+ return CephadmDaemonDeploySpec(
+ host=dd.hostname,
+ daemon_id=dd.daemon_id,
+ daemon_type=dd.daemon_type,
+ service_name=dd.service_name(),
+ ip=dd.ip,
+ ports=dd.ports,
+ )
+
def to_daemon_description(self, status: DaemonDescriptionStatus, status_desc: str) -> DaemonDescription:
return DaemonDescription(
daemon_type=self.daemon_type,
import orchestrator
from cephadm.serve import CephadmServe
+from cephadm.services.cephadmservice import CephadmDaemonDeploySpec
from cephadm.utils import ceph_release_to_major, name_to_config_section, CEPH_UPGRADE_ORDER
from orchestrator import OrchestratorError, DaemonDescription, daemon_type_to_service
logger.info('Upgrade: Updating %s.%s' %
(d.daemon_type, d.daemon_id))
try:
+ daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(d)
self.mgr._daemon_action(
- d.daemon_type,
- d.daemon_id,
- d.hostname,
+ daemon_spec,
'redeploy',
image=target_image
)