Repository navigation
Record the auto-deploy attempt on the deployment version #7935
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
base: main
Are you sure you want to change the base?
Changes from all commits
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,9 @@ | ||
| bundle: | ||
| name: dms-attempt-name-$UNIQUE_NAME | ||
| experimental: | ||
| deployment_history: true | ||
|
|
||
| resources: | ||
| jobs: | ||
| foo: | ||
| name: foo |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Cloud = true | ||
| EnvMatrix.DMS = ["true"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
|
|
||
| === With DATABRICKS_AUTO_DEPLOY_ATTEMPT set, the version the deploy creates records the attempt | ||
|
|
||
| >>> DATABRICKS_AUTO_DEPLOY_ATTEMPT=webhook-triggers/[UUID][0]/attempts/[UUID][1] [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/dms-attempt-name-[UNIQUE_NAME]/default/files... | ||
| Created jobs.foo | ||
| Files: 2 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py --dms //versions ^//operations ^//complete | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/bundle/deployments/[DEPLOYMENT_ID]/versions", | ||
| "q": { | ||
| "version_id": "1" | ||
| }, | ||
| "body": { | ||
| "auto_deploy_attempt": "webhook-triggers/[UUID][0]/attempts/[UUID][1]", | ||
| "cli_version": "[CLI_VERSION]", | ||
| "operations": [ | ||
| { | ||
| "action_type": "OPERATION_ACTION_TYPE_CREATE", | ||
| "resource_key": "jobs.foo" | ||
| } | ||
| ], | ||
| "version_type": "VERSION_TYPE_DEPLOY" | ||
| } | ||
| } | ||
|
|
||
| === Without it, the request has no attempt | ||
|
|
||
| >>> update_file.py databricks.yml name: foo name: renamed | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/dms-attempt-name-[UNIQUE_NAME]/default/files... | ||
| Updated jobs.foo | ||
| Files: 1 uploaded, 0 deleted | ||
| Resources: 0 created, 1 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py --dms //versions ^//operations ^//complete | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/bundle/deployments/[DEPLOYMENT_ID]/versions", | ||
| "q": { | ||
| "version_id": "2" | ||
| }, | ||
| "body": { | ||
| "cli_version": "[CLI_VERSION]", | ||
| "operations": [ | ||
| { | ||
| "action_type": "OPERATION_ACTION_TYPE_UPDATE", | ||
| "resource_key": "jobs.foo" | ||
| } | ||
| ], | ||
| "previous_version_id": "1", | ||
| "version_type": "VERSION_TYPE_DEPLOY" | ||
| } | ||
| } | ||
|
|
||
| === A destroy doesn't record the attempt, even with the variable set | ||
|
|
||
| >>> DATABRICKS_AUTO_DEPLOY_ATTEMPT=webhook-triggers/[UUID][0]/attempts/[UUID][1] [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.jobs.foo | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/dms-attempt-name-[UNIQUE_NAME]/default | ||
|
|
||
| Destroy: 1 deleted | ||
|
|
||
| >>> print_requests.py --dms //versions ^//operations ^//complete | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/bundle/deployments/[DEPLOYMENT_ID]/versions", | ||
| "q": { | ||
| "version_id": "3" | ||
| }, | ||
| "body": { | ||
| "cli_version": "[CLI_VERSION]", | ||
| "operations": [ | ||
| { | ||
| "action_type": "OPERATION_ACTION_TYPE_DELETE", | ||
| "resource_key": "jobs.foo" | ||
| } | ||
| ], | ||
| "previous_version_id": "2", | ||
| "version_type": "VERSION_TYPE_DESTROY" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
| attempt=webhook-triggers/11111111-1111-1111-1111-111111111111/attempts/22222222-2222-2222-2222-222222222222 | ||
| trap "errcode trace '$CLI' bundle destroy --auto-approve" EXIT | ||
|
|
||
| title "With DATABRICKS_AUTO_DEPLOY_ATTEMPT set, the version the deploy creates records the attempt" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nice to have] Nothing destroys the bundle at the end, so on the inherited cloud run the job (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 3e4f7f0. The last step destroys the bundle itself, to check that a destroy carries no attempt, so the script clears the trap after it. |
||
| trace DATABRICKS_AUTO_DEPLOY_ATTEMPT=$attempt $CLI bundle deploy | ||
| add_repl "$($CLI bundle summary -o json | jq -r .bundle.deployment.deployment_id)" DEPLOYMENT_ID | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit]
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no helper for the deployment ID, and |
||
| trace print_requests.py --dms //versions ^//operations ^//complete | ||
|
|
||
| title "Without it, the request has no attempt" | ||
| trace update_file.py databricks.yml 'name: foo' 'name: renamed' | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py --dms //versions ^//operations ^//complete | ||
|
|
||
| title "A destroy doesn't record the attempt, even with the variable set" | ||
| trace DATABRICKS_AUTO_DEPLOY_ATTEMPT=$attempt $CLI bundle destroy --auto-approve | ||
| trace print_requests.py --dms //versions ^//operations ^//complete | ||
| # Destroyed above, so the cleanup trap has nothing left to do. | ||
| trap - EXIT | ||
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.
[nice to have] This test inherits
Cloud = truefromacceptance/bundle/dms/test.toml(seeout.test.toml), so it also runs against a real workspace with a made-upwebhook-triggers/1111…/attempts/2222…name. The description says the service validates the value. If it checks that the attempt exists, the first deploy fails with "failed to create deployment version" in the cloud run. Should this directory setCloud = falseuntil there's a real attempt to point at, or was it checked against a workspace?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.
The service checks only the attempt name's format, not that the attempt exists, and this name is well formed (lowercase canonical UUIDs). It hasn't run against a workspace yet, because no workspace accepts the field until it ships. That's also when this PR can merge, so I'm keeping the cloud run: it confirms the field is live.