-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
provisioner: Data corruption if PVC Name is used across namespaces #8987
Comments
Oof. That's not a good behavior for the storage provisioner. Do you mind opening up a PR so that this behaves in a way consistent with your expectations? We can then land it into the next release. Thank you for raising this issue. |
If I were to create a PR, all I would do is give an untested change which set it back to use PVName. I don't know the code base to work out how to retrieve the namespace to change it to incorporate that. Putting it back to PVName though will likely upset people who wanted a more predictable directory path though. |
Reverting to the previous code seems like the correct thing to do here, I am not sure that "predictable names" was a good feature anyway (for something that automatic allocates storage for you). It would also be nice with some regression tests for the storage provisioner, so we can avoid things like storing PV on tmpfs or bugs with multiple namespaces (or multiple hosts) - like this one. |
For the benefit of others who may stumble across this issue when investigating apparent data corruption issues, the original behaviour were unique names were used for persistent volumes was not restored. Instead, a path was used that incorporated both the name of the namespace and that of the persistent volume claim. That addressed the reported problem, but is not a full proof solution. The problem that can now arise is where the storage provisioner is too slow to reclaim the persistent volume and delete the physical directory. The consequence is that if you create a persistent volume claim of same name in a namespace, it can grab the original physical directory before it is deleted, with the storage provisioner then being prevented from deleting it since sees it as in use again. If the persistent volume had data in it, the new deployment using the persistent volume claim will see the old data, which can cause a range of application specific problems since it will work off the old data and may not reinitialise a database etc. In short, if reusing a persistent volume claim name in the same namespace, ensure you wait a period of time for the original persistent volume claim to be released properly and the underlying persistent volume reclaimed and the physical directory deleted. In the worst case you may have to ssh into the minikube VM and watch the directory used by the storage provisioner to ensure the directory is gone before reusing the same persistent volume claim name in a namespace. |
As raised in comment:
in PR:
a change was made to how directories on disk were named when created by the storage provisioner:
That is, the change at line 60 from:
to:
This meant that whereas previously the name of the directory on disk was unique, and named after the PV (which used a uuid or similar), the name of the directory on disk was changed to the PVC name.
The problem is that the PVC name isn't unique because the same PVC name can be used in different namespaces.
This change causes a data corruption problem for applications because the PVC in two different namespaces can be assigned the same directory on disk for storage when the PVC names are the same in each namespace.
This means you can't for example run two instances of same database deployment in two different namespaces as they will trample on each others database files and corrupt themselves since they use the same PVC name.
The original method of using the PV name was much safer.
If you really want directory names to be more friendly, you must use the name of the namespace in the path as well. For example, in the form:
Without a change to this, will keep having persistent volume data corruption issues.
Steps to reproduce the issue:
Create two separate namespaces.
Create a PVC in each namespace where the PVC has the same name.
Create a deployment in each namespace which mounts the respective PVC in that namespace.
Write files to the persistent volume from each pod and will see that is the same storage. You can also look at the PV created for each and see it is the same file system path.
For example:
Full output of
minikube start
command used, if not already included:The text was updated successfully, but these errors were encountered: