Skip to content

Commit

Permalink
Add delete protection for local mode
Browse files Browse the repository at this point in the history
This adds delete protection for local mode. Current implementation
deletes Deployment AND PVC. After this change only the deployment will
be deleted if the delete protection is set on the CRD.
  • Loading branch information
blacksails committed Dec 16, 2019
1 parent 7326e77 commit 7ea0659
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions local/local_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,14 @@ func (r *Local) DeleteDatabase(db *crd.Database) error {
continue
}

if err := r.kc.CoreV1().PersistentVolumeClaims(db.Namespace).Delete(db.Name,
&metav1.DeleteOptions{}); err != nil {
fmt.Printf("ERROR: error while deleting the pvc: %v\n", err)
continue
if db.Spec.DeleteProtection {
log.Printf("Trying to delete a %v in %v which is a deleted protected database", db.Name, db.Namespace)
} else {
if err := r.kc.CoreV1().PersistentVolumeClaims(db.Namespace).Delete(db.Name,
&metav1.DeleteOptions{}); err != nil {
fmt.Printf("ERROR: error while deleting the pvc: %v\n", err)
continue
}
}

return nil
Expand Down

0 comments on commit 7ea0659

Please sign in to comment.