From 833a3614a68bb364177495dc9356796e84647607 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 14 Jan 2025 16:48:58 +0000 Subject: [PATCH 1/5] Always set no_compute to true for apps --- bundle/deploy/terraform/tfdyn/convert_app.go | 6 ++++++ bundle/deploy/terraform/tfdyn/convert_app_test.go | 1 + 2 files changed, 7 insertions(+) diff --git a/bundle/deploy/terraform/tfdyn/convert_app.go b/bundle/deploy/terraform/tfdyn/convert_app.go index dcba0809b6..b3d599f15d 100644 --- a/bundle/deploy/terraform/tfdyn/convert_app.go +++ b/bundle/deploy/terraform/tfdyn/convert_app.go @@ -38,6 +38,12 @@ func (appConverter) Convert(ctx context.Context, key string, vin dyn.Value, out return err } + // We always set no_compute to true as it allows DABs not to wait for app compute to be started when app is created. + vout, err = dyn.Set(vout, "no_compute", dyn.V(true)) + if err != nil { + return err + } + // Add the converted resource to the output. out.App[key] = vout.AsAny() diff --git a/bundle/deploy/terraform/tfdyn/convert_app_test.go b/bundle/deploy/terraform/tfdyn/convert_app_test.go index be8152cc62..722d3b2f8d 100644 --- a/bundle/deploy/terraform/tfdyn/convert_app_test.go +++ b/bundle/deploy/terraform/tfdyn/convert_app_test.go @@ -63,6 +63,7 @@ func TestConvertApp(t *testing.T) { assert.Equal(t, map[string]any{ "description": "app description", "name": "app_id", + "no_compute": true, "resources": []any{ map[string]any{ "name": "job1", From af6171d9b3c0e4179c6667b82b4421bb9f52c98b Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 14 Jan 2025 16:51:29 +0000 Subject: [PATCH 2/5] make app creation test short --- integration/bundle/apps_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/integration/bundle/apps_test.go b/integration/bundle/apps_test.go index 2da764ed8a..913d99afea 100644 --- a/integration/bundle/apps_test.go +++ b/integration/bundle/apps_test.go @@ -16,12 +16,6 @@ import ( func TestDeployBundleWithApp(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) - // TODO: should only skip app run when app can be created with no_compute option. - if testing.Short() { - t.Log("Skip the app creation and run in short mode") - return - } - if testutil.GetCloud(t) == testutil.GCP { t.Skip("Skipping test for GCP cloud because /api/2.0/apps is temporarily unavailable there.") } @@ -80,6 +74,11 @@ env: - name: JOB_ID value: "%d"`, job.JobId)) + if testing.Short() { + t.Log("Skip the app run in short mode") + return + } + // Try to run the app _, out := runResourceWithStderr(t, ctx, root, "test_app") require.Contains(t, out, app.Url) From 8e9546e9c5683ac5059db0357204140ab7b98319 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 14 Jan 2025 17:07:36 +0000 Subject: [PATCH 3/5] fix test --- bundle/deploy/terraform/tfdyn/convert_app_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bundle/deploy/terraform/tfdyn/convert_app_test.go b/bundle/deploy/terraform/tfdyn/convert_app_test.go index 722d3b2f8d..cdf56f8ed8 100644 --- a/bundle/deploy/terraform/tfdyn/convert_app_test.go +++ b/bundle/deploy/terraform/tfdyn/convert_app_test.go @@ -137,6 +137,7 @@ func TestConvertAppWithNoDescription(t *testing.T) { assert.Equal(t, map[string]any{ "name": "app_id", "description": "", // Due to Apps API always returning a description field, we set it in the output as well to avoid permanent TF drift + "no_compute": true, "resources": []any{ map[string]any{ "name": "job1", From 1cd201fa200548d296a2dbf773f44ee77658a4de Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 28 Jan 2025 16:32:45 +0000 Subject: [PATCH 4/5] removed slow deploy warning --- bundle/apps/slow_deploy_message.go | 29 ----------------------------- bundle/phases/deploy.go | 1 - 2 files changed, 30 deletions(-) delete mode 100644 bundle/apps/slow_deploy_message.go diff --git a/bundle/apps/slow_deploy_message.go b/bundle/apps/slow_deploy_message.go deleted file mode 100644 index 87275980af..0000000000 --- a/bundle/apps/slow_deploy_message.go +++ /dev/null @@ -1,29 +0,0 @@ -package apps - -import ( - "context" - - "github.com/databricks/cli/bundle" - "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/cli/libs/diag" -) - -type slowDeployMessage struct{} - -// TODO: needs to be removed when when no_compute option becomes available in TF provider and used in DABs -// See https://github.com/databricks/cli/pull/2144 -func (v *slowDeployMessage) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { - if len(b.Config.Resources.Apps) > 0 { - cmdio.LogString(ctx, "Note: Databricks apps included in this bundle may increase initial deployment time due to compute provisioning.") - } - - return nil -} - -func (v *slowDeployMessage) Name() string { - return "apps.SlowDeployMessage" -} - -func SlowDeployMessage() bundle.Mutator { - return &slowDeployMessage{} -} diff --git a/bundle/phases/deploy.go b/bundle/phases/deploy.go index b59ce9f89f..c6ec04962e 100644 --- a/bundle/phases/deploy.go +++ b/bundle/phases/deploy.go @@ -130,7 +130,6 @@ func Deploy(outputHandler sync.OutputHandler) bundle.Mutator { // mutators need informed consent if they are potentially destructive. deployCore := bundle.Defer( bundle.Seq( - apps.SlowDeployMessage(), bundle.LogString("Deploying resources..."), terraform.Apply(), ), From bd7c8ac13e1c92c5d96b8c327143433691ce58ea Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 28 Jan 2025 16:59:58 +0000 Subject: [PATCH 5/5] update expected output --- integration/bundle/testdata/apps/bundle_deploy.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/integration/bundle/testdata/apps/bundle_deploy.txt b/integration/bundle/testdata/apps/bundle_deploy.txt index b077f327db..211164174e 100644 --- a/integration/bundle/testdata/apps/bundle_deploy.txt +++ b/integration/bundle/testdata/apps/bundle_deploy.txt @@ -1,5 +1,4 @@ Uploading bundle files to /Workspace/Users/$USERNAME/.bundle/$UNIQUE_PRJ/files... -Note: Databricks apps included in this bundle may increase initial deployment time due to compute provisioning. Deploying resources... Updating deployment state... Deployment complete!