mirror of https://github.com/databricks/cli.git
Do not wait for app compute to start on `bundle deploy` (#2144)
## Changes This allows DABs to avoid waiting for the compute to start when app is initially created as part of "bundle deploy" which significantly improves deploy time. Always set no_compute to true for apps ## Tests Covered by `TestDeployBundleWithApp`, currently fails until TF provider is upgraded to the version supporting `no_compute` option
This commit is contained in:
parent
099e9bed0f
commit
413ca5c134
|
@ -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{}
|
||||
}
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
@ -136,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",
|
||||
|
|
|
@ -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(),
|
||||
),
|
||||
|
|
|
@ -18,12 +18,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.")
|
||||
}
|
||||
|
@ -106,6 +100,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)
|
||||
|
|
|
@ -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!
|
||||
|
|
Loading…
Reference in New Issue