Bug 2138155

Summary: For reattaching an existing PV with ReclaimPloicy: Retain latest namespace details is not updated in metadata
Product: [Red Hat Storage] Red Hat OpenShift Data Foundation Reporter: Amrita Mahapatra <ammahapa>
Component: csi-driverAssignee: Madhu Rajanna <mrajanna>
Status: CLOSED CURRENTRELEASE QA Contact: Amrita Mahapatra <ammahapa>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.12CC: mrajanna, muagarwa, nberry, ocs-bugs, odf-bz-bot
Target Milestone: ---   
Target Release: ODF 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.12.0-87 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-27 12:28:04 UTC
Description of problem (please be detailed as possible and provide log
snippests):Namespace details under metadata is not updated after a PVC is deleted by setting ReclaimPloicy: Retain on PV and a freshly created PVC on a different namespace is attached to the old PV for CSI_ENABLE_METADATA and CSI_ENABLE_OMAP_GENERATOR flags are 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-27T07:14:35Z"
  name: rook-ceph-operator-config
  namespace: openshift-storage
  resourceVersion: "397438"
  uid: 891fa9e0-3f6c-410f-9f2e-a33683563227

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

oc get pvc -n test| grep rbd-pvc-test-namespace
rbd-pvc-test-namespace                      Bound    pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1   1Gi        RWO            ocs-storagecluster-ceph-rbd   116s


oc get pv | grep pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1
pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1   1Gi        RWO            Retain           Bound    test/rbd-pvc-test-namespace                              ocs-storagecluster-ceph-rbd            8m57s

bash-4.4$ rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-1fe1c4fb-ed99-484a-bb5f-a9a39e26c663
There are 4 metadata on this image:

Key                               Value                                   
csi.ceph.com/cluster/name         7635b583-f61d-4fe4-8d89-207c5595b415    
csi.storage.k8s.io/pv/name        pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1
csi.storage.k8s.io/pvc/name       rbd-pvc-test-namespace                  
csi.storage.k8s.io/pvc/namespace  test


Delete the pvc–
oc get pv -n test | grep pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1
pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1   1Gi        RWO            Retain           Released   test/rbd-pvc-test-namespace                                      ocs-storagecluster-ceph-rbd            3m58s


Clear claimref for the pv--
oc get pv -n test | grep pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1
pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1   1Gi        RWO            Retain           Available   ocs-storagecluster-ceph-rbd

Create a new PVC in a different namespace----
oc get pvc -n openshift-storage | grep rbd-pvc
rbd-pvc                       Bound    pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1   1Gi        RWO            ocs-storagecluster-ceph-rbd   13m


oc get pv| grep pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1
pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1   1Gi        RWO            Retain           Bound    openshift-storage/rbd-pvc                                        ocs-storagecluster-ceph-rbd            21m


The namespace details in metadata is not updated–

rbd image-meta ls ocs-storagecluster-cephblockpool/csi-vol-1fe1c4fb-ed99-484a-bb5f-a9a39e26c663
There are 4 metadata on this image:

Key                               Value                                   
csi.ceph.com/cluster/name         7635b583-f61d-4fe4-8d89-207c5595b415    
csi.storage.k8s.io/pv/name        pvc-71cf143b-5dcd-4711-98e2-4d3b23a4b0d1
csi.storage.k8s.io/pvc/name       rbd-pvc                                 
csi.storage.k8s.io/pvc/namespace  test



Version of all relevant components (if applicable):
OCP version --- 4.12.0-0.nightly-2022-10-25-210451
OCS version --- 4.12.0-82


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: NA


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 in a different namespace, it will be attached to the existing PV
5. Check the metadata for the PV the pvc name and namespace should be the latest one


Actual results: In the metadata the previous namespace is displaying


Expected results: In the metadata the namespace should be the latest one 


Additional info:

Comment 4 Mudit Agarwal 2022-10-31 03:21:08 UTC
Please backport to 4.12