Skip to content

Commit

Permalink
Log rbd mirror image status in the self test
Browse files Browse the repository at this point in the history
After the vrc is completed, log the rbd mirror image status, expanding
the metrics in the description field.

Example log (running rbd-mirror/test dr1 dr2):

    * rbd mirror image status in cluster dr1
      {
        "name": "csi-vol-09d91ca0-709d-422c-ade8-8da87aea1d44",
        "global_id": "03001adf-5001-44f5-ac28-fead2ad9baec",
        "state": "up+stopped",
        "description": "local image is primary",
        "daemon_service": {
          "service_id": "4378",
          "instance_id": "4380",
          "daemon_id": "a",
          "hostname": "dr1"
        },
        "last_update": "2022-10-25 18:16:03",
        "peer_sites": [
          {
            "site_name": "c25c4619-8f17-44ad-a3b4-bde531b97822",
            "mirror_uuids": "8a813851-7731-43a7-b31e-f3b44fd43788",
            "state": "up+replaying",
            "description": {
              "state": "replaying",
              "metrics": {
                "bytes_per_second": 0.0,
                "bytes_per_snapshot": 0.0,
                "remote_snapshot_timestamp": 1666721761,
                "replay_state": "idle"
              }
            },
            "last_update": "2022-10-25 18:16:03"
          }
        ],
        "snapshots": [
          {
            "id": 50,
            "name": ".mirror.primary.03001adf-5001-44f5-ac28-fead2ad9baec.3f6e8450-1a7b-4f75-9ea3-48ed81fc2de8",
            "demoted": false,
            "mirror_peer_uuids": [
              "d53aa0da-b0b9-418c-81dc-95db0efcc4e9"
            ]
          }
        ]
      }

It takes from seconds until rbd report the local_snapshot_timestamp, not
sure why. It always have the same timestamp as the remove snapshot, so
it seems pointless to wait few seconds until it is reported.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Oct 27, 2022
1 parent f51851c commit 9f189b1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/rbd-mirror/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

import json
import sys
import time

Expand All @@ -13,6 +14,29 @@ POOL_NAME = "replicapool"
PVC_NAME = "rbd-pvc"


def rbd_mirror_image_status(cluster, image):
out = drenv.kubectl(
"exec", "deploy/rook-ceph-tools", "--namespace", "rook-ceph", "--",
"rbd", "mirror", "image", "status", f"{POOL_NAME}/{image}",
"--format", "json",
profile=cluster,
verbose=False,
)
status = json.loads(out)

# Exapand metrics json embdeded in the peer description.
for peer in status["peer_sites"]:
desc = peer.get("description", "")
if ", " in desc:
state, metrics = desc.split(", ", 1)
peer["description"] = {
"state": state,
"metrics": json.loads(metrics),
}

return status


def test_volume_replication(primary, secondary):
drenv.log_progress(f"Deploying pvc {PVC_NAME} in cluster {primary}")
drenv.kubectl(
Expand Down Expand Up @@ -106,6 +130,10 @@ def test_volume_replication(primary, secondary):
profile=primary,
)

drenv.log_progress(f"rbd mirror image status in cluster {primary}")
image_status = rbd_mirror_image_status(primary, rbd_image)
drenv.log_detail(json.dumps(image_status, indent=2))

drenv.log_progress(f"Deleting vr vr-sample in primary cluster {primary}")
drenv.kubectl(
"delete", "volumereplication", "vr-sample",
Expand Down

0 comments on commit 9f189b1

Please sign in to comment.