From: Pere Diaz Bou Date: Tue, 7 Jun 2022 17:57:44 +0000 (+0200) Subject: mgr/dashboard: add byte info, move state, add idle state X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c2aa36a258ac3722ddb49a1f9cbffe53ae0358bc;p=ceph.git mgr/dashboard: add byte info, move state, add idle state Resolves: rhbz#1891012 Idle substate added from snapshot mode. Instead of seconds info we display bytes and entries info. Signed-off-by: Pere Diaz Bou (cherry picked from commit 453446104b8fe86b3f561b99a7b5a5838ee89478) --- diff --git a/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py b/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py index 5a434fbd570b1..1e8536b09fd8a 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py +++ b/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py @@ -4,7 +4,7 @@ import json import logging import re from functools import partial -from typing import no_type_check +from typing import NamedTuple, Optional, no_type_check import cherrypy import rbd @@ -199,6 +199,13 @@ def get_daemons_and_pools(): # pylint: disable=R0915 } +class ReplayingData(NamedTuple): + bytes_per_second: Optional[int] = None + seconds_until_synced: Optional[int] = None + syncing_percent: Optional[float] = None + entries_behind_primary: Optional[int] = None + + @ViewCache() @no_type_check def _get_pool_datum(pool_name): @@ -250,8 +257,9 @@ def _get_pool_datum(pool_name): rbd.MIRROR_IMAGE_STATUS_STATE_STOPPED: { 'health': 'ok', 'state_color': 'info', - 'state': 'Primary' + 'state': 'Stopped' } + } rbdctx = rbd.RBD() @@ -273,6 +281,29 @@ def _get_pool_datum(pool_name): return data +def _update_syncing_image_data(mirror_image, image): + if mirror_image['state'] == 'Replaying': + p = re.compile("replaying, ({.*})") + replaying_data = p.findall(mirror_image['description']) + assert len(replaying_data) == 1 + replaying_data = json.loads(replaying_data[0]) + if 'replay_state' in replaying_data and replaying_data['replay_state'] == 'idle': + image.update({ + 'state_color': 'info', + 'state': 'Idle' + }) + for field in ReplayingData._fields: + try: + image[field] = replaying_data[field] + except KeyError: + pass + else: + p = re.compile("bootstrapping, IMAGE_COPY/COPY_OBJECT (.*)%") + image.update({ + 'progress': (p.findall(mirror_image['description']) or [0])[0] + }) + + @ViewCache() def _get_content_data(): # pylint: disable=R0914 pool_names = [pool['pool_name'] for pool in CephService.get_pool_list('rbd') @@ -309,22 +340,7 @@ def _get_content_data(): # pylint: disable=R0914 }) image_ready.append(image) elif mirror_image['health'] == 'syncing': - if mirror_image['state'] == 'Replaying': - p = re.compile("replaying, ({.*})") - replaying_data = p.findall(mirror_image['description']) - assert len(replaying_data) == 1 - replaying_data = json.loads(replaying_data[0]) - seconds_until_synced = 0 - if 'seconds_until_synced' in replaying_data: - seconds_until_synced = replaying_data['seconds_until_synced'] - image.update({ - 'seconds_until_synced': seconds_until_synced - }) - else: - p = re.compile("bootstrapping, IMAGE_COPY/COPY_OBJECT (.*)%") - image.update({ - 'progress': (p.findall(mirror_image['description']) or [0])[0] - }) + _update_syncing_image_data(mirror_image, image) image_syncing.append(image) else: image.update({ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.html index a052f43c9a59a..a9547a10bc4af 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.html @@ -55,12 +55,6 @@ let-row="row" let-value="value">
- - synced - - - {{row.seconds_until_synced | duration }} until synced -
{