Skip to content

Commit

Permalink
Merge pull request #26 from k8ssandra/cluster-wide-tasks-creation
Browse files Browse the repository at this point in the history
Allow creating cluster wide tasks
  • Loading branch information
adejanovski authored Feb 15, 2024
2 parents 344ff8a + 76f770c commit 41b0d34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/tasks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func CreateClusterTask(ctx context.Context, kubeClient client.Client, command co
},
}

if len(datacenters) > 0 {
if len(datacenters) > 0 && datacenters[0] != "" {
task.Spec.Datacenters = datacenters
}

Expand Down
16 changes: 16 additions & 0 deletions pkg/tasks/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,19 @@ func TestCreateTaskLongName(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, task)
}

func TestCreateClusterWideTask(t *testing.T) {
namespace := env.CreateNamespace(t)
kubeClient := env.Client(namespace)

cluster := "test-cluster"
dcName := ""
rackName := "rack1"

task, err := tasks.CreateClusterRestartTask(context.Background(), kubeClient, namespace, cluster, dcName, rackName)

assert.NoError(t, err)
assert.NotNil(t, task)
assert.Equal(t, controlapi.CommandRestart, task.Spec.Template.Jobs[0].Command)
assert.Equal(t, 0, len(task.Spec.Datacenters))
}

0 comments on commit 41b0d34

Please sign in to comment.