openebs / dynamic-localpv-provisioner

Dynamically deploy Stateful Persistent Node-Local Volumes & Filesystems for Kubernetes that is provisioned from simple Local-Hostpath /root storage.
https://openebs.io
Apache License 2.0
143 stars 63 forks source link

Delay in pod deletion when having localpv provisioned #154

Open lordofire opened 1 year ago

lordofire commented 1 year ago

Describe the bug: When a pod is created with the localpv provisioned, deleting the pod using kubectl along with the pv will take around 40+ seconds whereas creating a pod should return instantly.

Expected behaviour: Delete a pod should have very small blocking wait compared to pod creation.

Steps to reproduce the bug:

  1. Setup the hostpath with xfs quota enabled. Install the openebs localpv provisioner.
  2. Create a pod along with the pv with the following configuration test.yaml
    apiVersion: apps/v1
    kind: List
    items:
    - kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
    name: local-hostpath-pvc
    namespace: infra-offline-dev
    spec:
    storageClassName: openebs-hostpath
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 5G
    - apiVersion: v1
    kind: Pod
    metadata:
    name: hello-local-device-pod
    namespace: infra-offline-dev
    spec:
    volumes:
      - name: local-storage
        persistentVolumeClaim:
          claimName: local-hostpath-pvc
    containers:
      - name: hello-container
        image: busybox
        command:
          - sh
          - -c
          - 'while true; do echo "`date` [`hostname`] Hello from OpenEBS Local PV." >> /mnt/store/greet.txt; sleep $(($RANDOM % 5 + 300)); done'
        volumeMounts:
          - mountPath: /mnt/store
            name: local-storage

    cmd: kubectl apply -f test.yaml

  3. After waiting the pod being created, delete the pod as well as the pvc together using kubectl: cmd: kubectl delete -f test.yaml

My test output when performing the delete:

Linux$ time kubectl delete -f test.yaml
persistentvolumeclaim "local-hostpath-pvc" deleted
pod "hello-local-device-pod" deleted

real    0m43.641s
user    0m0.098s
sys 0m0.034s

Anything else we need to know?: N/A

Environment details:

lordofire commented 1 year ago

Any update on this issue?

lordofire commented 1 year ago

Any update on this issue?

niladrih commented 5 months ago

This might help in achieving quicker Pod-schedule times for the hostpath delete job. There aren't a lot of tweak-able setting that make the controller more. However, that is an enhancement that could benefit users.

I'll see the hostNetwork change going in in v4.1.0. Maybe you could see if that helps with your times.

tiagolobocastro commented 1 month ago

@lordofire did you capture some logs from openebs-localpv-provisioner-5d88cb474b-j59qk at the time? It seems to have restarted 16 times. @niladrih any updates here, do you understand the root cause?