-
Notifications
You must be signed in to change notification settings - Fork 154
Adding new pipelines deploy command
#3107
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
25 commits
Select commit
Hold shift + click to select a range
365a31e
deploy feat
alyssa-db 64ef843
modified deploy function
alyssa-db 50e8b4b
modified bundle import functions
alyssa-db 2e786c6
Merge branch 'main' into pipelines-deploy
alyssa-db 18950dd
added init dependent tests
alyssa-db 59a0a1f
terminology
alyssa-db 9adabbf
remove fail-on-active-runs
alyssa-db a6dc2cc
Merge branch 'main' into pipelines-deploy
alyssa-db de0259f
tests
alyssa-db fdec351
not exposing bundle
alyssa-db e0fc71d
Merge branch 'main' into pipelines-deploy
alyssa-db 22b174d
moved to utils.go
alyssa-db 18ba170
Merge branch 'main' into pipelines-deploy
alyssa-db 0dc46a5
added comment
alyssa-db 02a2a51
Merge branch 'main' into pipelines-deploy
alyssa-db 0a9a6ba
tests
alyssa-db 0919062
unexporting
alyssa-db a70a18b
Merge branch 'main' into pipelines-deploy
alyssa-db 7db01ba
tests
alyssa-db 20da5cc
Merge branch 'main' into pipelines-deploy
alyssa-db d0626b0
Add diagnostics warning test for pipelines deploy (#3179)
alyssa-db 0e0caf5
new out.test.toml files
alyssa-db 3f88a0b
Merge branch 'main' into pipelines-deploy
alyssa-db 81ca535
Merge branch 'main' into pipelines-deploy
alyssa-db 897ba26
added pipelines check
alyssa-db 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,5 @@ | ||
| bundle: | ||
| name: test-pipeline-auto-approve | ||
|
|
||
| include: | ||
| - "./*.yml" |
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,5 @@ | ||
| Local = true | ||
| Cloud = false | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
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,36 @@ | ||
|
|
||
| >>> [PIPELINES] deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-pipeline-auto-approve/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Remove resources from configuration to test auto-approve | ||
| >>> rm resources.yml | ||
|
|
||
| === Try to redeploy without --auto-approve - should fail | ||
| >>> errcode [PIPELINES] deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-pipeline-auto-approve/default/files... | ||
|
|
||
| This action will result in the deletion or recreation of the following DLT Pipelines along with the | ||
| Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the Pipelines will | ||
| restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline | ||
| properties such as the 'catalog' or 'storage' are changed: | ||
| delete pipeline foo | ||
| Error: the deployment requires destructive actions, but current console does not support prompting. Please specify --auto-approve if you would like to skip prompts and proceed | ||
|
|
||
|
|
||
| Exit code: 1 | ||
|
|
||
| === Redeploy with --auto-approve - should succeed | ||
| >>> [PIPELINES] deploy --auto-approve | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-pipeline-auto-approve/default/files... | ||
|
|
||
| This action will result in the deletion or recreation of the following DLT Pipelines along with the | ||
| Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the Pipelines will | ||
| restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline | ||
| properties such as the 'catalog' or 'storage' are changed: | ||
| delete pipeline foo | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! |
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,4 @@ | ||
| resources: | ||
| pipelines: | ||
| foo: | ||
| name: test-pipeline |
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,10 @@ | ||
| trace $PIPELINES deploy | ||
|
|
||
| title "Remove resources from configuration to test auto-approve" | ||
| trace rm resources.yml | ||
|
|
||
| title "Try to redeploy without --auto-approve - should fail" | ||
| trace errcode $PIPELINES deploy | ||
|
|
||
| title "Redeploy with --auto-approve - should succeed" | ||
| trace $PIPELINES deploy --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 @@ | ||
| EnvMatrix.DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
10 changes: 10 additions & 0 deletions
10
acceptance/pipelines/deploy/create-pipeline/databricks.yml
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,10 @@ | ||
| bundle: | ||
| name: test-create-pipeline | ||
|
|
||
| resources: | ||
| pipelines: | ||
| foo: | ||
| name: test-pipeline | ||
| libraries: | ||
| - notebook: | ||
| path: ./nb.sql |
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 @@ | ||
| -- Databricks notebook source | ||
| select 1 |
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,5 @@ | ||
| Local = true | ||
| Cloud = false | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
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,28 @@ | ||
|
|
||
| >>> [PIPELINES] deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-create-pipeline/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] pipelines get [UUID] | ||
| { | ||
| "spec": { | ||
| "channel": "CURRENT", | ||
| "deployment": { | ||
| "kind": "BUNDLE", | ||
| "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-create-pipeline/default/state/metadata.json" | ||
| }, | ||
| "edition": "ADVANCED", | ||
| "id": "[UUID]", | ||
| "libraries": [ | ||
| { | ||
| "notebook": { | ||
| "path": "/Workspace/Users/[USERNAME]/.bundle/test-create-pipeline/default/files/nb" | ||
| } | ||
| } | ||
| ], | ||
| "name": "test-pipeline", | ||
| "storage": "dbfs:/pipelines/[UUID]" | ||
| } | ||
| } |
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,3 @@ | ||
| trace $PIPELINES deploy | ||
| PIPELINE_ID=$($CLI bundle summary -o json | jq -r '.resources.pipelines.foo.id') | ||
| trace $CLI pipelines get "${PIPELINE_ID}" | jq "{spec}" | ||
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 @@ | ||
| EnvMatrix.DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
8 changes: 8 additions & 0 deletions
8
acceptance/pipelines/deploy/render-diagnostics-warning/databricks.yml
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,8 @@ | ||
| bundle: | ||
| name: render-diagnostics-warning-pipeline | ||
|
|
||
| resources: | ||
| pipelines: | ||
| test-pipeline: | ||
| # This is an unknown property that should trigger a warning | ||
| unknown_property: "this_should_trigger_a_warning" |
5 changes: 5 additions & 0 deletions
5
acceptance/pipelines/deploy/render-diagnostics-warning/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,5 @@ | ||
| Local = true | ||
| Cloud = false | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
11 changes: 11 additions & 0 deletions
11
acceptance/pipelines/deploy/render-diagnostics-warning/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,11 @@ | ||
|
|
||
| >>> [PIPELINES] deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/render-diagnostics-warning-pipeline/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| Warning: unknown field: unknown_property | ||
| at resources.pipelines.test-pipeline | ||
| in databricks.yml:8:7 | ||
|
|
||
| <EOL> |
3 changes: 3 additions & 0 deletions
3
acceptance/pipelines/deploy/render-diagnostics-warning/script
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,3 @@ | ||
| trace $PIPELINES deploy | ||
| # print newline to comply with whitespace linter | ||
| printf "<EOL>\n" |
1 change: 1 addition & 0 deletions
1
acceptance/pipelines/deploy/render-diagnostics-warning/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 @@ | ||
| EnvMatrix.DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
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 @@ | ||
| bundle: | ||
| name: test-pipeline-var-flag | ||
|
|
||
| variables: | ||
| catalog: | ||
| default: main | ||
| schema: | ||
| default: test_schema | ||
|
|
||
| resources: | ||
| pipelines: | ||
| foo: | ||
| catalog: ${var.catalog} | ||
| target: ${var.schema} |
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,5 @@ | ||
| Local = true | ||
| Cloud = false | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
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 @@ | ||
|
|
||
| === Test --var flag usage | ||
| >>> [PIPELINES] deploy --var=catalog=custom_catalog --var=schema=custom_schema --auto-approve | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-pipeline-var-flag/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Verify: Check that variables were substituted correctly | ||
| >>> [CLI] pipelines get [UUID] | ||
| { | ||
| "catalog": "custom_catalog", | ||
| "target": "custom_schema" | ||
| } |
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,7 @@ | ||
| title "Test --var flag usage" | ||
| trace $PIPELINES deploy --var="catalog=custom_catalog" --var="schema=custom_schema" --auto-approve | ||
|
|
||
| title "Verify: Check that variables were substituted correctly" | ||
| PIPELINE_ID=$($CLI bundle summary -o json | jq -r '.resources.pipelines.foo.id') | ||
| trace $CLI pipelines get "${PIPELINE_ID}" | jq '.spec | {catalog: .catalog, target: .target}' | ||
| # Expected: catalog should be "custom_catalog" and target should contain "custom_schema" |
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 @@ | ||
| EnvMatrix.DATABRICKS_CLI_DEPLOYMENT = ["terraform"] |
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
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
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,3 @@ | ||
| # All pipelines tests are local only | ||
| Local = true | ||
| Cloud = false |
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,69 @@ | ||
| // Copied from cmd/bundle/deploy.go and adapted for pipelines use. | ||
| package pipelines | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/databricks/cli/bundle" | ||
| "github.com/databricks/cli/bundle/config/validate" | ||
| "github.com/databricks/cli/bundle/phases" | ||
| "github.com/databricks/cli/cmd/bundle/utils" | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/databricks/cli/libs/diag" | ||
| "github.com/databricks/cli/libs/sync" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func deployCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "deploy", | ||
| Short: "Deploy pipelines", | ||
| Args: root.NoArgs, | ||
| } | ||
|
|
||
| var forceLock bool | ||
| var autoApprove bool | ||
| var verbose bool | ||
| cmd.Flags().BoolVar(&forceLock, "force-lock", false, "Force acquisition of deployment lock.") | ||
| cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip interactive approvals that might be required for deployment.") | ||
| cmd.Flags().BoolVar(&verbose, "verbose", false, "Enable verbose output.") | ||
| // Verbose flag currently only affects file sync output, it's used by the vscode extension | ||
| cmd.Flags().MarkHidden("verbose") | ||
|
|
||
| cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
| ctx := cmd.Context() | ||
| b, diags := utils.ConfigureBundleWithVariables(cmd) | ||
|
|
||
| if !diags.HasError() { | ||
| bundle.ApplyFunc(ctx, b, func(context.Context, *bundle.Bundle) diag.Diagnostics { | ||
| b.Config.Bundle.Deployment.Lock.Force = forceLock | ||
| b.AutoApprove = autoApprove | ||
| return nil | ||
| }) | ||
|
|
||
| var outputHandler sync.OutputHandler | ||
| if verbose { | ||
| outputHandler = func(ctx context.Context, c <-chan sync.Event) { | ||
| sync.TextOutput(ctx, c, cmd.OutOrStdout()) | ||
| } | ||
| } | ||
|
|
||
| diags = diags.Extend(phases.Initialize(ctx, b)) | ||
|
|
||
| if !diags.HasError() { | ||
| diags = diags.Extend(bundle.Apply(ctx, b, validate.FastValidate())) | ||
| } | ||
|
|
||
| if !diags.HasError() { | ||
| diags = diags.Extend(phases.Build(ctx, b)) | ||
| } | ||
|
|
||
| if !diags.HasError() { | ||
| diags = diags.Extend(phases.Deploy(ctx, b, outputHandler)) | ||
| } | ||
| } | ||
|
|
||
| return renderDiagnostics(cmd.OutOrStdout(), b, diags) | ||
| } | ||
| return cmd | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.