Skip to content

Add defaults on jobs that terraform applies #2767

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 2 commits into from
Apr 29, 2025
Merged

Add defaults on jobs that terraform applies #2767

merged 2 commits into from
Apr 29, 2025

Conversation

denik
Copy link
Contributor

@denik denik commented Apr 24, 2025

Changes

Initialize jobs resources with the defaults that terraform applies (except for num_workers).

Why

This makes those defaults visible for users (bundle validate -o json) and PyDABs.

This makes terraform-removal branch simpler as there is no hidden modification of resources that terraform does on deploy.

num_workers is skipped because it has a conflict with SingleNodeCluster validator. We should find a better place for that (and other validators), somewhere before applying defaults.

@denik denik temporarily deployed to test-trigger-is April 24, 2025 13:24 — with GitHub Actions Inactive
@kanterov
Copy link
Collaborator

Are you sure it's applied by Terraform? I think it's server-side default, and the reason why you can see it in Terraform is that it re-fetches resources after creation.

@denik
Copy link
Contributor Author

denik commented Apr 25, 2025

Are you sure it's applied by Terraform? I think it's server-side default, and the reason why you can see it in Terraform is that it re-fetches resources after creation.

Pretty sure, here's a test that records /jobs/create request (which is a first request) made by terraform:

https://github.com/databricks/cli/blob/main/acceptance/bundle/resources/jobs/output.txt#L21

@denik denik force-pushed the denik/jobs-defaults branch from 52baa27 to aae0d3c Compare April 25, 2025 11:52
denik added a commit that referenced this pull request Apr 25, 2025
## Why
Presets should have more priority and need to see the configuration
before common defaults are applied, because this mutator is making
decisions based on presence of user-provided fields in the
configuration.

This does not matter currently where we only have few defaults, but will
start to matter once we add more, like in
#2767

Previous PR #2777 makes it
possible to move this without issues.

## Tests
Existing tests for empty resource added in
#2771 and
#2774
@denik denik force-pushed the denik/jobs-defaults branch from aae0d3c to 028cbe0 Compare April 25, 2025 12:05
@denik denik temporarily deployed to test-trigger-is April 25, 2025 12:06 — with GitHub Actions Inactive
@denik denik force-pushed the denik/jobs-defaults branch from 028cbe0 to 0be67e6 Compare April 25, 2025 12:11
@denik denik temporarily deployed to test-trigger-is April 25, 2025 12:11 — with GitHub Actions Inactive
@denik denik marked this pull request as ready for review April 25, 2025 12:19
@denik denik temporarily deployed to test-trigger-is April 25, 2025 14:21 — with GitHub Actions Inactive
@denik denik force-pushed the denik/jobs-defaults branch from c31cb35 to 2e2e587 Compare April 25, 2025 14:51
@denik denik temporarily deployed to test-trigger-is April 25, 2025 14:51 — with GitHub Actions Inactive
],
"trigger": {
- "pause_status": "PAUSED",
+ "pause_status": "UNPAUSED",
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this is the diff between dev and prod, indicating that the default was not sent for prod.

Can you confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed a diff between dev and prod output for "validate -o json" and the pause_status=UNPAUSED is now sent for prod but it was not before:


// https://github.com/databricks/terraform-provider-databricks/blob/v1.75.0/clusters/resource_cluster.go
// This triggers SingleNodeCluster() cluster validator. It needs to be run before applying defaults.
//{"resources.jobs.*.job_clusters[*].new_cluster.num_workers", 0},
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious to know why this is a TF default to begin with. Can you check in with the TF team to figure this out?

@denik denik temporarily deployed to test-trigger-is April 29, 2025 07:58 — with GitHub Actions Inactive
@denik denik force-pushed the denik/jobs-defaults branch from a91e746 to 527f6d2 Compare April 29, 2025 09:36
@denik denik temporarily deployed to test-trigger-is April 29, 2025 09:36 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 29, 2025 10:31 — with GitHub Actions Inactive
@denik denik enabled auto-merge April 29, 2025 10:50
@denik denik added this pull request to the merge queue Apr 29, 2025
Merged via the queue into main with commit b5f9b1e Apr 29, 2025
10 checks passed
@denik denik deleted the denik/jobs-defaults branch April 29, 2025 11:05
github-merge-queue bot pushed a commit that referenced this pull request Apr 29, 2025
## Changes
Set defaults for pipelines: edition and channel, same as added by
terraform.

## Why
See #2767

## Tests
Existing tests.
github-merge-queue bot pushed a commit that referenced this pull request May 1, 2025
## Changes
- Set default num_workers=0 on jobs
- Move SingleNodeCluster() validator to run before applying defaults,
otherwise it complains about num_workers being 0 even though users did
not set it.
 
## Why
See #2767 for justification.
Needed for #2791

## Tests
Existing tests.
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