Skip to content

Add preliminary job_runs resource#5603

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

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

Conversation

@radakam

@radakam radakam commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Changes

New job_runs bundle resource.
Triggers one run of an existing job during bundle deploy — the bundle equivalent of jobs run-now. The run appears in bundle summary with a clickable URL.

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

Re-trigger only on the run's own config change.
A run is immutable, so there's no update path. It re-triggers (no-op delete + fresh RunNow) only when its own inputs change (e.g. job_parameters, job_id); editing the targeted job or out-of-band changes don't re-trigger it. Implemented via recreate_on_changes + ignore_remote_changes; DoRead records only the run's identity, and a missing run (404) is treated as not-found via apierr.IsMissing.

Why

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

Tests

  • Acceptance (DATABRICKS_BUNDLE_ENGINE=direct): basic, redeploy, job_parameters.
  • no_drift invariant extended to cover job_runs; excluded from migrate and continue_293.
  • Unit: bundle/direct/dresources/..., bundle/config/resources/..., libs/structs/structwalk/....

@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: 9129a5b

Run: 28165828523

Env 🟨​KNOWN 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🟨​ aws linux 7 1 13 243 1027 5:32
🟨​ aws windows 7 1 13 245 1025 8:52
💚​ aws-ucws linux 8 13 330 944 5:03
💚​ aws-ucws windows 8 13 332 942 5:25
💚​ azure linux 2 15 246 1025 4:37
💚​ azure windows 2 15 248 1023 5:28
💚​ azure-ucws linux 2 15 335 940 5:23
💚​ azure-ucws windows 2 15 337 938 5:22
💚​ gcp linux 2 15 245 1027 4:13
💚​ gcp windows 2 15 247 1025 4:46
21 interesting tests: 13 SKIP, 7 KNOWN, 1 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 🟨​K 🟨​K 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 🟨​K 🟨​K 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 🟨​K 🟨​K 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🟨​K 💚​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_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 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 4 slowest tests (at least 2 minutes):
duration env testname
3:27 azure-ucws windows TestAccept
3:23 azure windows TestAccept
3:21 aws-ucws windows TestAccept
3:10 gcp windows TestAccept

@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

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

/bundle/ - needs approval

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

General files (require maintainer)

5 files changed
Based on git history:

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

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 Outdated
Comment thread acceptance/bundle/resources/job_runs/basic/script
Comment thread bundle/direct/dresources/job_run.go Outdated
Comment thread bundle/direct/dresources/job_run.go
Comment thread acceptance/bundle/resources/job_runs/redeploy/script
Comment thread acceptance/bundle/resources/job_runs/basic/databricks.yml
@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
@radakam radakam temporarily deployed to test-trigger-is June 17, 2026 15:05 — with GitHub Actions Inactive
@radakam radakam force-pushed the job-runs-resource branch from 9df3417 to 8a71c9e Compare June 19, 2026 08:30
@radakam radakam temporarily deployed to test-trigger-is June 19, 2026 08:30 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 19, 2026 08:30 — with GitHub Actions Inactive
@andrewnester andrewnester requested review from denik and pietern June 19, 2026 10:34
Comment thread python/codegen/uv.lock Outdated
These pypi-proxy registry rewrites in python/uv.lock and
python/codegen/uv.lock were environment artifacts unrelated to the
job_runs resource. Restore both lockfiles to match main.
@radakam radakam temporarily deployed to test-trigger-is June 19, 2026 10:43 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 19, 2026 10:43 — with GitHub Actions Inactive
A run's URL needs both its run id and its parent job id. The run id is
restored from state like any resource, but the job id in config comes from
a ${resources.jobs.*.id} reference that is only resolved at deploy, so at
read time it is 0 and the URL would render as jobs/0/runs/<runid>.

Restore the run's resolved job_id from state at load time (same mechanism
as id and the dashboard etag), then build the URL in JobRun.InitializeURL.
@radakam radakam temporarily deployed to test-trigger-is June 19, 2026 13:13 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 19, 2026 13:13 — with GitHub Actions Inactive
Comment thread bundle/config/resources/job_run.go Outdated
Comment thread acceptance/bundle/resources/job_runs/basic/databricks.yml
A job run is immutable and fire-once, so it should re-trigger only when its
own RunNow config changes, never from edits to the targeted job or from
out-of-band remote drift. Remove the job_settings snapshot field (whose sole
purpose was to make job edits re-trigger the run), drop it from DoRead and the
resources.yml lifecycle rules, and ignore remote changes for every run input so
only a local change recreates the run.

Regenerate schema, validation, and refschema artifacts, and remove the
notebook_change acceptance test whose premise (job edit re-triggers run) no
longer applies.
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 07:38 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 07:38 — with GitHub Actions Inactive
radakam added 2 commits June 25, 2026 07:49
Add a job_run config to the invariant suite so the no_drift check (deploy ->
plan shows 0 drift -> destroy) covers job_runs, guarding that a triggered run
shows no perpetual drift on redeploy. Exclude it from the migrate (direct-only,
no terraform converter) and continue_293 (resource absent in v0.293.0)
invariants, mirroring vector_search/genie_space.
# Conflicts:
#	acceptance/bundle/invariant/continue_293/out.test.toml
#	acceptance/bundle/invariant/migrate/out.test.toml
#	acceptance/bundle/invariant/no_drift/out.test.toml
#	acceptance/bundle/invariant/test.toml
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 08:05 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 08:05 — with GitHub Actions Inactive
Return (false, nil) on a 404 from GetRun via apierr.IsMissing, matching
the newer resources, so only real lookup failures propagate as errors.
Add a NEXT_CHANGELOG.md entry for the job_runs resource.
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 08:28 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 08:28 — with GitHub Actions Inactive
Replace PLACEHOLDER annotations for the top-level job_runs resource and its
lifecycle field with real descriptions, and regenerate jsonschema.json.
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 08:49 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 08:49 — with GitHub Actions Inactive
…rigger scope

Add a `bundle plan` between the config edit and redeploy in the job_runs
redeploy acceptance test so the golden output explicitly shows the
`recreate job_runs.my_run` action, making the "config change re-triggers
the run" behavior visible at the plan level.

Reword the DoRead and resources.yml comments to frame "re-trigger only on
the run's own config change" as the current milestone scope, with
re-triggering on other signals (every deploy, file/value changes) noted as
later-milestone work.
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 11:08 — with GitHub Actions Inactive
@radakam radakam temporarily deployed to test-trigger-is June 25, 2026 11:08 — with GitHub Actions Inactive
# list below. DoRead records only the run's identity (job_id), which it
# confirms but does not re-trigger on.
ignore_remote_changes:
- field: dbt_commands

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.

question - not sure if it works; if we include literal empty string as field, will it cover all fields?

// only resolved at deploy; restoring the deployed value lets read-only
// commands build the run URL.
var jobID int64
if strings.Contains(key, ".job_runs.") && len(entry.State) > 0 {

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.

can this trigger for resources.jobs.job_runs.permissions?

I know this follows pattern from the above, but maybe we should fix that as well.

Comment thread bundle/direct/dresources/job_run.go
if err != nil {
return nil, err
}
run, err := r.client.Jobs.GetRun(ctx, jobs.GetRunRequest{

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.

If we don't use the result of GetRun, do we still need to call it? If run cannot be deleted (according to comment in DoDelete), then presence of id means it was created, we can trust it.

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.

i do see there is https://docs.databricks.com/api/workspace/jobs/deleterun

should not we try to delete it?

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.

4 participants