Bug 2135830

Summary: For reattaching an existing PV with ReclaimPloicy: Retain latest pvc name is not updated in metadata
Product: [Red Hat Storage] Red Hat OpenShift Data Foundation Reporter: Amrita Mahapatra <ammahapa>
Component: rookAssignee: Madhu Rajanna <mrajanna>
Status: CLOSED CURRENTRELEASE QA Contact: Amrita Mahapatra <ammahapa>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.12CC: ebenahar, mrajanna, muagarwa, ocs-bugs, odf-bz-bot, tnielsen
Target Milestone: ---   
Target Release: ODF 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.12.0-80 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-02-08 14:06:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Amrita Mahapatra 2022-10-18 14:10:34 UTC
Description of problem (please be detailed as possible and provide log
snippests): Metadata is not updated after a PVC is deleted by setting ReclaimPloicy: Retain on PV and a freshly created PVC attach to the old PV for CSI_ENABLE_METADATA flag set to true.

oc get cm rook-ceph-operator-config -o yaml
apiVersion: v1
data:
  CSI_ENABLE_METADATA: "true"
  CSI_ENABLE_OMAP_GENERATOR: "true"
kind: ConfigMap
metadata:
  creationTimestamp: "2022-10-14T12:21:37Z"
  name: rook-ceph-operator-config
  namespace: openshift-storage
  resourceVersion: "7685925"
  uid: dc69272c-e8b5-4497-af42-3aac341ad66a

Metadata for the pvc created, the Pv associated has ReclaimPloicy: Retain

oc get pvc | grep pvc-rbd-retain
pvc-rbd-retain-pv             Bound    pvc-20285835-dbd7-4a8d-83aa-f548825c783d   1Gi        RWO            ocs-storagecluster-ceph-rbd   6m44s

oc get pv | grep pvc-20285835-dbd7-4a8d-83aa-f548825c783d
pvc-20285835-dbd7-4a8d-83aa-f548825c783d   1Gi        RWO            Retain           Bound    openshift-storage/pvc-rbd-retain-pv                              ocs-storagecluster-ceph-rbd            8m57s

bash-4.4$ rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-a27473bc-392c-44b6-9c64-818367cbce98
There are 4 metadata on this image:

Key                               Value                                   
csi.ceph.com/cluster/name         15e431d1-b362-4c3b-957c-30864e68cda2    
csi.storage.k8s.io/pv/name        pvc-20285835-dbd7-4a8d-83aa-f548825c783d
csi.storage.k8s.io/pvc/name       pvc-rbd-retain-pv                       
csi.storage.k8s.io/pvc/namespace  openshift-storage


Delete the pvc–
oc get pv | grep pvc-20285835-dbd7-4a8d-83aa-f548825c783d
pvc-20285835-dbd7-4a8d-83aa-f548825c783d   1Gi        RWO            Retain           Released   openshift-storage/pvc-rbd-retain-pv                              ocs-storagecluster-ceph-rbd            11m


Still the metadata details are available–
rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-a27473bc-392c-44b6-9c64-818367cbce98
There are 4 metadata on this image:

Key                               Value                                   
csi.ceph.com/cluster/name         15e431d1-b362-4c3b-957c-30864e68cda2    
csi.storage.k8s.io/pv/name        pvc-20285835-dbd7-4a8d-83aa-f548825c783d
csi.storage.k8s.io/pvc/name       pvc-rbd-retain-pv                       
csi.storage.k8s.io/pvc/namespace  openshift-storage

Removed claim ref—
oc get pv | grep pvc-20285835-dbd7-4a8d-83aa-f548825c783d
pvc-20285835-dbd7-4a8d-83aa-f548825c783d   1Gi        RWO            Retain           Available                                                                    ocs-storagecluster-ceph-rbd            13m
New pvc created—
oc get pvc | grep pvc-rbd-retain
pvc-rbd-retain-pv2            Bound    pvc-20285835-dbd7-4a8d-83aa-f548825c783d   1Gi        RWO            ocs-storagecluster-ceph-rbd   45s

oc get pv | grep pvc-20285835-dbd7-4a8d-83aa-f548825c783d
pvc-20285835-dbd7-4a8d-83aa-f548825c783d   1Gi        RWO            Retain           Bound    openshift-storage/pvc-rbd-retain-pv2                             ocs-storagecluster-ceph-rbd            15m


In metadata pvc name is not updated for the retained pv—
rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-a27473bc-392c-44b6-9c64-818367cbce98
There are 4 metadata on this image:

Key                               Value                                   
csi.ceph.com/cluster/name         15e431d1-b362-4c3b-957c-30864e68cda2    
csi.storage.k8s.io/pv/name        pvc-20285835-dbd7-4a8d-83aa-f548825c783d
csi.storage.k8s.io/pvc/name       pvc-rbd-retain-pv                       
csi.storage.k8s.io/pvc/namespace  openshift-storage



Version of all relevant components (if applicable):
OCP version --- 4.12.0-0.nightly-2022-10-05-053337
OCS version --- 4.12.0-74


Does this issue impact your ability to continue to work with the product
(please explain in detail what is the user impact)? No


Is there any workaround available to the best of your knowledge? No


Rate from 1 - 5 the complexity of the scenario you performed that caused this
bug (1 - very simple, 5 - very complex)? 3


Can this issue reproducible? Yes


Can this issue reproduce from the UI? No


If this is a regression, please provide more details to justify this:


Steps to Reproduce:
1. Create a pvc and update the Pv associated with ReclaimPloicy: Retain

2. Check the metadata created
3. Delete the PVC check the PV is in Released state then remove claim ref for the PV and check the PV is in available state
4. Create another pvc, it will be attached to the existing PV
5. Check the metadata for the PV the pvc name should be the latest one


Actual results: In the metadata the previous pvc name is displaying


Expected results: In the metadata the pvc name should be the latest one 


Additional info: