Delete all PVCs if guest cluster is deleted in Rancher #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a cluster is deleted, the PVCs of the workloads are not deleted in Harvester. This is because the node driver does not know why the associated VM has to be deleted, e.g. because its parameters have changed or because the cluster is deleted.
To solve the problem, a finalizer on the
Machine
resource in Rancher will add an annotation to the VM which then is evaluated by the node driver when it running theRemove()
handler.See rancher/rancher#47870 for the Rancher part.
Related to: harvester/harvester#2825
When the cluster is deleted in Rancher, a pod is started which will run the
docker-machine-driver-harvester
binary. The output will look like this:Testing
Testing can be done via an ipxe test cluster. Note, this test requires a Rancher setup containing this PR.
make build && make package
ssh [email protected]
and run:Pod
tab and chooseCreate Persistent Volume Claim
after pressing theAdd Volume
button. Make sure to use theHarvester
storage class.harvesterhci.io/removeAllPersistentVolumeClaims
annotation at the VM in Harvester.10. There is a pod (in the Rancher context) which is running the node driver binary. The log output should look like this:
Force the removal of all persistent volume claims
log line MUST be present.Volumes
page in Harvester. The volume that was created by the workload in rancher MUST be removed.