Closed mh013370 closed 9 months ago
This implementation isn't quite complete. All of the objects created under NifiCluster
are configured to be owned by the NifiCluster
CRD. When that object gets deleted, every object it owns is garbage collected including the PVCs.
To prevent this, we have to release ownership of the Retain
PVCs prior to finalizing deletion of the NifiCluster
. There are some edge cases here we need to handle when reclaim policies are changed during the NifiCluster
lifecycle that i must handle.
Will push changes to address this.
I've verified these changes by running the following tests:
Create NifiCluster
with Retain
PVCs & delete the cluster. Assert that PVCs remain after NifiCluster
is deleted. Re-create NifiCluster
and assert that PVCs are re-bound to new cluster.
Create NifiCluster
with Delete
PVCs & delete the cluster. Assert that PVCs are deleted when NifiCluster
is deleted.
Create NifiCluster
with Retain
PVCs, change reclaim policy to Delete
, then delete the cluster. Assert that PVCs are deleted when cluster is deleted.
Create NifiCluster
with Delete
PVCs, change reclaim policy to Retain
, then delete the cluster. Assert that PVCs remain after NifiCluster
is deleted. Re-create NifiCluster
and assert that PVCs are re-bound to new cluster.
Create NifiCluster
with Retain
PVCs. Scale cluster up by 1 node & then scale cluster down by 1. Ensure that new node's PVCs are retained. Scale cluster back up by 1 and ensure that PVC is re-bound to new pod.
Create NifiCluster
with Delete
PVCs. Scale cluster up by 1 & then scale cluster down by 1. Ensure that the new node's PVCs are deleted.
All test cases were successful.
What's in this PR?
Adds a new optional field called
ReclaimPolicy
to nifikop's volumeStorageConfig
. This instructs nifikop whether or not toDelete
orRetain
PVCs onNifiCluster
deletion.There's a caveat here where nifikop will only re-attach the PVC to the node it was previously attached to. It will not re-attach the PVC to a random node in the case that a
NifiCluster
is created and then deleted with PVCs configured withRetain
reclaim policies. If a PVC is created for node 2, for example, it will only ever belong to node 2.Example NifiCluster
NodeConfig
:Why?
To prevent data loss when a
NifiCluster
is accidentally deleted. I think we ought to recommend that the reclaim policies be left as the defaultDelete
policy to avoid the potential for leaving PVCs around indefinitely. If a PVC is configured asRetain
, nifikop will never delete it. it must be deleted manually or reconfigured asDelete
and then delete theNifiCluster
.Checklist