Bug 1853429 - Unable to delete pv
Summary: Unable to delete pv
Keywords:
Status: CLOSED DUPLICATE of bug 1853384
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Storage
Version: 2.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Adam Litke
QA Contact: Ying Cui
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-02 16:14 UTC by Lars Kellogg-Stedman
Modified: 2020-07-07 11:14 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-07-07 11:14:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Lars Kellogg-Stedman 2020-07-02 16:14:00 UTC
(I've filed this against CNV because we're using the hostpath provisioner.)

Description of problem:

If I create a persistent volume claim using the hostpath provisioner:

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: lars-test-pvc
  namespace: default
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: hostpath-provisioner
  volumeMode: Filesystem

And then create a pod that consumes that claim:

---
apiVersion: "v1"
kind: "Pod"
metadata:
  name: "lars-test-pod"
  namespace: default
spec:
  containers:
    - name: "lars-test-web"
      image: "nginx"
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/var/www/html"
          name: "pvol"
  volumes:
    - name: "pvol"
      persistentVolumeClaim:
        claimName: "lars-test-pvc"

Everything seems to work just fine. A pv is created:

  $ oc get pv | grep lars-test-pvc
  pvc-043ff7b2-9adb-497b-8204-4c8d5fc56c15   557Gi      RWO            Delete           Bound         default/lars-test-pvc   hostpath-provisioner            80s


And the pod runs as expected:

  $ oc get pod lars-test-pod
  NAME            READY   STATUS    RESTARTS   AGE
  lars-test-pod   1/1     Running   0          27s


If I delete the pod...

  $ oc delete pod lars-test-pod

...the pod is removed successfully, but the pv persists.  If I try to delete the pv:

  $ oc delete pv pvc-043ff7b2-9adb-497b-8204-4c8d5fc56c15

The command reports:

  persistentvolume "pvc-043ff7b2-9adb-497b-8204-4c8d5fc56c15" deleted

But the command never exits. At this point, the pv status is "Terminating":

  $ oc get pv | grep lars-test-pvc
  pvc-043ff7b2-9adb-497b-8204-4c8d5fc56c15   557Gi      RWO            Delete           Terminating   default/lars-test-pvc   hostpath-provisioner            2m35s

If we delete the claim itself...

  $ oc delete pvc lars-test-pvc

...this seems to correctly delete both the pvc and the pv. Should attempting to delete the pv succeed? If not, should the command return an error message instead of hanging?

Comment 1 Qixuan Wang 2020-07-06 08:13:10 UTC
Hi Lars,

You can't expect to delete PV by deleting Pod directly, otherwise, what's the point of the persistent volume?
Removing PV by deleting PVC is the correct manner.
If you just want to delete PV directly but it's stuck in Terminating, it probably happens when PV is protected (describe PV then you can find finalizers: - kubernetes.io/pv-protection), set the finalizers to null would be helpful.

Comment 2 Adam Litke 2020-07-07 11:14:46 UTC
This is the same behavior as reported in Bug 1853384.  Typically with dynamically provisioned PVs, the PVC should be removed and this will cause the PV to be cleaned up automatically.  We still want to investigate the command hanging as that is not expected but we will address this in Bug 1853384.

*** This bug has been marked as a duplicate of bug 1853384 ***


Note You need to log in before you can comment on or make changes to this bug.