Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting dataset before deleting the pod referring to the dataset leads to orphaned DatasetInternal objects #344

Open
srikumar003 opened this issue Mar 25, 2024 · 2 comments
Assignees
Labels
bug Something isn't working dataset Issues related to the Dataset and DatasetInternal Operator

Comments

@srikumar003
Copy link
Collaborator

Relates to #341

More description to follow

@srikumar003 srikumar003 added bug Something isn't working dataset Issues related to the Dataset and DatasetInternal Operator labels Apr 22, 2024
@srikumar003
Copy link
Collaborator Author

srikumar003 commented Apr 30, 2024

Describing Persistent Volume Claims displays a "Used By" field which can be used to determine if any pods are referencing the PVC (and hence the dataset).

kubectl describe pvc example-dataset

returns

Name:          example-dataset 
Namespace:     xxxx
StorageClass:  csi-s3
Status:        Bound
Volume:       yyyy
Labels:        dataset=example-dataset
Annotations:   pv.kubernetes.io/bind-completed: yes
               pv.kubernetes.io/bound-by-controller: yes
               volume.beta.kubernetes.io/storage-provisioner: ch.ctrox.csi.s3-driver
               volume.kubernetes.io/storage-provisioner: ch.ctrox.csi.s3-driver
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      9765625000Ki
Access Modes:  RWX
VolumeMode:    Filesystem
Used By:       <none>
Events:        <none>

Relevant issue

We can use the same logic used by kubectl describe - i.e. loop through the pods in the namespace and add the name of the pods which have a PVC annotation for the dataset/PVC name to a list. if list is not empty, dataset cannot be detected.

Also, use this logic to populate a similar used-by field for the dataset.

@srikumar003
Copy link
Collaborator Author

The Dataset custom resource creates a DatasetInternal resource which actually "owns" the resources (PVC, ConfigMaps) etc created for the former.

The finaliser of the DatasetInternal checks if the PVC is referenced before deletion and does not exit until this is deleted.

However, Dataset has no finalizer present, so it's deletion goes through, leaving the DatasetInternal object orphaned.

To resolve this issue, we need to catch a DELETE request and check if the corresponding Internal instance has been deleted, or else deny the request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dataset Issues related to the Dataset and DatasetInternal Operator
Projects
None yet
Development

No branches or pull requests

2 participants