]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: progress item for service apply
authorSage Weil <sage@newdream.net>
Fri, 21 May 2021 18:43:24 +0000 (14:43 -0400)
committerSage Weil <sage@newdream.net>
Thu, 3 Jun 2021 12:41:15 +0000 (07:41 -0500)
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 089d2fb01b72366aed021caf34dacb85c09b93cc)

src/pybind/mgr/cephadm/serve.py

index 652d9c0c0f1e2c998814fd789fa4a9b71fd13c83..3a2128e4958045ca6e1b9b43a9e8edd6c848887e 100644 (file)
@@ -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