Skip to content

Commit

Permalink
Set the ServiceName for new StatefulSets (#305)
Browse files Browse the repository at this point in the history
* make sure the ServiceName is set

* update changelog
  • Loading branch information
jsanda committed Mar 24, 2022
1 parent d619b53 commit 9e14134
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti
* [BUGFIX]
```

## unreleased

* [BUGFIX] [#304](https://github.com/k8ssandra/cass-operator/issues/304) Hostname lookups on Cassandra pods fail

## v1.10.1

* [BUGFIX] [#278](https://github.com/k8ssandra/cass-operator/issues/278) ImageRegistry json key was incorrect in the definition type. Fixed from "imageRegistryOverride" to "imageRegistry"
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciliation/construct_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func newStatefulSetForCassandraDatacenter(
}
result.Annotations = map[string]string{}

if sts != nil && sts.Spec.ServiceName != result.Spec.ServiceName {
if sts != nil && sts.Spec.ServiceName != "" && sts.Spec.ServiceName != result.Spec.ServiceName {
result.Spec.ServiceName = sts.Spec.ServiceName
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/reconciliation/construct_statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package reconciliation
import (
"fmt"
"github.com/k8ssandra/cass-operator/pkg/oplabels"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"reflect"
"testing"
Expand Down Expand Up @@ -152,6 +154,25 @@ func Test_newStatefulSetForCassandraDatacenter_rackNodeAffinitylabels(t *testing
assert.Equal(t, expected, nodeAffinityLabels)
}

func Test_newStatefulSetForCassandraDatacenter_ServiceName(t *testing.T) {
dc := &api.CassandraDatacenter{
Spec: api.CassandraDatacenterSpec{
ClusterName: "test",
ServerType: "cassandra",
ServerVersion: "4.0.3",
Size: 1,
StorageConfig: api.StorageConfig{
CassandraDataVolumeClaimSpec: &corev1.PersistentVolumeClaimSpec{},
},
},
}

sts, err := newStatefulSetForCassandraDatacenter(&appsv1.StatefulSet{}, "default", dc, 1, false)

require.NoError(t, err)
assert.Equal(t, dc.GetAllPodsServiceName(), sts.Spec.ServiceName)
}

func Test_newStatefulSetForCassandraDatacenterWithAdditionalVolumes(t *testing.T) {
type args struct {
rackName string
Expand Down

0 comments on commit 9e14134

Please sign in to comment.