From 3d5117776c1bd285e49dbffe727663854fd17d36 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 27 Dec 2023 10:12:57 +0100 Subject: [PATCH 1/3] Improve error when bundle root is not writable --- bundle/deploy/lock/acquire.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bundle/deploy/lock/acquire.go b/bundle/deploy/lock/acquire.go index 18778aa5dd..70ca831da1 100644 --- a/bundle/deploy/lock/acquire.go +++ b/bundle/deploy/lock/acquire.go @@ -2,8 +2,11 @@ package lock import ( "context" + "errors" + "fmt" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/locker" "github.com/databricks/cli/libs/log" ) @@ -38,6 +41,7 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error { } err := m.init(b) + existError := filer.NoSuchDirectoryError{} if err != nil { return err } @@ -47,6 +51,9 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error { err = b.Locker.Lock(ctx, force) if err != nil { log.Errorf(ctx, "Failed to acquire deployment lock: %v", err) + if errors.As(err, &existError) { + return fmt.Errorf("access denied to deployment root (this can indicate a previous deploy was done with a different identity): %s", b.Config.Workspace.RootPath) + } return err } From d5b997e60b4e7e1f9c275983870b932bc5aa8c99 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 27 Dec 2023 10:26:09 +0100 Subject: [PATCH 2/3] Add comment --- bundle/deploy/lock/acquire.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bundle/deploy/lock/acquire.go b/bundle/deploy/lock/acquire.go index 70ca831da1..ff399f1e59 100644 --- a/bundle/deploy/lock/acquire.go +++ b/bundle/deploy/lock/acquire.go @@ -41,7 +41,6 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error { } err := m.init(b) - existError := filer.NoSuchDirectoryError{} if err != nil { return err } @@ -51,8 +50,12 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error { err = b.Locker.Lock(ctx, force) if err != nil { log.Errorf(ctx, "Failed to acquire deployment lock: %v", err) + + existError := filer.NoSuchDirectoryError{} if errors.As(err, &existError) { - return fmt.Errorf("access denied to deployment root (this can indicate a previous deploy was done with a different identity): %s", b.Config.Workspace.RootPath) + // If we get a "doesn't exist" error from the API this indicates + // we either don't have permissions or the path is invalid. + return fmt.Errorf("cannot write to deployment root (this can indicate a previous deploy was done with a different identity): %s", b.Config.Workspace.RootPath) } return err } From 90202cde0106566c7a676719bb3e4743aed6449c Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Thu, 28 Dec 2023 13:24:05 +0100 Subject: [PATCH 3/3] Rename variable --- bundle/deploy/lock/acquire.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle/deploy/lock/acquire.go b/bundle/deploy/lock/acquire.go index ff399f1e59..1335f7800c 100644 --- a/bundle/deploy/lock/acquire.go +++ b/bundle/deploy/lock/acquire.go @@ -51,8 +51,8 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error { if err != nil { log.Errorf(ctx, "Failed to acquire deployment lock: %v", err) - existError := filer.NoSuchDirectoryError{} - if errors.As(err, &existError) { + notExistsError := filer.NoSuchDirectoryError{} + if errors.As(err, ¬ExistsError) { // If we get a "doesn't exist" error from the API this indicates // we either don't have permissions or the path is invalid. return fmt.Errorf("cannot write to deployment root (this can indicate a previous deploy was done with a different identity): %s", b.Config.Workspace.RootPath)