]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add byte info, move state, add idle state
authorPere Diaz Bou <pdiazbou@redhat.com>
Tue, 7 Jun 2022 17:57:44 +0000 (19:57 +0200)
committerNizamudeen A <nia@redhat.com>
Tue, 16 Aug 2022 07:30:58 +0000 (13:00 +0530)
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 <pdiazbou@redhat.com>
(cherry picked from commit 453446104b8fe86b3f561b99a7b5a5838ee89478)

src/pybind/mgr/dashboard/controllers/rbd_mirroring.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/image-list/image-list.component.ts

index 5a434fbd570b1979bc45e1265ed78a5c2d53f332..1e8536b09fd8a3a9c2fe9735e70dfe79909c60cb 100644 (file)
@@ -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({
index a052f43c9a59a8d63995a355f9c53eb9d0b05bbb..a9547a10bc4af82348d971b74bde9b1d46d6ca5a 100644 (file)
              let-row="row"
              let-value="value">
   <div *ngIf="row.state === 'Replaying'">
-    <span *ngIf="row.seconds_until_synced == 0">
-      synced
-    </span>
-    <span *ngIf="row.seconds_until_synced > 0">
-      {{row.seconds_until_synced | duration }} until synced
-    </span>
   </div>
   <ngb-progressbar *ngIf="row.state === 'Syncing'"
                     type="info"
index c7f6e91883e9b3dee183d28243f0c8a5bf81d285..00fe91338fa243ef5d35ab588706a4ac274a897b 100644 (file)
@@ -41,42 +41,44 @@ export class ImageListComponent implements OnInit, OnDestroy {
     this.image_error.columns = [
       { prop: 'pool_name', name: $localize`Pool`, flexGrow: 2 },
       { prop: 'name', name: $localize`Image`, flexGrow: 2 },
-      { prop: 'description', name: $localize`Issue`, flexGrow: 4 },
       {
         prop: 'state',
         name: $localize`State`,
         cellTemplate: this.stateTmpl,
         flexGrow: 1
-      }
+      },
+      { prop: 'description', name: $localize`Issue`, flexGrow: 4 },
     ];
 
     this.image_syncing.columns = [
       { prop: 'pool_name', name: $localize`Pool`, flexGrow: 2 },
       { prop: 'name', name: $localize`Image`, flexGrow: 2 },
+                       {
+        prop: 'state',
+        name: $localize`State`,
+        cellTemplate: this.stateTmpl,
+        flexGrow: 1
+      },
       {
         prop: 'progress',
         name: $localize`Progress`,
         cellTemplate: this.progressTmpl,
         flexGrow: 2
       },
-      {
-        prop: 'state',
-        name: $localize`State`,
-        cellTemplate: this.stateTmpl,
-        flexGrow: 1
-      }
+      { prop: 'bytes_per_second', name: $localize`Bytes per second`, flexGrow: 2 },
+                       { prop: 'entries_behind_primary', name: $localize`Entries behind primary`, flexGrow: 2 },
     ];
 
     this.image_ready.columns = [
       { prop: 'pool_name', name: $localize`Pool`, flexGrow: 2 },
       { prop: 'name', name: $localize`Image`, flexGrow: 2 },
-      { prop: 'description', name: $localize`Description`, flexGrow: 4 },
       {
         prop: 'state',
         name: $localize`State`,
         cellTemplate: this.stateTmpl,
         flexGrow: 1
-      }
+      },
+      { prop: 'description', name: $localize`Description`, flexGrow: 4 },
     ];
 
     this.subs = this.rbdMirroringService.subscribeSummary((data) => {