Repository navigation
Fix 'bundle deployment bind' failing with immutable folders #7329
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e7fa55c
Fix 'bundle deployment bind' failing with immutable folders
andrewnester 430b597
Add PR link to immutable bind changelog fragment
andrewnester b8e9a00
Merge remote-tracking branch 'origin/main' into fix/immutable-bind
andrewnester 78341d7
Update immutable bind test output for numbered UUIDs
andrewnester a996368
Explain why the immutable bind test masks snapshot digests
andrewnester b50dfa0
Merge branch 'main' into fix/immutable-bind
andrewnester File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Fix `bundle deployment bind` (and `bundle generate --bind`) failing with `no such node "resources.internal_immutable_snapshots.immutable"` when `workspace.sync_mode` is `immutable`, as reported in [#7306](https://github.com/databricks/cli/issues/7306). ([#7329](https://github.com/databricks/cli/pull/7329)) |
26 changes: 26 additions & 0 deletions
26
acceptance/bundle/deployment/bind/job/immutable/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| sync_mode: immutable | ||
|
|
||
| resources: | ||
| jobs: | ||
| foo: | ||
| name: test-job-bind-$UNIQUE_NAME | ||
| tasks: | ||
| - task_key: my_task | ||
| environment_key: default | ||
| spark_python_task: | ||
| python_file: ./hello_world.py | ||
| environments: | ||
| - environment_key: default | ||
| spec: | ||
| environment_version: "4" | ||
| # References no bundle files. Binding it still plans the whole bundle, so the | ||
| # snapshot that the job above depends on has to resolve even here. | ||
| schemas: | ||
| schema1: | ||
| name: $SCHEMA_NAME | ||
| catalog_name: main | ||
| comment: This schema was created from DABs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| print("Hello, World!") |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/deployment/bind/job/immutable/out.test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Cloud = true | ||
| EnvMatrix.DMS = [""] |
57 changes: 57 additions & 0 deletions
57
acceptance/bundle/deployment/bind/job/immutable/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
|
|
||
| === Create a pre-defined job and schema: | ||
| Created job with ID: [JOB_ID] | ||
| { | ||
| "full_name": "main.test-schema-[UNIQUE_NAME]", | ||
| "catalog_name": "main" | ||
| } | ||
|
|
||
| === Bind the job while the state holds no snapshot yet: | ||
|
|
||
| >>> [CLI] bundle deployment bind foo [JOB_ID] --auto-approve | ||
| Successfully bound job with an id '[JOB_ID]' | ||
| Run 'bundle deploy' to deploy changes to your workspace | ||
|
|
||
| >>> [CLI] bundle plan | ||
| create internal_immutable_snapshots.immutable | ||
| update jobs.foo | ||
| create schemas.schema1 | ||
|
|
||
| Plan: 2 to add, 1 to change, 0 to delete, 0 unchanged | ||
|
|
||
| === Deploy the job, which deploys the snapshot it depends on: | ||
|
|
||
| >>> [CLI] bundle deploy --select jobs.foo | ||
| Created internal_immutable_snapshots.immutable | ||
| Updated jobs.foo | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 1 created, 1 changed, 0 deleted, 0 unchanged, 1 not selected | ||
|
|
||
| >>> [CLI] jobs get [JOB_ID] | ||
| "/Workspace/Users/[UUID][0]/.snapshots/[SNAPSHOT_HASH]/[SNAPSHOT_HASH]-[UUID][1]/snapshot/files/hello_world.py" | ||
|
|
||
| === Bind the schema now that the state holds a snapshot the config does not declare: | ||
|
|
||
| >>> [CLI] bundle deployment bind schema1 main.test-schema-[UNIQUE_NAME] --auto-approve | ||
| Successfully bound schema with an id 'main.test-schema-[UNIQUE_NAME]' | ||
| Run 'bundle deploy' to deploy changes to your workspace | ||
|
|
||
| >>> [CLI] bundle plan | ||
| update schemas.schema1 | ||
|
|
||
| Plan: 0 to add, 1 to change, 0 to delete, 2 unchanged | ||
|
|
||
| === Unbind both and destroy the bundle: | ||
|
|
||
| >>> [CLI] bundle deployment unbind foo | ||
|
|
||
| >>> [CLI] bundle deployment unbind schema1 | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default | ||
|
|
||
| Destroy: 0 deleted | ||
|
|
||
| === Delete the pre-defined job and schema (both must have survived the destroy): | ||
| 0 | ||
| 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| title "Create a pre-defined job and schema:" | ||
|
|
||
| PYTHON_FILE="/Workspace/Users/${CURRENT_USER_NAME}/initial_hello_world.py" | ||
|
|
||
| JOB_ID=$($CLI jobs create --json ' | ||
| { | ||
| "name": "test-job-bind-'${UNIQUE_NAME}'", | ||
| "tasks": [ | ||
| { | ||
| "task_key": "my_task", | ||
| "environment_key": "default", | ||
| "spark_python_task": { | ||
| "python_file": "'${PYTHON_FILE}'" | ||
| } | ||
| } | ||
| ], | ||
| "environments": [ | ||
| { | ||
| "environment_key": "default", | ||
| "spec": { | ||
| "environment_version": "4" | ||
| } | ||
| } | ||
| ] | ||
| }' | jq -r '.job_id') | ||
| add_repl "$JOB_ID" JOB_ID | ||
| echo "Created job with ID: $JOB_ID" | ||
|
|
||
| export SCHEMA_NAME="test-schema-${UNIQUE_NAME}" | ||
| $CLI schemas create ${SCHEMA_NAME} main | jq '{full_name, catalog_name}' | ||
|
|
||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| title "Delete the pre-defined job and schema (both must have survived the destroy):" | ||
| $CLI jobs delete $JOB_ID | ||
| echo $? | ||
| $CLI schemas delete main.${SCHEMA_NAME} | ||
| echo $? | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "Bind the job while the state holds no snapshot yet:" | ||
| trace $CLI bundle deployment bind foo $JOB_ID --auto-approve | ||
| trace $CLI bundle plan | ||
|
|
||
| title "Deploy the job, which deploys the snapshot it depends on:" | ||
| trace $CLI bundle deploy --select jobs.foo | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.tasks[0].spark_python_task.python_file' | ||
|
|
||
| title "Bind the schema now that the state holds a snapshot the config does not declare:" | ||
| trace $CLI bundle deployment bind schema1 main.${SCHEMA_NAME} --auto-approve | ||
| trace $CLI bundle plan | ||
|
|
||
| title "Unbind both and destroy the bundle:" | ||
| trace $CLI bundle deployment unbind foo | ||
| trace $CLI bundle deployment unbind schema1 | ||
| trace $CLI bundle destroy --auto-approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # DMS does not support the immutable snapshot resource yet (see bundle/deploy/immutable/test.toml). | ||
| EnvMatrix.DMS = [""] | ||
|
|
||
| Ignore = [ | ||
| "databricks.yml", | ||
| ".databricks", | ||
| ] | ||
|
|
||
| [[Repls]] | ||
| # Snapshot paths embed two sha256 digests that change on every run: the bundle ID hashes | ||
| # workspace.state_path and the content hash covers the rendered databricks.yml, and both | ||
| # contain $UNIQUE_NAME. | ||
| Old = "[0-9a-f]{64}" | ||
| New = "[SNAPSHOT_HASH]" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is snapshot_hash unstable? if not, we can skip the replacement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both digests change on every run, so the replacement has to stay. The first is the bundle ID,
sha256(workspace.state_path), and the state path containstest-bundle-$UNIQUE_NAME; the second is the content hash of the snapshot zip, which includes the rendereddatabricks.ymlwith$UNIQUE_NAMEand$SCHEMA_NAMEsubstituted. Two consecutive local runs with the Repl removed gave6bf0af6a…/b13825ad…and08c3431d…/207fa6a4…. This matchesbundle/deploy/immutable,dms/immutable-folderandresources/apps/immutable, which all mask the same pattern.