Skip to content

Commit d54d32b

Browse files
smanpathakcalind
authored andcommitted
Add owner reference for PVC
1 parent 0b2ac9f commit d54d32b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/mysqlcluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const (
8181
statusUpToDate = "up-to-date"
8282
statusCreated = "created"
8383
statusUpdated = "updated"
84-
statusFailed = "faild"
84+
statusFailed = "failed"
8585
statusOk = "ok"
8686
statusSkip = "skip"
8787
)

pkg/mysqlcluster/statefullset.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,21 @@ func (f *cFactory) ensureVolumes(in []core.Volume) []core.Volume {
459459
}
460460

461461
func (f *cFactory) ensureVolumeClaimTemplates(in []core.PersistentVolumeClaim) []core.PersistentVolumeClaim {
462+
initPvc := false
462463
if len(in) == 0 {
463464
in = make([]core.PersistentVolumeClaim, 1)
465+
initPvc = true
464466
}
465467
data := in[0]
466468

467469
data.Name = dataVolumeName
470+
471+
if initPvc {
472+
// This can be set only when creating new PVC. It ensures that PVC can be
473+
// terminated after deleting parent MySQL cluster
474+
data.ObjectMeta.OwnerReferences = f.getOwnerReferences()
475+
}
476+
468477
data.Spec = f.cluster.Spec.VolumeSpec.PersistentVolumeClaimSpec
469478

470479
in[0] = data

0 commit comments

Comments
 (0)