mirror of https://github.com/databricks/cli.git
Improve error when bundle root is not writable (#1093)
## Changes This improves the error when deploying to a bundle root that the current user doesn't have write access to. This can come up slightly more often since the change of https://github.com/databricks/cli/pull/1091. Before this change: ``` $ databricks bundle deploy --target prod Building my_project... Error: no such directory: /Users/lennart.kats@databricks.com/.bundle/my_project/prod/state ``` After this change: ``` $ databricks bundle deploy --target prod Building my_project... Error: cannot write to deployment root (this can indicate a previous deploy was done with a different identity): /Users/lennart.kats@databricks.com/.bundle/my_project/prod ``` Note that this change uses the "no such directory" error returned from the filer.
This commit is contained in:
parent
206b1bf198
commit
9a1f078bd9
|
@ -2,8 +2,11 @@ package lock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/libs/filer"
|
||||||
"github.com/databricks/cli/libs/locker"
|
"github.com/databricks/cli/libs/locker"
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
@ -47,6 +50,13 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
err = b.Locker.Lock(ctx, force)
|
err = b.Locker.Lock(ctx, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf(ctx, "Failed to acquire deployment lock: %v", err)
|
log.Errorf(ctx, "Failed to acquire deployment lock: %v", err)
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue