databricks-cli/bundle/config/validate
shreyas-goenka b323703c1b
Add validation for single node clusters (#1909)
## Changes
This PR adds a warning validating that the configuration for a single
node cluster is valid for interactive, job, job-task, and pipeline
clusters.

Note: We skip the validation if a cluster policy is configured because
the policy is likely to configure `spark_conf` / `custom_tags` itself.

Note: Terrform originally only had validation for interactive, job, and
job-task clusters. This PR adding the validation for pipeline clusters
as well is new.

This PR follows the same logic as we used to have in Terraform. The
validation was removed from Terraform because we had no way to demote
the error to a warning:
https://github.com/databricks/terraform-provider-databricks/pull/4222

### Background
Single-node clusters require `spark_conf` and `custom_tags` to be
correctly set in the cluster definition for them to function optimally.
The cluster will be created even if incorrectly configured, but its
performance will not be great.

For example, if both `spark_conf` and `custom_tags` are not set and
`num_workers` is 0, then only the driver process will be launched on the
cluster compute instance thus leading to sub-optimal utilization of
available compute resources and no parallelization across worker
processes when processing a spark query.

### Issue

This PR addresses some issues reported in
https://github.com/databricks/cli/issues/1546

## Tests
Unit tests and manually.

Example output of the warning:
```
➜  bundle-playground git:(master) ✗ cli bundle validate
Warning: Single node cluster is not correctly configured
  at resources.pipelines.bar.clusters[0]
  in databricks.yml:29:11

num_workers should be 0 only for single-node clusters. To create a
valid single node cluster please ensure that the following properties
are correctly set in the cluster specification:

  spark_conf:
    spark.databricks.cluster.profile: singleNode
    spark.master: local[*]

  custom_tags:
    ResourceClass: SingleNode
  

Name: foobar
Target: default
Workspace:
  User: shreyas.goenka@databricks.com
  Path: /Workspace/Users/shreyas.goenka@databricks.com/.bundle/foobar/default

Found 1 warning
```
2024-11-22 15:48:09 +00:00
..
all_resources_have_values.go Report all empty resources present in error diagnostic (#1685) 2024-08-20 00:22:00 +00:00
files_to_sync.go Skip sync warning if no sync paths are defined (#1926) 2024-11-21 15:03:13 +00:00
files_to_sync_test.go Skip sync warning if no sync paths are defined (#1926) 2024-11-21 15:03:13 +00:00
folder_permissions.go Fixed adding /Workspace prefix for resource paths (#1866) 2024-10-30 17:34:11 +00:00
folder_permissions_test.go Added validator for folder permissions (#1824) 2024-10-24 12:36:17 +00:00
job_cluster_key_defined.go Support multiple paths for diagnostics (#1616) 2024-07-25 15:16:27 +00:00
job_cluster_key_defined_test.go Added validate mutator to surface additional bundle warnings (#1352) 2024-04-18 15:13:16 +00:00
job_task_cluster_spec.go Add JobTaskClusterSpec validate mutator (#1784) 2024-09-25 11:30:14 +00:00
job_task_cluster_spec_test.go Add JobTaskClusterSpec validate mutator (#1784) 2024-09-25 11:30:14 +00:00
single_node_cluster.go Add validation for single node clusters (#1909) 2024-11-22 15:48:09 +00:00
single_node_cluster_test.go Add validation for single node clusters (#1909) 2024-11-22 15:48:09 +00:00
unique_resource_keys.go Pass copy of `dyn.Path` to callback function (#1747) 2024-09-05 11:05:16 +00:00
validate.go Add validation for single node clusters (#1909) 2024-11-22 15:48:09 +00:00
validate_sync_patterns.go Make fileset take optional list of paths to list (#1684) 2024-08-19 15:15:14 +00:00