From: Sage Weil Date: Fri, 21 May 2021 18:43:24 +0000 (-0400) Subject: mgr/cephadm: progress item for service apply X-Git-Tag: v16.2.5~87^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dfcb8f87dd6e640bee9d955e2cb6fedb02d2ab7b;p=ceph.git mgr/cephadm: progress item for service apply Signed-off-by: Sage Weil (cherry picked from commit 089d2fb01b72366aed021caf34dacb85c09b93cc) --- diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 652d9c0c0f1e..3a2128e49580 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -1,6 +1,7 @@ import hashlib import json import logging +import uuid from collections import defaultdict from contextlib import contextmanager from typing import TYPE_CHECKING, Optional, List, cast, Dict, Any, Union, Tuple, Iterator @@ -701,6 +702,28 @@ class CephadmServe: self.log.debug('cannot scale mon|mgr below 1)') return False + # progress + progress_id = str(uuid.uuid4()) + delta: List[str] = [] + if slots_to_add: + delta += [f'+{len(slots_to_add)}'] + if daemons_to_remove: + delta += [f'-{len(daemons_to_remove)}'] + progress_title = f'Updating {spec.service_name()} deployment ({" ".join(delta)} -> {len(all_slots)})' + progress_total = len(slots_to_add) + len(daemons_to_remove) + progress_done = 0 + + def update_progress() -> None: + self.mgr.remote( + 'progress', 'update', progress_id, + ev_msg=progress_title, + ev_progress=(progress_done / progress_total), + add_to_ceph_s=True, + ) + + if progress_total: + update_progress() + # add any? did_config = False @@ -758,6 +781,7 @@ class CephadmServe: # there is only 1 gateway. self._remove_daemon(d.name(), d.hostname) daemons_to_remove.remove(d) + progress_done += 1 break # deploy new daemon @@ -781,6 +805,8 @@ class CephadmServe: daemon_spec = svc.prepare_create(daemon_spec) self._create_daemon(daemon_spec) r = True + progress_done += 1 + update_progress() except (RuntimeError, OrchestratorError) as e: msg = (f"Failed while placing {slot.daemon_type}.{daemon_id} " f"on {slot.hostname}: {e}") @@ -790,6 +816,8 @@ class CephadmServe: # later successes will also change to True if r is None: r = False + progress_done += 1 + update_progress() continue # add to daemon list so next name(s) will also be unique @@ -816,6 +844,11 @@ class CephadmServe: assert d.hostname is not None self._remove_daemon(d.name(), d.hostname) + progress_done += 1 + update_progress() + + self.mgr.remote('progress', 'complete', progress_id) + if r is None: r = False return r