Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/bundles/7597.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Retry the root path check in `bundle destroy` on transient errors, so a dropped connection no longer fails the destroy. ([#7597](https://github.com/databricks/cli/pull/7597))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bundle:
name: destroy-get-status-500-$UNIQUE_NAME

resources:
jobs:
foo:
name: foo-$UNIQUE_NAME
2 changes: 2 additions & 0 deletions acceptance/bundle/destroy/get-status-500/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = false
EnvMatrix.DMS = ["", "true"]
17 changes: 17 additions & 0 deletions acceptance/bundle/destroy/get-status-500/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/destroy-get-status-500-[UNIQUE_NAME]/default/files...
Created jobs.foo
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== A 500 on the root path get-status is retried

>>> [CLI] bundle destroy --auto-approve
Warn: retrying after 500 Internal Server Error from GET /api/2.0/workspace/get-status
The following resources will be deleted:
delete resources.jobs.foo

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/destroy-get-status-500-[UNIQUE_NAME]/default

Destroy: 1 deleted
9 changes: 9 additions & 0 deletions acceptance/bundle/destroy/get-status-500/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
envsubst < databricks.yml.tmpl > databricks.yml

trace $CLI bundle deploy

# Destroy first checks that the bundle root path exists. A 500 from that read (seen on cloud as
# "unexpected EOF" when the connection is cut) is retried instead of failing the destroy.
title "A 500 on the root path get-status is retried"
fault.py "GET /api/2.0/workspace/get-status" 500 0 1
trace $CLI bundle destroy --auto-approve
9 changes: 9 additions & 0 deletions acceptance/bundle/destroy/get-status-500/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Cloud = false

Env.DATABRICKS_BUNDLE_RETRY_INTERVAL_MS = "100"
SuppressLines.warn_retry = ""

Ignore = [
"databricks.yml",
".databricks/"
]
7 changes: 6 additions & 1 deletion bundle/phases/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ import (
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/logdiag"
"github.com/databricks/cli/libs/retry"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/service/workspace"
)

func assertRootPathExists(ctx context.Context, b *bundle.Bundle) (bool, error) {
w := b.WorkspaceClient(ctx)
_, err := w.Workspace.GetStatusByPath(ctx, b.Config.Workspace.RootPath)
// The read has no side effects, so a transient failure is safe to replay instead of failing destroy.
_, err := retry.With(ctx, retry.IsTransientRead, func() (*workspace.ObjectInfo, error) {
return w.Workspace.GetStatusByPath(ctx, b.Config.Workspace.RootPath)
})

if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.StatusCode == http.StatusNotFound {
log.Infof(ctx, "Root path does not exist: %s", b.Config.Workspace.RootPath)
Expand Down
Loading