diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 86e288dfd9..8eac3866e1 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -10,6 +10,7 @@ To disable this, set the environment variable DATABRICKS_CACHE_ENABLED to false. ### Bundles * Enable caching user identity by default ([#4202](https://github.com/databricks/cli/pull/4202)) +* Do not show single node warning when is_single_node option is explicitly set ([#4272](https://github.com/databricks/cli/pull/4272)) * Fix false positive folder permission warnings and make them more actionable ([#4216](https://github.com/databricks/cli/pull/4216)) * Pass additional Azure DevOps system variables ([#4236](https://github.com/databricks/cli/pull/4236)) * Replace Black formatter with Ruff in Python bundle templates for faster, all-in-one linting and formatting ([#4196](https://github.com/databricks/cli/pull/4196)) diff --git a/bundle/config/validate/single_node_cluster.go b/bundle/config/validate/single_node_cluster.go index acc5f444d0..f4f6f0e595 100644 --- a/bundle/config/validate/single_node_cluster.go +++ b/bundle/config/validate/single_node_cluster.go @@ -44,6 +44,13 @@ func showSingleNodeClusterWarning(ctx context.Context, v dyn.Value) bool { return false } + // If is_single_node is set to true, the cluster is correctly configured automatically. + // No need to show the warning. + isSingleNode, ok := v.Get("is_single_node").AsBool() + if ok && isSingleNode { + return false + } + // Convenient type that contains the common fields from compute.ClusterSpec and // pipelines.PipelineCluster that we are interested in. type ClusterConf struct { diff --git a/bundle/config/validate/single_node_cluster_test.go b/bundle/config/validate/single_node_cluster_test.go index 6136a9ecfd..02f27efcb6 100644 --- a/bundle/config/validate/single_node_cluster_test.go +++ b/bundle/config/validate/single_node_cluster_test.go @@ -563,3 +563,41 @@ func TestValidateSingleNodeClusterPassJobForEachTaskCluster(t *testing.T) { }) } } + +func TestValidateSingleNodeClusterWithIsSingleNode(t *testing.T) { + ctx := context.Background() + + // Test that when is_single_node is set to true, no warning is shown + // even if the manual single-node configuration is not present. + b := &bundle.Bundle{ + Config: config.Root{ + Resources: config.Resources{ + Jobs: map[string]*resources.Job{ + "foo": { + JobSettings: jobs.JobSettings{ + JobClusters: []jobs.JobCluster{ + { + NewCluster: compute.ClusterSpec{ + ClusterName: "my_cluster", + }, + }, + }, + }, + }, + }, + }, + }, + } + + // Set num_workers to 0 and is_single_node to true + bundletest.Mutate(t, b, func(v dyn.Value) (dyn.Value, error) { + v, err := dyn.Set(v, "resources.jobs.foo.job_clusters[0].new_cluster.num_workers", dyn.V(0)) + if err != nil { + return v, err + } + return dyn.Set(v, "resources.jobs.foo.job_clusters[0].new_cluster.is_single_node", dyn.V(true)) + }) + + diags := bundle.Apply(ctx, b, SingleNodeCluster()) + assert.Empty(t, diags) +}