Skip to content

[Fix] Make spark_version field optional to work with defaults in policies #4643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 24, 2025

Conversation

pietern
Copy link
Contributor

@pietern pietern commented Apr 14, 2025

Changes

A cluster policy can enforce a specific spark_version field and set it as the default. This mechanism allows for a centralized choice of the Databricks Runtime version across all jobs. To allow a job to inherit this field from a policy, it must be configured as optional in the schema.

The job resource referred to JobSettings and JobSettingsResource with a mix of js and jsr variable names. This PR updates references to JobSettingsResource to be called jsr.

Tests

  • make test run locally
  • relevant change in docs/ folder

@pietern pietern requested review from a team as code owners April 14, 2025 13:09
@pietern pietern requested review from mgyucht and removed request for a team April 14, 2025 13:09
@pietern pietern temporarily deployed to test-trigger-is April 14, 2025 13:09 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 14, 2025 13:09 — with GitHub Actions Inactive
@pietern
Copy link
Contributor Author

pietern commented Apr 14, 2025

This fails with:

Error: cannot create job: panic: job_cluster: new_cluster: inconsistency: spark_version is optional, default is empty, but has no omitempty

I suspect the field needs to be marked as optional in the OpenAPI spec for clusters to make this work.

@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:01 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:02 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:26 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:27 — with GitHub Actions Inactive
@pietern pietern changed the title [WIP] Make spark_version field optional to work with defaults in policies [Fix] Make spark_version field optional to work with defaults in policies Apr 17, 2025
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:34 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:35 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:37 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:39 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:53 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is April 17, 2025 14:54 — with GitHub Actions Inactive
@@ -399,7 +399,7 @@ type Cluster struct {
ClusterID string `json:"cluster_id,omitempty"`
ClusterName string `json:"cluster_name,omitempty"`

SparkVersion string `json:"spark_version"`
SparkVersion string `json:"spark_version,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change, the jobs unit tests failed with:

panic: new_cluster: inconsistency: spark_version is optional, default is empty, but has no omitempty

Reflection on the 2.0 structs flagged the incompatibility between an optional field in the schema without a default and a mandatory struct field. This struct is no longer used directly by a resource.

@pietern pietern temporarily deployed to test-trigger-is April 23, 2025 08:58 — with GitHub Actions Inactive
Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for doing this Pieter!

@tanmay-db tanmay-db temporarily deployed to test-trigger-is April 24, 2025 09:12 — with GitHub Actions Inactive
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 4643
  • Commit SHA: 85ed0dc56e88798d71c0a8371886c4e9427e8715

Checks will be approved automatically on success.

@tanmay-db tanmay-db temporarily deployed to test-trigger-is April 24, 2025 09:12 — with GitHub Actions Inactive
@tanmay-db tanmay-db added this pull request to the merge queue Apr 24, 2025
Merged via the queue into main with commit 0a932c2 Apr 24, 2025
12 checks passed
@tanmay-db tanmay-db deleted the feature/optional-job-cluster-spark-version branch April 24, 2025 12:09
deco-sdk-tagging bot added a commit that referenced this pull request Apr 24, 2025
## Release v1.75.0

### New Features and Improvements

 * Add support for `power_bi_task` in jobs ([#4647](#4647))
 * Add support for `dashboard_task` in jobs ([#4646](#4646))
 * Add `compute_mode` to `databricks_mws_workspaces` to support creating serverless workspaces ([#4670](#4670)).
 * Make `spark_version` optional in the context of jobs such that a cluster policy can provide a default value ([#4643](#4643))
 

### Documentation

 * Document `performance_target` in `databricks_job` ([#4651](#4651))
 * Add more examples for `databricks_model_serving` ([#4658](#4658))
 * Document `on_streaming_backlog_exceeded` in email/webhook notifications in `databricks_job` ([#4660](#4660))
 * Refresh `spark_python_task` option in `databricks_job` ([#4666](#4666))

### Exporter

 * Emit files installed with `%pip install` in Python notebooks ([#4664](#4664))
 * Correctly handle account-level identities when generating the code ([#4650](#4650))
 * Add export of dashboard tasks in `datarbicks_job` ([#4665](#4665))
 * Add export of PowerBI tasks in `datarbicks_job` ([#4668](#4668))
 * Add `Ignore` implementation for `databricks_grants` to fix issue with wrongly generated dependencies ([#4650](#4650))
 * Improve handling of `owner` for UC resources ([#4669](#4669))
github-merge-queue bot pushed a commit to databricks/cli that referenced this pull request Apr 25, 2025
## Changes
Upgrade TF provider to 1.75.0

Includes
databricks/terraform-provider-databricks#4643
which fixes #2755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants