diff --git a/clusters/clusters_api.go b/clusters/clusters_api.go index d47cfb6090..6a08a4a608 100644 --- a/clusters/clusters_api.go +++ b/clusters/clusters_api.go @@ -447,7 +447,7 @@ func (cluster Cluster) Validate() error { if profile == "singleNode" && strings.HasPrefix(master, "local") && resourceClass == "SingleNode" { return nil } - return fmt.Errorf("NumWorkers could be 0 only for SingleNode clusters. See https://docs.databricks.com/clusters/single-node.html for more details") + return errors.New(numWorkerErr) } // TODO: Remove this once all the resources using clusters are migrated to Go SDK. diff --git a/clusters/resource_cluster.go b/clusters/resource_cluster.go index fb77a5f76d..3c03502023 100644 --- a/clusters/resource_cluster.go +++ b/clusters/resource_cluster.go @@ -26,7 +26,26 @@ var clusterSchema = resourceClusterSchema() var clusterSchemaVersion = 4 const ( - numWorkerErr = "NumWorkers could be 0 only for SingleNode clusters. See https://docs.databricks.com/clusters/single-node.html for more details" + numWorkerErr = `num_workers may be 0 only for single-node clusters. To create a single node +cluster please include the following configuration in your cluster configuration: + + spark_conf = { + "spark.databricks.cluster.profile" : "singleNode" + "spark.master" : "local[*]" + } + + custom_tags = { + "ResourceClass" = "SingleNode" + } + +Please note that the Databricks Terraform provider cannot detect if the above configuration +is defined in a policy used by the cluster. Please define this in the cluster configuration +itself to create a single node cluster. + +For more details please see: + 1. https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/cluster#fixed-size-or-autoscaling-cluster + 2. https://docs.databricks.com/clusters/single-node.html` + unsupportedExceptCreateEditClusterSpecErr = "unsupported type %T, must be one of %scompute.CreateCluster, %scompute.ClusterSpec or %scompute.EditCluster. Please report this issue to the GitHub repo" ) diff --git a/clusters/resource_cluster_test.go b/clusters/resource_cluster_test.go index 804067597b..240b62cb4e 100644 --- a/clusters/resource_cluster_test.go +++ b/clusters/resource_cluster_test.go @@ -1860,8 +1860,7 @@ func TestResourceClusterCreate_SingleNodeFail(t *testing.T) { "is_pinned": false, }, }.Apply(t) - assert.Error(t, err) - require.Equal(t, true, strings.Contains(err.Error(), "NumWorkers could be 0 only for SingleNode clusters")) + assert.EqualError(t, err, numWorkerErr) } func TestResourceClusterCreate_NegativeNumWorkers(t *testing.T) { @@ -1900,8 +1899,7 @@ func TestResourceClusterUpdate_FailNumWorkersZero(t *testing.T) { "num_workers": 0, }, }.Apply(t) - assert.Error(t, err) - require.Equal(t, true, strings.Contains(err.Error(), "NumWorkers could be 0 only for SingleNode clusters")) + assert.EqualError(t, err, numWorkerErr) } func TestModifyClusterRequestAws(t *testing.T) { diff --git a/jobs/resource_job_test.go b/jobs/resource_job_test.go index 95ffb03923..75a780c00a 100644 --- a/jobs/resource_job_test.go +++ b/jobs/resource_job_test.go @@ -2056,8 +2056,21 @@ func TestResourceJobCreateSingleNode_Fail(t *testing.T) { jar = "dbfs://ff/gg/hh.jar" }`, }.Apply(t) - assert.Error(t, err) - require.Equal(t, true, strings.Contains(err.Error(), "NumWorkers could be 0 only for SingleNode clusters")) + assert.ErrorContains(t, err, `num_workers may be 0 only for single-node clusters. To create a single node +cluster please include the following configuration in your cluster configuration: + + spark_conf = { + "spark.databricks.cluster.profile" : "singleNode" + "spark.master" : "local[*]" + } + + custom_tags = { + "ResourceClass" = "SingleNode" + } + +Please note that the Databricks Terraform provider cannot detect if the above configuration +is defined in a policy used by the cluster. Please define this in the cluster configuration +itself to create a single node cluster.`) } func TestResourceJobRead(t *testing.T) { @@ -2946,8 +2959,21 @@ func TestResourceJobUpdate_FailNumWorkersZero(t *testing.T) { parameters = ["--cleanup", "full"] }`, }.Apply(t) - assert.Error(t, err) - require.Equal(t, true, strings.Contains(err.Error(), "NumWorkers could be 0 only for SingleNode clusters")) + assert.ErrorContains(t, err, `num_workers may be 0 only for single-node clusters. To create a single node +cluster please include the following configuration in your cluster configuration: + + spark_conf = { + "spark.databricks.cluster.profile" : "singleNode" + "spark.master" : "local[*]" + } + + custom_tags = { + "ResourceClass" = "SingleNode" + } + +Please note that the Databricks Terraform provider cannot detect if the above configuration +is defined in a policy used by the cluster. Please define this in the cluster configuration +itself to create a single node cluster.`) } func TestJobsAPIList(t *testing.T) {