Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle deployment panics when the supplied profile doesn't exist #960

Closed
ilia-db opened this issue Nov 7, 2023 · 2 comments
Closed

Bundle deployment panics when the supplied profile doesn't exist #960

ilia-db opened this issue Nov 7, 2023 · 2 comments
Labels
DABs DABs related issues

Comments

@ilia-db
Copy link
Contributor

ilia-db commented Nov 7, 2023

Describe the issue

databricks bundle deploy --profile TEST panics when the supplied profile doesn't exist in the ~/.databrickscfg file.

Configuration

No special configuration

Steps to reproduce the behavior

  1. Run databricks bundle deploy --profile TEST, make sure that TEST doesn't exist in the ~/.databrickscfg
  2. See error

Expected Behavior

I would expect a proper error message without panics and stacktraces.

Actual Behavior

$: databricks bundle deploy --profile HELLO
panic: resolve: /Users/ilia.babanov/.databrickscfg has no HELLO profile configured. Config: host=https://adb-2548836972759138.18.azuredatabricks.net, profile=HELLO

goroutine 1 [running]:
github.com/databricks/cli/bundle.(*Bundle).WorkspaceClient.func1()
        github.com/databricks/cli/bundle/bundle.go:119 +0x7c
sync.(*Once).doSlow(0x10166a280?, 0x100f31460?)
        sync/once.go:74 +0x100
sync.(*Once).Do(...)
        sync/once.go:65
github.com/databricks/cli/bundle.(*Bundle).WorkspaceClient(0x140003a82c0)
        github.com/databricks/cli/bundle/bundle.go:115 +0x50
github.com/databricks/cli/bundle/config/mutator.(*populateCurrentUser).Apply(0x100fd9998?, {0x100fd9998, 0x140004ff080}, 0x140003a82c0)
        github.com/databricks/cli/bundle/config/mutator/populate_current_user.go:29 +0x3c
github.com/databricks/cli/bundle.Apply({0x100fd9998, 0x140004ff020}, 0x100fd9998?, {0x100fd5150, 0x101761180})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/bundle.(*seqMutator).Apply(0x100fd9998?, {0x100fd9998, 0x140004ff020}, 0x5?)
        github.com/databricks/cli/bundle/seq.go:15 +0x84
github.com/databricks/cli/bundle.Apply({0x100fd9998, 0x140004fefc0}, 0x100b12adb?, {0x100fd41d8, 0x140004a5878})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/bundle/phases.(*phase).Apply(0x140004fee10, {0x100fd9998, 0x140004fefc0}, 0x5?)
        github.com/databricks/cli/bundle/phases/phase.go:31 +0xec
github.com/databricks/cli/bundle.Apply({0x100fd9998, 0x140004fef60}, 0x100fd9998?, {0x100fd5308, 0x140004fee10})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/bundle.(*seqMutator).Apply(0x100fd9998?, {0x100fd9998, 0x140004fef60}, 0x5?)
        github.com/databricks/cli/bundle/seq.go:15 +0x84
github.com/databricks/cli/bundle.Apply({0x100fd9998, 0x140004fedb0}, 0x0?, {0x100fd41d8, 0x140004a5860})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/cmd/bundle.newDeployCommand.func1(0x140004a7b00, {0x14000413760?, 0x4?, 0x100b0d1a5?})
        github.com/databricks/cli/cmd/bundle/deploy.go:30 +0x1b8
github.com/spf13/cobra.(*Command).execute(0x140004a7b00, {0x14000413740, 0x2, 0x2})
        github.com/spf13/[email protected]/command.go:940 +0x658
github.com/spf13/cobra.(*Command).ExecuteC(0x140003be000)
        github.com/spf13/[email protected]/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        github.com/spf13/[email protected]/command.go:1001
github.com/databricks/cli/cmd/root.Execute(0x100fd9960?)
        github.com/databricks/cli/cmd/root/root.go:99 +0x58
main.main()
        github.com/databricks/cli/main.go:11 +0x30 

OS and CLI version

Databricks CLI v0.208.2, but also current main
macOS 13.6 (22G120)

Is this a regression?

Not sure, but the panic has been added explicitly here - #102

Debug Logs

