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 committed Jun 12, 2021
1 parent ece4469 commit 99f5969
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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 @@ -102,7 +105,7 @@ type CassandraDatacenterSpec struct {
// },
// "jmv-options": {
// "max_heap_size": 1024M
// }
// }
// }
//
// ConfigSecret is mutually exclusive with Config. ConfigSecret takes precedence and
Expand Down Expand Up @@ -514,6 +517,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 operator/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 99f5969

Please sign in to comment.