diff --git a/acceptance/bundle/migrate/auto/run-no-commit/databricks.yml b/acceptance/bundle/migrate/auto/run-no-commit/databricks.yml index 40404a02b8d..9227b4b8b99 100644 --- a/acceptance/bundle/migrate/auto/run-no-commit/databricks.yml +++ b/acceptance/bundle/migrate/auto/run-no-commit/databricks.yml @@ -1,5 +1,4 @@ -bundle: - name: test-bundle +bundle: {name: test-bundle} resources: jobs: diff --git a/acceptance/bundle/migrate/auto/run-no-commit/output.txt b/acceptance/bundle/migrate/auto/run-no-commit/output.txt index 950329c8541..449bbd59f9a 100644 --- a/acceptance/bundle/migrate/auto/run-no-commit/output.txt +++ b/acceptance/bundle/migrate/auto/run-no-commit/output.txt @@ -5,7 +5,7 @@ === bundle run on direct migrates the terraform state IN MEMORY (no commit) to resolve the job >>> DATABRICKS_BUNDLE_ENGINE=direct errcode [CLI] bundle run test_job --no-wait Notice: migrating your bundle to direct deployment engine (https://github.com/databricks/cli/issues/6765). -Run URL: [DATABRICKS_URL]/jobs/[NUMID]/runs/[NUMID]?o=[NUMID] +Run URL: [DATABRICKS_URL]/jobs/[TEST_JOB_ID]/runs/[NUMID]?o=[NUMID] >>> print_migration_telemetry @@ -18,3 +18,34 @@ Run URL: [DATABRICKS_URL]/jobs/[NUMID]/runs/[NUMID]?o=[NUMID] >>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state ID Type Language Path [NUMID] FILE /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/terraform.tfstate + +=== bundle run works with engine: terraform: warns and runs the job from the terraform state +>>> update_file.py databricks.yml {name: test-bundle} {name: test-bundle, engine: terraform} + +>>> [CLI] bundle run test_job --no-wait +Warning: the Terraform deployment engine has been removed in Databricks CLI v1.20.0 + in databricks.yml:1:37 + +Remove the "bundle.engine" setting (or set it to "direct") to deploy with the direct engine; existing Terraform state is migrated automatically. To keep using Terraform, revert to Databricks CLI v1.19.x. +See https://docs.databricks.com/dev-tools/bundles/direct for details + +Notice: migrating your bundle to direct deployment engine (https://github.com/databricks/cli/issues/6765). +Run URL: [DATABRICKS_URL]/jobs/[TEST_JOB_ID]/runs/[NUMID]?o=[NUMID] + + +>>> print_requests.py //jobs +{ + "headers": { + "User-Agent": [ + "cli/[CLI_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/bundle_run cmd-exec-id/[UUID] interactive/none engine/direct auth/pat" + ] + }, + "method": "POST", + "path": "/api/2.2/jobs/run-now", + "body": { + "job_id": [TEST_JOB_ID] + } +} + +>>> find.py \.databricks/.*(\.tfstate|resources.*\.json|\.wal) +.databricks/bundle/default/terraform/terraform.tfstate diff --git a/acceptance/bundle/migrate/auto/run-no-commit/script b/acceptance/bundle/migrate/auto/run-no-commit/script index 4d65ccbf135..2640ea4e235 100644 --- a/acceptance/bundle/migrate/auto/run-no-commit/script +++ b/acceptance/bundle/migrate/auto/run-no-commit/script @@ -2,6 +2,7 @@ export DATABRICKS_BUNDLE_ENGINE= title "Replay a prior terraform deployment" trace replay_tfstate.py terraform-requests.json terraform.tfstate +replace_ids.py rm -f "$OUT_REQUESTS" title "bundle run on direct migrates the terraform state IN MEMORY (no commit) to resolve the job" @@ -17,3 +18,10 @@ title "Nothing durable written: still on terraform (local state files + remote), # cache under .terraform/ is excluded by matching only state files (tfstate/.backup, resources*.json, WAL). trace find.py '\.databricks/.*(\.tfstate|resources.*\.json|\.wal)' trace MSYS_NO_PATHCONV=1 $CLI workspace list "/Workspace/Users/${CURRENT_USER_NAME}/.bundle/test-bundle/default/state" + +title "bundle run works with engine: terraform: warns and runs the job from the terraform state" +# Set after the replay: replay_tfstate.py runs bundle validate, which rejects engine: terraform. +trace update_file.py databricks.yml "{name: test-bundle}" "{name: test-bundle, engine: terraform}" +trace $CLI bundle run test_job --no-wait +trace print_requests.py //jobs +trace find.py '\.databricks/.*(\.tfstate|resources.*\.json|\.wal)' diff --git a/cmd/bundle/run.go b/cmd/bundle/run.go index 35061f23105..17199a6cabf 100644 --- a/cmd/bundle/run.go +++ b/cmd/bundle/run.go @@ -138,6 +138,9 @@ Example usage: if cmd.ArgsLenAtDash() == 0 && len(args) > 0 { b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{ SkipInitialize: true, + InitFunc: func(b *bundle.Bundle) { + b.AllowTerraformEngineConfig = true + }, }) if err != nil { return err @@ -154,6 +157,10 @@ Example usage: _, _, err := utils.ProcessBundleRet(cmd, utils.ProcessOptions{ AlwaysPull: true, ErrorOnEmptyState: true, + // Let users run a bundle that pins the removed Terraform engine. + InitFunc: func(b *bundle.Bundle) { + b.AllowTerraformEngineConfig = true + }, PostInitFunc: func(ctx context.Context, b *bundle.Bundle) error { var err error key, runArgs, err = resolveRunArgument(ctx, b, args)