kadalu / kadalu

A lightweight Persistent storage solution for Kubernetes / OpenShift / Nomad using GlusterFS in background. More information at https://kadalu.tech
https://docs.kadalu.tech/k8s-storage/devel/quick-start/
Other
713 stars 98 forks source link

[Bug]: grep matches volumes with same prefix #1077

Open ramalhais-sky opened 3 months ago

ramalhais-sky commented 3 months ago

Describe the bug This command has a bug: https://github.com/kadalu/kadalu/blob/d6bfe1ada056a4aa421c0c3be0f5e1ab00cbb453/lib/kadalulib.py#L67 It uses grep to match a volume, but it should use regex to exactly match the volume name, otherwise, it will match any volumes with the same prefix

To Reproduce Steps to reproduce the behavior:

  1. Create kadalustorage volprevix
  2. Create kadalustorage volprevix-other
  3. Create corresponding PVCs
  4. Verify that kadalu will not process any other volumes AND kadalu-provisioner-0 errors with
    [2024-08-01 17:09:47,424] ERROR [_server - 508:_call_behavior] - Exception calling application: [Errno 2] No such file or directory: '/mnt/volprevix'
    Traceback (most recent call last):
    File "/kadalu/lib/python3.10/site-packages/grpc/_server.py", line 494, in _call_behavior
    response_or_iterator = behavior(argument, context)
    File "/kadalu/controllerserver.py", line 120, in CreateVolume
    volume = search_volume(request.name)
    File "/kadalu/volumeutils.py", line 782, in search_volume
    retry_errors(os.statvfs, [mntdir], [ENOTCONN])
    File "/kadalu/kadalulib.py", line 48, in retry_errors
    return func(*args)
    FileNotFoundError: [Errno 2] No such file or directory: '/mnt/volprevix'

Expected behavior Just work

Actual behavior Unable to process any other volumes and errors out with restarts of containers in kadalu-provisioner-0

Environment:

$ kubectl kadalu version
kubectl-kadalu plugin: 1.1.0
kadalu pod(s) versions
pod/kadalu-csi-nodeplugin-2xw26: devel
pod/kadalu-csi-nodeplugin-jwtrz: devel
pod/kadalu-csi-nodeplugin-mb6w8: devel
pod/kadalu-csi-nodeplugin-ml9fg: devel
pod/kadalu-csi-provisioner-0: devel
pod/operator-5f957b8cb9-5dtj5: devel

Screenshots or Logs Please ask

Additional context As a work around try not to name the PVCs in a way that one will be a prefix of the other. ex: Call them begin-PVC_NAME-end

madoe commented 3 months ago

Thanks for bringing this up. I experienced the same error (Tried to describe it in #1058, but could not reproduce it at this time due to an other error)