From e40777986c918750594c92fee1f97266237c800f Mon Sep 17 00:00:00 2001 From: srteam2020 Date: Sat, 12 Jun 2021 11:17:00 -0500 Subject: [PATCH] Fix-118: Check UID before deleting PVC --- apis/cassandra/v1beta1/cassandradatacenter_types.go | 4 ++++ pkg/reconciliation/reconcile_datacenter.go | 1 + 2 files changed, 5 insertions(+) diff --git a/apis/cassandra/v1beta1/cassandradatacenter_types.go b/apis/cassandra/v1beta1/cassandradatacenter_types.go index a1f878c2e..a3d763132 100644 --- a/apis/cassandra/v1beta1/cassandradatacenter_types.go +++ b/apis/cassandra/v1beta1/cassandradatacenter_types.go @@ -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" @@ -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 } diff --git a/pkg/reconciliation/reconcile_datacenter.go b/pkg/reconciliation/reconcile_datacenter.go index 67fd54979..b699688d0 100644 --- a/pkg/reconciliation/reconcile_datacenter.go +++ b/pkg/reconciliation/reconcile_datacenter.go @@ -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{