Skip to content

Commit

Permalink
If status.datacenterName is set, but empty, do not use it for resourc…
Browse files Browse the repository at this point in the history
…eNames (#752)
  • Loading branch information
burmanm authored Feb 14, 2025
1 parent 7b13601 commit 2f22b49
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti
* [CHANGE] [#527](https://github.com/k8ssandra/cass-operator/issues/527) Migrate the Kustomize configuration to Kustomize 5 only. Support for using Kustomize 4.x to generate config is no longer supported.
* [ENHANCEMENT] [#729](https://github.com/k8ssandra/cass-operator/issues/729) Modify NewMgmtClient to support additional transport option for the http.Client
* [ENHANCEMENT] [#737](https://github.com/k8ssandra/cass-operator/issues/737) Before issuing PVC deletion when deleting a datacenter, verify the PVCs that match the labels are not actually used by any pods.
* [BUGFIX] [#751](https://github.com/k8ssandra/cass-operator/issues/751) If datacenterName == "", do not use it as accepted value, threat it the same way as nil value
* [BUGFIX] [#744](https://github.com/k8ssandra/cass-operator/issues/744) If StatefulSet was manually modified outside CassandraDatacenter, do not start such pods as they would need to be decommissioned instantly and could have IP conflict issues when doing so.

## v1.23.0
Expand Down
2 changes: 1 addition & 1 deletion apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ func SplitRacks(nodeCount, rackCount int) []int {
}

func (dc *CassandraDatacenter) DatacenterNameStatus() bool {
return dc.Status.DatacenterName != nil
return dc.Status.DatacenterName != nil && *dc.Status.DatacenterName != ""
}

// LabelResourceName returns a sanitized version of the name returned by DatacenterName()
Expand Down
18 changes: 18 additions & 0 deletions pkg/reconciliation/construct_statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,24 @@ func TestValidSubdomainNames(t *testing.T) {
}
}

func TestEmptyDatacenterStatusName(t *testing.T) {
assert := assert.New(t)
dc := &api.CassandraDatacenter{
ObjectMeta: metav1.ObjectMeta{
Name: "dc1",
},
Spec: api.CassandraDatacenterSpec{
ClusterName: "cluster1",
},
Status: api.CassandraDatacenterStatus{
DatacenterName: ptr.To[string](""),
},
}

typedName := NewNamespacedNameForStatefulSet(dc, "r1")
assert.Equal("cluster1-dc1-r1-sts", typedName.Name)
}

func Test_newStatefulSetForCassandraDatacenter_dcNameOverride(t *testing.T) {
dc := &api.CassandraDatacenter{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 2f22b49

Please sign in to comment.