databricks bundle deploy --profile HELLO --log-level debug
10:18  INFO start version=0.208.2 args=databricks, bundle, deploy, --profile, HELLO, --log-level, debug
10:18 DEBUG Loading bundle configuration from: /Users/ilia.babanov/tmp/ilia_babanov_cow_bff/databricks.yml
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=scripts.preinit
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="scripts.go 37}" msg="No script defined for preinit, skipping" mutator=seq mutator=scripts.preinit
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=ProcessRootIncludes
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=ProcessRootIncludes mutator=seq
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=ProcessRootIncludes mutator=seq mutator=ProcessInclude(resources/ilia_babanov_cow_bff_job.yml)
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=DefineDefaultTarget(default)
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=LoadGitDetails
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=SelectDefaultTarget
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=initialize
time=2023-11-07T10:18:54.931+01:00 level=INFO source="phase.go 30}" msg="Phase: initialize" mutator=seq mutator=initialize
time=2023-11-07T10:18:54.931+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=initialize mutator=seq
time=2023-11-07T10:18:54.932+01:00 level=DEBUG source="mutator.go 22}" msg=Apply mutator=seq mutator=initialize mutator=seq mutator=PopulateCurrentUser
panic: resolve: /Users/ilia.babanov/.databrickscfg has no HELLO profile configured. Config: host=https://adb-2548836972759138.18.azuredatabricks.net, profile=HELLO

goroutine 1 [running]:
github.com/databricks/cli/bundle.(*Bundle).WorkspaceClient.func1()
        github.com/databricks/cli/bundle/bundle.go:119 +0x7c
sync.(*Once).doSlow(0x0?, 0x0?)
        sync/once.go:74 +0x100
sync.(*Once).Do(...)
        sync/once.go:65
github.com/databricks/cli/bundle.(*Bundle).WorkspaceClient(0x140003a82c0)
        github.com/databricks/cli/bundle/bundle.go:115 +0x50
github.com/databricks/cli/bundle/config/mutator.(*populateCurrentUser).Apply(0x105071998?, {0x105071998, 0x140004f5530}, 0x140003a82c0)
        github.com/databricks/cli/bundle/config/mutator/populate_current_user.go:29 +0x3c
github.com/databricks/cli/bundle.Apply({0x105071998, 0x140004f5470}, 0x140004dd5b0?, {0x10506d150, 0x1057f9180})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/bundle.(*seqMutator).Apply(0x105071998?, {0x105071998, 0x140004f5}, 0x5?)
        github.com/databricks/cli/bundle/seq.go:15 +0x84
github.com/databricks/cli/bundle.Apply({0x105071998, 0x140004f5350}, 0x104baaadb?, {0x10506c1d8, 0x140004a58c0})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/bundle/phases.(*phase).Apply(0x140004f5140, {0x105071998, 0x140004f5350}, 0x5?)
        github.com/databricks/cli/bundle/phases/phase.go:31 +0xec
github.com/databricks/cli/bundle.Apply({0x105071998, 0x140004f5290}, 0x140004dd500?, {0x10506d308, 0x140004f5140})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/bundle.(*seqMutator).Apply(0x105071998?, {0x105071998, 0x140004f5290}, 0x5?)
        github.com/databricks/cli/bundle/seq.go:15 +0x84
github.com/databricks/cli/bundle.Apply({0x105071998, 0x140004f50e0}, 0x0?, {0x10506c1d8, 0x140004a58a8})
        github.com/databricks/cli/bundle/mutator.go:23 +0x10c
github.com/databricks/cli/cmd/bundle.newDeployCommand.func1(0x140004a7b00, {0x14000475b40?, 0x4?, 0x104ba51a5?})
        github.com/databricks/:30 +0x1b8
github.com/spf13/cobra.(*Command).execute(0x140004a7b00, {0x14000475b00, 0x4, 0x4})
        github.com/spf13/[email protected]/command.go:940 +0x658
github.com/spf13/cobra.(*Command).ExecuteC(0x140003c0000)
        github.com/spf13/[email protected]/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        github.com/spf13/[email protected]/command.go:1001
github.com/databricks/cli/cmd/root.Execute(0x105071960?)
        github.com/databricks/cli/cmd/root/root.go:99 +0x58
main.main()
        github.com/databricks/cli/main.go:11 +0x30
@ilia-db ilia-db added the DABs DABs related issues label Nov 7, 2023
@andrewnester
Copy link
Contributor

This panic is (somewhat) intentional and is a consequence of us using .Do call and define WorkspaceClient() to always return WorkspaceClient and panic if something is wrong. it makes usage if WorkspaceClient cleaner but the error is indeed less readable
https://github.com/databricks/cli/blob/main/bundle/bundle.go#L124C36-L133

@pietern what's your thoughts on it?

@pietern
Copy link
Contributor

pietern commented Dec 11, 2023

This has been addressed in #1002.

@pietern pietern closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DABs DABs related issues
Projects
None yet
Development

No branches or pull requests

3 participants