Skip to content

Commit

Permalink
Fix-118: Check UID before deleting PVC
Browse files Browse the repository at this point in the history
  • Loading branch information
srteam2020 authored and marshtompsxd committed Nov 2, 2021
1 parent ed4a19b commit e407779
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
// DatacenterLabel is the operator's label for the datacenter name
DatacenterLabel = "cassandra.datastax.com/datacenter"

// DatacenterUID is the operator's label for datacenter UID
DatacenterUID = "cassandra.datastax.com/datacenterUID"

// SeedNodeLabel is the operator's label for the seed node state
SeedNodeLabel = "cassandra.datastax.com/seed-node"

Expand Down Expand Up @@ -496,6 +499,7 @@ func (dc *CassandraDatacenter) SetCondition(condition DatacenterCondition) {
func (dc *CassandraDatacenter) GetDatacenterLabels() map[string]string {
labels := dc.GetClusterLabels()
labels[DatacenterLabel] = dc.Name
labels[DatacenterUID] = string(dc.UID)
return labels
}

Expand Down
1 change: 1 addition & 0 deletions pkg/reconciliation/reconcile_datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (rc *ReconciliationContext) listPVCs() (*corev1.PersistentVolumeClaimList,

selector := map[string]string{
api.DatacenterLabel: rc.Datacenter.Name,
api.DatacenterUID: string(rc.Datacenter.UID),
}

listOptions := &client.ListOptions{
Expand Down

0 comments on commit e407779

Please sign in to comment.