PaloAltoNetworks / prisma-cloud-compute-operator

15 stars 22 forks source link

Deleting the Console CR removed underlying PVC #30

Open ctrought opened 2 years ago

ctrought commented 2 years ago

Describe the bug

More of an undesirable behaviour, but when deleting the CR for an existing console the underlying PVCs are deleted. This behaviour can vary by operator, so if it is deleted with the assumption the PVC can be reused when redeploying the console CR then all data is unknowingly wiped and all configuration and data is lost.

https://sdk.operatorframework.io/docs/building-operators/golang/advanced-topics/#sensitive-resources

Expected behavior

Retain PVC's and require manual cleanup, the PVC will be reused unless user deletes it manually.

Current behavior

PVC is deleted when the console CR is removed.

Possible solution

Do not set ownerReferences on the PVC

Steps to reproduce

  1. Delete an existing console CR with the intention of redeploying (e.g. bugs during upgrade process)
  2. PVC is deleted
  3. Redeploy console CR
  4. Data is gone

Context

A number of operator created PVCs do not set ownerReferences so that PVC's are retained so that the criticality of the data kept there is determined by the end user.

Your Environment

ctrought commented 2 years ago

I guess another option may be to set a finalizer on the PVC

      blockOwnerDeletion: true