-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prompt when a pipeline recreation happens (#1672)
## Changes DLT pipeline recreations are destructive. They can lead to lost history of previous updates, outage of the tables temporarily and are potentially computationally expensive. Thus we make a breaking change where a prompt is shown to the user if there configuration changes will lead to a DLT recreation. Users can skip the prompt by specifying the `--auto-approve` flag. This PR also fixes an issue with our test runner where logs from the cmdio.Logger would not get propagated to the reader returned by our cobra test runner. ## Tests Manually, and new unit and integration tests. ``` ➜ bundle-playground-3 cli bundle deploy Uploading bundle files to /Users/63ec021d-b0c6-49c0-93a0-5123953a1cb2/.bundle/test/development/files... The following DLT pipelines will be recreated. Underlying tables will be unavailable for a transient period until the newly recreated pipelines are run once successfully. History of previous pipeline update runs will be lost because of recreation: recreate pipeline foo Would you like to proceed? [y/n]: n Deployment cancelled! ```
- Loading branch information
1 parent
35cdf40
commit a27c24a
Showing
6 changed files
with
258 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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,67 @@ | ||
package phases | ||
|
||
import ( | ||
"testing" | ||
|
||
terraformlib "github.com/databricks/cli/libs/terraform" | ||
tfjson "github.com/hashicorp/terraform-json" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseTerraformActions(t *testing.T) { | ||
changes := []*tfjson.ResourceChange{ | ||
{ | ||
Type: "databricks_pipeline", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionCreate}, | ||
}, | ||
Name: "create pipeline", | ||
}, | ||
{ | ||
Type: "databricks_pipeline", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionDelete}, | ||
}, | ||
Name: "delete pipeline", | ||
}, | ||
{ | ||
Type: "databricks_pipeline", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionDelete, tfjson.ActionCreate}, | ||
}, | ||
Name: "recreate pipeline", | ||
}, | ||
{ | ||
Type: "databricks_whatever", | ||
Change: &tfjson.Change{ | ||
Actions: tfjson.Actions{tfjson.ActionDelete, tfjson.ActionCreate}, | ||
}, | ||
Name: "recreate whatever", | ||
}, | ||
} | ||
|
||
res := parseTerraformActions(changes, func(typ string, actions tfjson.Actions) bool { | ||
if typ != "databricks_pipeline" { | ||
return false | ||
} | ||
|
||
if actions.Delete() || actions.Replace() { | ||
return true | ||
} | ||
|
||
return false | ||
}) | ||
|
||
assert.Equal(t, []terraformlib.Action{ | ||
{ | ||
Action: terraformlib.ActionTypeDelete, | ||
ResourceType: "databricks_pipeline", | ||
ResourceName: "delete pipeline", | ||
}, | ||
{ | ||
Action: terraformlib.ActionTypeRecreate, | ||
ResourceType: "databricks_pipeline", | ||
ResourceName: "recreate pipeline", | ||
}, | ||
}, res) | ||
} |
8 changes: 8 additions & 0 deletions
8
internal/bundle/bundles/recreate_pipeline/databricks_template_schema.json
This file contains 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 @@ | ||
{ | ||
"properties": { | ||
"unique_id": { | ||
"type": "string", | ||
"description": "Unique ID for the schema and pipeline names" | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
internal/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl
This file contains 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,25 @@ | ||
bundle: | ||
name: "bundle-playground" | ||
|
||
variables: | ||
catalog: | ||
description: The catalog the DLT pipeline should use. | ||
default: main | ||
|
||
|
||
resources: | ||
pipelines: | ||
foo: | ||
name: test-pipeline-{{.unique_id}} | ||
libraries: | ||
- notebook: | ||
path: ./nb.sql | ||
development: true | ||
catalog: ${var.catalog} | ||
|
||
include: | ||
- "*.yml" | ||
|
||
targets: | ||
development: | ||
default: true |
This file contains 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 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