Skip to content

Commit

Permalink
adjust webhook test
Browse files Browse the repository at this point in the history
Signed-off-by: Karol Szwaj <[email protected]>
  • Loading branch information
cnvergence committed Nov 27, 2023
1 parent 64bf78a commit 55e2646
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
4 changes: 2 additions & 2 deletions apis/k8ssandra/v1alpha1/k8ssandracluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func (r *K8ssandraCluster) ValidateUpdate(old runtime.Object) error {
newCassConfig := r.Spec.Cassandra.DatacenterOptions.CassandraConfig
if oldCassConfig != nil && newCassConfig != nil {
oldNumTokens, oldNumTokensExists := oldCassConfig.CassandraYaml["num_tokens"]
newNumTokens := newCassConfig.CassandraYaml["num_tokens"]
newNumTokens, newNumTokensExists := newCassConfig.CassandraYaml["num_tokens"]

if !oldNumTokensExists {
cassVersion, err := semver.NewVersion(oldCluster.Spec.Cassandra.ServerVersion)
if err != nil {
return err
}
defaultNumTokens := oldCluster.DefaultNumTokens(cassVersion)
if int64(newNumTokens.(float64)) != defaultNumTokens {
if newNumTokensExists && int64(newNumTokens.(float64)) != defaultNumTokens {
return ErrNumTokens
}
} else {
Expand Down
11 changes: 0 additions & 11 deletions apis/k8ssandra/v1alpha1/k8ssandracluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,6 @@ func testNumTokensInUpdate(t *testing.T) {
// This should be acceptable change, since 3.11.10 defaulted to 256 and so it is the same value
err = k8sClient.Update(ctx, cluster)
require.NoError(err)

// However, not setting the num_tokens, when the defaults have changed should be rejected - otherwise the cluster will reject the update
cluster2 := createMinimalClusterObj("numtokens-test-update-2", "numtokensupdate-namespace")
cluster2.Spec.Cassandra.ServerVersion = "3.11.10"
cluster2.Spec.Cassandra.DatacenterOptions.CassandraConfig = &CassandraConfig{}
err = k8sClient.Create(ctx, cluster2)
require.NoError(err)

cluster2.Spec.Cassandra.ServerVersion = "4.1.3"
err = k8sClient.Update(ctx, cluster2)
require.Error(err)
}

func testReaperKeyspaceValidation(t *testing.T) {
Expand Down

0 comments on commit 55e2646

Please sign in to comment.