Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: enhance tracevol.py script to work with volumesnapshots #5049

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

black-dragon74
Copy link
Member

Describe what this PR does

This patch adds the functionality to map the k8s volumesnapshots to the cephfs/rbd snapshots.

This patch also adds a wrapper around oc/kubectl called kube_client which will help get rid of code duplication.

Closes: #3344

Future concerns

I will follow up the refactors around kube_client in a separate PR

@black-dragon74
Copy link
Member Author

Testing

Script output

❯ troubleshooting/tools/tracevol.py -k ~/.kube/config -c kubectl -rn rook-ceph -n rook-ceph -cm rook-ceph-csi-config -cmn rook-ceph
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                            RBD                                                                             |
+----------+------------------------------------------+----------------------------------------------+-----------------+------------------+------------------+
| PVC Name |                 PV Name                  |                  Image Name                  | PV name in omap | Image ID in omap | Image in cluster |
+----------+------------------------------------------+----------------------------------------------+-----------------+------------------+------------------+
| rbd-pvc  | pvc-343d0393-882f-4ae3-acfe-bb94df0a3829 | csi-vol-ec58aaf0-2f28-45fc-95f8-67775e0be615 |       True      |       True       |       True       |
+----------+------------------------------------------+----------------------------------------------+-----------------+------------------+------------------+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                    CephFS                                                                                   |
+-------------------+------------------------------------------+----------------------------------------------+-----------------+----------------------+----------------------+
|      PVC Name     |                 PV Name                  |                Subvolume Name                | PV name in omap | Subvolume ID in omap | Subvolume in cluster |
+-------------------+------------------------------------------+----------------------------------------------+-----------------+----------------------+----------------------+
|     cephfs-pvc    | pvc-39a11e4c-2ddd-46c6-9b5a-6b004bd4eced | csi-vol-595c630d-6e17-4c00-a66e-91785fb01c6d |       True      |         True         |         True         |
| cephfs-static-pvc |             cephfs-static-pv             |                                              |      False      |        False         |        False         |
+-------------------+------------------------------------------+----------------------------------------------+-----------------+----------------------+----------------------+
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                         Volume Snapshots                                                                                         |
+---------------------------------------------------------------------------+------------+----------+----------------------------------------------+-----------------------------------------------+
|                                    Name                                   |    PVC     | PVC Type |                Subvolume Name                |                  Snapshot ID                  |
+---------------------------------------------------------------------------+------------+----------+----------------------------------------------+-----------------------------------------------+
|                              rbd-pvc-snapshot                             |  rbd-pvc   |   RBD    | csi-vol-ec58aaf0-2f28-45fc-95f8-67775e0be615 | csi-snap-dab553a8-9184-45ab-ba43-dde720fa45ea |
| snapshot-f64ca5dd7f01b816f689a0c44423338452e82ae57498cfd449949c1dc399fb68 | cephfs-pvc |  CephFS  | csi-vol-595c630d-6e17-4c00-a66e-91785fb01c6d | csi-snap-7a9fa01e-8577-4829-bb30-73b0ac94b534 |
+---------------------------------------------------------------------------+------------+----------+----------------------------------------------+-----------------------------------------------+

RBD snapshot inside ceph

❯ oc exec -it rook-ceph-tools-68bf47bc65-486jp -- rbd children replicapool/csi-vol-ec58aaf0-2f28-45fc-95f8-67775e0be615
replicapool/csi-snap-dab553a8-9184-45ab-ba43-dde720fa45ea

CephFS snapshot inside ceph

❯ oc exec -it rook-ceph-tools-68bf47bc65-486jp -- ceph fs subvolume snapshot ls myfs csi-vol-595c630d-6e17-4c00-a66e-91785fb01c6d csi
[
    {
        "name": "csi-snap-7a9fa01e-8577-4829-bb30-73b0ac94b534"
    }
]

Regards

@black-dragon74 black-dragon74 requested a review from a team January 2, 2025 11:52
This patch adds the functionality to map the k8s volumesnapshots
to the cephfs/rbd snapshots.

This patch also adds a wrapper around oc/kubectl called `kube_client`
which will help get rid of code duplication.

Closes: ceph#3344

Signed-off-by: Niraj Yadav <[email protected]>
@Madhu-1
Copy link
Collaborator

Madhu-1 commented Jan 3, 2025

+---------------------------------------------------------------------------+------------+----------+----------------------------------------------+-----------------------------------------------+
| Name | PVC | PVC Type | Subvolume Name | Snapshot ID |
+---------------------------------------------------------------------------+------------+----------+----------------------------------------------+-----------------------------------------------+
| rbd-pvc-snapshot | rbd-pvc | RBD | csi-vol-ec58aaf0-2f28-45fc-95f8-67775e0be615 | csi-snap-dab553a8-9184-45ab-ba43-dde720fa45ea |
| snapshot-f64ca5dd7f01b816f689a0c44423338452e82ae57498cfd449949c1dc399fb68 | cephfs-pvc | CephFS | csi-vol-595c630d-6e17-4c00-a66e-91785fb01c6d | csi-snap-7a9fa01e-8577-4829-bb30-73b0ac94b534 |
+---------------------------------------------------------------------------+------------+----------+----------------------------------------------+-----------------------------------------------+

can we have different table for cephfs and rbd just like we have for PVC? Subvolume Name is cephfs specific, if the type is RBD it doesn't make sense to print rbd details under subvolume name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance trace.py to work with volumesnapshots
2 participants