Introducing a ReclaimPolicy for ephemerally created Volume resource#1153
Introducing a ReclaimPolicy for ephemerally created Volume resource#1153ushabelgur wants to merge 2 commits intoironcore-dev:mainfrom
ReclaimPolicy for ephemerally created Volume resource#1153Conversation
| } | ||
|
|
||
| func IsDefaultEphemeralOrControlledBy(o metav1.Object, owner metav1.Object) bool { | ||
| return metav1.IsControlledBy(o, owner) || IsEphemeralManagedBy(o, commonv1alpha1.DefaultEphemeralManager) |
There was a problem hiding this comment.
Note: I added new method with OR condition here, as above original method IsDefaultEphemeralControlledBy() is used by all other ephemeral controllers and it will break behavior of those controllers.
c7fbc7e to
3eb6dca
Compare
| } | ||
| annotations.SetDefaultEphemeralManagedBy(volume) | ||
| _ = ctrl.SetControllerReference(machine, volume, r.Scheme()) | ||
| if machineVolume.Ephemeral.VolumeTemplate.Spec.ReclaimPolicy != storagev1alpha1.Retain { |
There was a problem hiding this comment.
In case we use Retain policy for ephemeral Volumes and we don't set the controller reference, there will be no finalizer preventing the deletion of a Volume. We should prohibit the deletion of an ephemeral volume at all times as long as the Machine object exists. One idea would be to always set the controller reference and remove it in the case of a Machine deletion.
There was a problem hiding this comment.
We might can utilize RESTDeleteStrategy in /k8s.io/apiserver@v0.30.7/pkg/registry/rest/delete.go
There was a problem hiding this comment.
As discussed offline, If we want to handle removal of OwnerRef in registry using RESTDeleteStrategy, we are not adding ReclaimPolicy directly under VolumeSpec we have created wrapper around VolumeTemplateSpec as we didn't want to set this field for volumes other than ephemeral. so will not have reference to ReclaimPolicy in volme strategy.
So handling removal of controller reference in machine controller before deleting machine.
aba6b94 to
c9a8408
Compare
d5f6a51 to
c7fbc7e
Compare
|
As discussed offline, in ideal scenarios rook disks won't be created as ephemeral resource. In most of the case PVs will attached as volume to machine, which will be retained by default. This feature is not needed as of now. Closing the PR for now. |
Proposed Changes
ReclaimPolicyfor ephemerally createdVolumeresource with 2 supported modes:Retain: the resource is not deleted after the managing resource has been deletedDelete: the current behavior, the resource is garbage-collected when the managing resource has been deletedReclaimPolicywould be assumed to beDeleteto not to not break current behavior.VolumeTemplateSpecto supportReclaimPolicytype along with existing VolumeSpecOwnerReferenceis added to ephemerally created volume in both the case ofReclaimPolicyis set toDeleteto avoid deletion of ephemeral volumes accidently.ReclaimPolicyis set toRetain.[Note: volume_release_controller is already taking care of releasing volumes whose claimer doesn't existing, by setting .spec.claimRef to nil when claimer
Machineobject is deleted. So not adding any extra logic for this]Fixes #1114