Skip to content

Add preliminary job_runs resource#5603

Open
radakam wants to merge 11 commits into
mainfrom
job-runs-resource
Open

Add preliminary job_runs resource#5603
radakam wants to merge 11 commits into
mainfrom
job-runs-resource

Conversation

@radakam

@radakam radakam commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Changes

Add a job_runs bundle resource (direct engine). Deploying it triggers a job run via the Jobs RunNow API and stores the run id in state.

resources:
  job_runs:
    my_run:
      job_id: ${resources.jobs.my_job.id}

Includes the resource + direct CRUD, lifecycle config, generated schema/validation, run_as handling, acceptance tests, and updates to the resource-enumeration tests.

Because a run isn't a normal CRUD resource, a few deliberate choices:

  • Create = trigger (RunNow); the run id is the tracked identity.
  • No update: there's no API to modify a run, so all request fields are recreate_on_changes — changes re-trigger a fresh run.
  • No-op delete: a triggered run can't be "undeployed". On recreate the framework calls delete before create, so a no-op delete + RunNow re-triggers the run.
  • Ignore drift: GetRun echoes the run's job-level and overriding parameters, so those are mapped back and diffed directly; only the request-only inputs GetRun never returns (idempotency_token, only, performance_target, queue) plus the job_settings snapshot are ignore_remote_changes.
  • run_as: RunNow has no run_as, so a differing bundle run_as is rejected early.

Re-triggering on job changes (job_settings)

RunNow only carries the stable job_id, so a run has no way to notice that the targeted job's definition changed. To support that, the resource has an optional job_settings field that snapshots the job. Point it at a whole-job reference and any change to the job re-triggers the run (the snapshot is recreate_on_changes):

resources:
  job_runs:
    my_run:
      job_id: ${resources.jobs.my_job.id}
      # Snapshot the whole job so any change to it re-triggers the run.
      job_settings: ${resources.jobs.my_job}

The snapshot is a local-only input: GetRun never returns it, so it's ignore_remote_changes to avoid spurious drift.

Closes DECO-27355.

(Waiting for completion + run URL are deferred to a later milestone.)

Why

Today, triggering a job as part of bundle deploy requires custom scripts outside the bundle. This project adds a resources.job_runs section to direct engine so users can declaratively run jobs as part of deployment — e.g. schema migrations, model training, data prep.

Tests

  • Acceptance:
    • job_runs/basic — one run-now, run id stored, clean destroy.
    • job_runs/redeploy — recreate on job_parameters change.
    • job_runs/notebook_change — changing the targeted job's notebook_path re-triggers the run via the job_settings snapshot.
  • TestAll/job_runs direct CRUD.
  • Testserver RunNow/GetRun now echo job and overriding parameters so reads round-trip.
  • Updated/passing: run_as, permissions, target-mode, Terraform lifecycle, bind-support enumeration, workspace-URL completeness (job_runs added to noURL — no stable run URL yet), and StateToBundle enumeration tests.

@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 07:21 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 07:21 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 985e7ba

Run: 27698872769

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 7 14 264 1013 7:08
💚​ aws windows 7 14 266 1011 8:15
🔄​ aws-ucws linux 2 7 14 358 927 28:20
💚​ aws-ucws windows 7 14 362 925 10:22
💚​ azure linux 1 16 267 1011 6:29
💚​ azure windows 1 16 269 1009 7:30
💚​ azure-ucws linux 1 16 365 923 7:26
🔄​ azure-ucws windows 2 1 16 365 921 11:17
🔄​ gcp linux 5 16 259 1014 14:18
🔄​ gcp windows 2 1 16 263 1012 12:25
26 interesting tests: 14 SKIP, 6 flaky, 6 RECOVERED
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🔄​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 🔄​f 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/bundle/resources/apps/inline_config ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p
🔄​ TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p
🔄​ TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/replace_existing 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_projects/update_display_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestFetchRepositoryInfoAPI_FromRepo/root ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f 🔄​f 🔄​f
🔄​ TestFetchRepositoryInfoAPI_FromRepo/subdir ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f 🔄​f 🔄​f
Top 25 slowest tests (at least 2 minutes):
duration env testname
4:51 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:48 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:10 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:33 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:23 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:22 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:21 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:18 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:17 aws-ucws windows TestAccept
3:15 gcp windows TestAccept
3:13 aws windows TestAccept
3:13 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:05 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:03 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:00 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:53 azure-ucws windows TestAccept
2:45 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:45 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:39 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:38 azure windows TestAccept
2:37 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:36 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:32 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:28 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:25 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 10:55 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 10:55 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:01 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:01 — with GitHub Actions Inactive
@radakam radakam force-pushed the job-runs-resource branch from 63df005 to ff9faea Compare June 15, 2026 12:02
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:03 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:03 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:40 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:40 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:50 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 12:50 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 13:24 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 13:24 — with GitHub Actions Inactive
@radakam radakam force-pushed the job-runs-resource branch from a899c09 to 3fb23a7 Compare June 15, 2026 13:24
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 13:25 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 13:25 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 13:45 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 13:45 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 14:29 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 15, 2026 14:29 — with GitHub Actions Inactive
@radakam radakam marked this pull request as ready for review June 15, 2026 18:54
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

