-
Notifications
You must be signed in to change notification settings - Fork 177
direct: Support partial plan/deploy with --select #5413
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
Changes from all commits
d1c3445
5cb793e
76fdaca
6506b1c
699d778
34a70db
47eb09a
52e84b9
dc519fa
203ea84
124ebdd
5dc2c35
2129404
1b2e8da
36fc9d1
cb1e467
cb85374
849814c
606505a
bba4341
c2b30d5
d718aa4
b0153ab
576ba6e
820dc0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| bundle: | ||
| name: select-ambiguous | ||
|
|
||
| # "thing" is defined as both a job and a pipeline. This is what an ambiguous | ||
| # --select selector would resolve to, but UniqueResourceKeys rejects it at load | ||
| # time, so the bundle never reaches selector resolution. | ||
| resources: | ||
| jobs: | ||
| thing: | ||
| name: job-thing | ||
| pipelines: | ||
| thing: | ||
| name: pipeline-thing |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| >>> musterr [CLI] bundle plan --select thing | ||
| Error: multiple resources or scripts have been defined with the same key: thing | ||
| at resources.jobs.thing | ||
| resources.pipelines.thing | ||
| in databricks.yml:10:7 | ||
| databricks.yml:13:7 | ||
|
|
||
|
|
||
| >>> musterr [CLI] bundle deploy --select thing | ||
| Error: multiple resources or scripts have been defined with the same key: thing | ||
| at resources.jobs.thing | ||
| resources.pipelines.thing | ||
| in databricks.yml:10:7 | ||
| databricks.yml:13:7 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| trace musterr $CLI bundle plan --select thing | ||
| trace musterr $CLI bundle deploy --select thing |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| bundle: | ||
| name: select-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| jobs: | ||
| bar: | ||
| name: bar-$UNIQUE_NAME | ||
|
|
||
| foo: | ||
| name: foo-$UNIQUE_NAME | ||
| tasks: | ||
| - task_key: run_bar | ||
| run_job_task: | ||
| job_id: ${resources.jobs.bar.id} | ||
|
|
||
| baz: | ||
| name: baz-$UNIQUE_NAME |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
|
|
||
| >>> [CLI] bundle plan --select bar | ||
| create jobs.bar | ||
|
|
||
| Plan: 1 to add, 0 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle plan --select jobs.bar --select jobs.baz | ||
| create jobs.bar | ||
| create jobs.baz | ||
|
|
||
| Plan: 2 to add, 0 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle plan --select jobs.bar,jobs.baz | ||
| create jobs.bar | ||
| create jobs.baz | ||
|
|
||
| Plan: 2 to add, 0 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle plan --select jobs.foo | ||
| create jobs.bar | ||
| create jobs.foo | ||
|
|
||
| Plan: 2 to add, 0 to change, 0 to delete, 0 unchanged | ||
|
|
||
| === bundle deploy --select jobs.foo | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Telemetry: | ||
| select_used true | ||
|
|
||
| >>> print_requests.py --sort //jobs | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/create", | ||
| "body": { | ||
| "deployment": { | ||
| "kind": "BUNDLE", | ||
| "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/state/metadata.json" | ||
| }, | ||
| "edit_mode": "UI_LOCKED", | ||
| "format": "MULTI_TASK", | ||
| "max_concurrent_runs": 1, | ||
| "name": "bar-[UNIQUE_NAME]", | ||
| "queue": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/create", | ||
| "body": { | ||
| "deployment": { | ||
| "kind": "BUNDLE", | ||
| "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/state/metadata.json" | ||
| }, | ||
| "edit_mode": "UI_LOCKED", | ||
| "format": "MULTI_TASK", | ||
| "max_concurrent_runs": 1, | ||
| "name": "foo-[UNIQUE_NAME]", | ||
| "queue": { | ||
| "enabled": true | ||
| }, | ||
| "tasks": [ | ||
| { | ||
| "run_job_task": { | ||
| "job_id": [NUMID] | ||
| }, | ||
| "task_key": "run_bar" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: select-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default | ||
| Resources: | ||
| Jobs: | ||
| bar: | ||
| Name: bar-[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/jobs/[NUMID]?w=[NUMID] | ||
| baz: | ||
| Name: baz-[UNIQUE_NAME] | ||
| URL: (not deployed) | ||
| foo: | ||
| Name: foo-[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/jobs/[NUMID]?w=[NUMID] | ||
|
|
||
| === Full plan after partial deploy | ||
| >>> [CLI] bundle plan | ||
| create jobs.baz | ||
|
|
||
| Plan: 1 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| === Full deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py --sort //jobs | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/create", | ||
| "body": { | ||
| "deployment": { | ||
| "kind": "BUNDLE", | ||
| "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/state/metadata.json" | ||
| }, | ||
| "edit_mode": "UI_LOCKED", | ||
| "format": "MULTI_TASK", | ||
| "max_concurrent_runs": 1, | ||
| "name": "baz-[UNIQUE_NAME]", | ||
| "queue": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| === Full plan again | ||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 3 unchanged | ||
|
|
||
| === Destroy | ||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.jobs.bar | ||
| delete resources.jobs.baz | ||
| delete resources.jobs.foo | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| envsubst '$UNIQUE_NAME' < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| title "Destroy" | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| # --- selector resolution --- | ||
| # Unqualified name, unique across resource types. | ||
| trace $CLI bundle plan --select bar | ||
| # Repeated --select. | ||
| trace $CLI bundle plan --select jobs.bar --select jobs.baz | ||
| # Comma-separated --select (equivalent to repeating the flag). | ||
| trace $CLI bundle plan --select jobs.bar,jobs.baz | ||
| # Qualified name; foo pulls in its dependency bar but not the independent baz. | ||
| trace $CLI bundle plan --select jobs.foo | ||
|
|
||
| # --- partial deploy --- | ||
| # Serialize the filtered plan to a temp file (kept out of the recorded output: the | ||
| # JSON embeds remote state that differs between local and cloud), then deploy it: | ||
| # inline, or via --plan (READPLAN=1). The deploy is not traced because readplanarg | ||
| # varies the command line between READPLAN variants, which must produce identical output. | ||
| $CLI bundle plan --select jobs.foo -o json > plan.json | ||
| title "bundle deploy --select jobs.foo\n" | ||
| $CLI bundle deploy --select jobs.foo $(readplanarg plan.json) | ||
| # The deploy reports that --select was used via telemetry. | ||
| title "Telemetry:\n" | ||
| print_telemetry_bool_values | grep '^select_used ' | ||
| # Only bar and foo were created, never baz. | ||
| trace print_requests.py --sort //jobs | ||
| # Summary after the partial deploy: foo and bar are deployed, baz is not. | ||
| trace $CLI bundle summary | ||
|
|
||
| # --- full plan/deploy after the partial deploy --- | ||
| # foo and bar are already deployed, so only baz remains to create. | ||
| title "Full plan after partial deploy" | ||
| trace $CLI bundle plan | ||
| $CLI bundle plan -o json > plan-full.json | ||
| title "Full deploy\n" | ||
| $CLI bundle deploy $(readplanarg plan-full.json) | ||
| # Only baz is created this time. | ||
| trace print_requests.py --sort //jobs | ||
| # Everything is deployed now: no changes. | ||
| title "Full plan again" | ||
| trace $CLI bundle plan |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Local = true | ||
| Cloud = true | ||
| RecordRequests = true | ||
| # --select is only supported by the direct engine, so this happy-path test runs on | ||
| # direct only (the rejection on terraform is covered by bundle/select/rejected). | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| # Also run a variant that deploys a serialized (already filtered) plan via --plan. | ||
| EnvMatrix.READPLAN = ["", "1"] | ||
| # databricks.yml and the serialized plans are generated at runtime; the plan JSON | ||
| # is kept out of the recorded output because it embeds local/cloud-specific state. | ||
| Ignore = [".databricks", ".gitignore", "databricks.yml", "plan.json", "plan-full.json"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| bundle: | ||
| name: select-errors | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
|
|
||
| >>> [CLI] bundle plan --select no_such_resource | ||
| Error: no such resource: no_such_resource | ||
|
|
||
|
|
||
| Exit code: 1 | ||
|
|
||
| >>> [CLI] bundle plan --select jobs.no_such_job | ||
| Error: no such resource: jobs.no_such_job | ||
|
|
||
|
|
||
| Exit code: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Selectors are resolved by the ResolveSelect mutator during initialize, before the | ||
| # engine is known, so these errors are identical on both engines. | ||
|
|
||
| # Unqualified name that matches no resource. | ||
| errcode trace $CLI bundle plan --select no_such_resource | ||
|
|
||
| # Qualified name whose resource does not exist. | ||
| errcode trace $CLI bundle plan --select jobs.no_such_job |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| bundle: | ||
| name: select-rejected | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
|
|
||
| >>> [CLI] bundle plan --select my_job | ||
| Error: --select is only supported with the direct engine. See https://docs.databricks.com/aws/en/dev-tools/bundles/direct | ||
|
|
||
|
|
||
| Exit code: 1 | ||
|
|
||
| >>> [CLI] bundle deploy --select my_job | ||
| Error: --select is only supported with the direct engine. See https://docs.databricks.com/aws/en/dev-tools/bundles/direct | ||
|
|
||
|
|
||
| Exit code: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # --select is only supported by the direct engine; both plan and deploy reject it. | ||
| errcode trace $CLI bundle plan --select my_job | ||
| errcode trace $CLI bundle deploy --select my_job |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # --select is rejected on the terraform engine with an actionable error. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Local = true | ||
| Cloud = false | ||
| Ignore = [".databricks", ".gitignore"] |
Uh oh!
There was an error while loading. Please reload this page.