16 files changed
Suggested: @pietern
Also eligible: @janniklasrose, @andrewnester, @denik, @shreyas-goenka, @anton-107, @lennartkats-db

/bundle/ - needs approval

19 files changed
Suggested: @pietern
Also eligible: @janniklasrose, @andrewnester, @denik, @shreyas-goenka, @anton-107, @lennartkats-db

General files (require maintainer)

Files: libs/structs/structwalk/walktype_test.go, libs/testserver/jobs.go
Based on git history:

  • @pietern -- recent work in bundle/direct/dresources/, bundle/config/resources/, bundle/internal/validation/generated/

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

Comment thread acceptance/bundle/resources/job_runs/basic/script
Comment thread bundle/direct/dresources/job_run.go
Comment thread acceptance/bundle/resources/job_runs/basic/script
Comment thread bundle/direct/dresources/job_run.go Outdated
// remote identity lives in RunId. Drift on the embedded request fields is
// suppressed via ignore_remote_changes in resources.yml.
type JobRunRemote struct {
jobs.RunNow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to embed jobs.Run here because this is what GetRun returns

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DoRead now maps the GetRun result back into RunNow shape. It seems that embedding jobs.Run would make the diff not line up as the remote needs to share field paths with the state (which is RunNow-shaped). Do you think it makes sense?

Comment thread acceptance/bundle/resources/job_runs/redeploy/script
Comment thread acceptance/bundle/resources/job_runs/basic/databricks.yml
radakam added 4 commits June 17, 2026 14:26
Introduce the job_runs bundle resource backed by the Jobs RunNow API.
This is a preliminary skeleton: it wires up the config type, the direct
engine resource, registration, and drift handling. Generated schema,
validation output, and tests are intentionally left for follow-ups.
Run the schema generator for the new job_runs resource and add real
descriptions for the job_runs map, JobRun.lifecycle, and
JobRun.python_named_params so the required-annotations guard test passes.
Regenerate the validation rules so job_runs picks up its required field
(job_id) and the performance_target enum. Missing required fields surface
as warnings via the existing validate:required mutator.
Deploy a bundle with a job and a job_run referencing it, and assert that
exactly one RunNow request is made and the returned run id is stored in
state. Restricted to the direct engine since job_runs has no Terraform
equivalent.
radakam added 6 commits June 17, 2026 14:27
Verify that changing a job_run's configuration re-triggers the run: after
the initial deploy, a config change (job_parameters) causes a second,
distinct RunNow request on redeploy via the recreate-on-change path.
Several reflection/enumeration tests iterate or hardcode the full resource
set and were not updated when the job_runs resource was added, leaving CI
red. Add job_runs to each: the run_as allResourceTypes list, the permissions
unsupportedResources list, the target-mode mock bundle, the Terraform
lifecycle skip list (direct-only), a bind fixture + GetRun mock, and a direct
CRUD fixture that triggers a run against a newly created job. The CRUD test
also treats job_runs as a no-op delete, since a triggered run cannot be
undeployed and stays readable afterward.
Fully populate the GetRunRequest and JobRunRemote literals in job_run.go to
satisfy exhaustruct, and regenerate the schema/refschema/apitypes artifacts so
the committed job_runs generated files match their generators.
Add job_runs coverage to the two reflection-driven completeness tests:
add "job_runs" to the noURL set in TestBundleResourcePluralNamesResolveInWorkspaceURLs
(no stable workspace URL yet) and exercise Resources.JobRuns in the
StateToBundle test suite.
Add a notebook_change acceptance test that verifies editing a job's
notebook_path updates the job (jobs/reset) without re-triggering the run,
confirming the run only recreates when its own RunNow config changes.

Also extend the basic and redeploy tests with plan/summary/validate traces
to make the deploy lifecycle visible in the recorded output.
Map GetRun fields (job_id, job_parameters, overriding parameters) back into
the RunNow shape in DoRead instead of returning an empty RunNow, so the
framework can compute a real diff for the run config.

Add a job_settings snapshot to the job_run config and state: setting
job_settings to a whole-job reference (e.g. ${resources.jobs.my_job}) lets a
change to the targeted job re-trigger the run, since the snapshot is marked
recreate_on_changes. The notebook_change acceptance test now asserts a
notebook_path edit re-triggers the run via this snapshot.

Regenerate schema/validation artifacts for the new job_settings field.
@radakam radakam force-pushed the job-runs-resource branch from d6b00f5 to f7ec335 Compare June 17, 2026 14:32
@radakam radakam temporarily deployed to test-trigger-is June 17, 2026 14:33 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 17, 2026 14:33 — with GitHub Actions Inactive
Avoid partial struct literals in job_run DoRead so exhaustruct passes,
and raise the config.Root field-count upper bound now that job_runs
snapshots a full job_settings.
@radakam radakam temporarily deployed to test-trigger-is June 17, 2026 15:05 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 17, 2026 15:05 — with GitHub Actions Inactive
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