Fix bind/unbind to resolve engine from bundle config, not just env var#4894
Open
Fix bind/unbind to resolve engine from bundle config, not just env var#4894
Conversation
The bind and unbind commands use engine.FromEnv() which only reads the DATABRICKS_BUNDLE_ENGINE environment variable. They ignore both the bundle.engine config setting and existing deployment state. The bind test shows that after deploying with direct engine (from config), bind silently creates terraform state alongside direct state. The unbind test shows that after deploying with direct engine (from config), unbind fails trying to use terraform because no terraform state exists. Task: 001.md Co-authored-by: Isaac
Bind() and Unbind() in bundle/phases/bind.go were calling engine.FromEnv() which only reads the DATABRICKS_BUNDLE_ENGINE env var. This meant they ignored the bundle.engine config setting and existing deployment state. Changed both functions to accept engine.EngineType as a parameter (matching Deploy()'s pattern), with callers resolving the engine via ProcessBundleRet which uses ResolveEngineSetting (config > env var > default). Task: 002.md
Tests now verify correct behavior: bind and unbind use the direct engine when bundle.engine is set to "direct" in config. Changed EnvMatrix to ["direct"] per task requirements. Task: 002.md
Task: 002.md
Change DATABRICKS_BUNDLE_ENGINE from ["direct"] to [] in bind/unbind engine-from-config tests. With ["direct"], env and config agreed so a regression back to engine.FromEnv() would still pass. With [], the env var is unset and the tests verify that bind/unbind read engine from bundle.engine config. Task-review: /Users/denis.bilenko/work/prompts/features/bundle-engine-vs-env/003.SUMMARY.md Co-authored-by: Isaac
Suggested reviewersBased on git history of the changed files, these people are best suited to review:
Confidence: high Eligible reviewersBased on CODEOWNERS, these people or teams could also review: @anton-107, @databricks/eng-apps-devex, @pietern, @shreyas-goenka, @simonfaltum Suggestions based on git history of 14 changed files (4 scored). See CODEOWNERS for path-specific ownership rules. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
bindandunbindnow resolve the deployment engine from bundle config (bundle.engine), not just theDATABRICKS_BUNDLE_ENGINEenv var. This matches howdeployanddestroyalready work.Why
When
bundle.engine: directwas set in config but the env var was unset,bindwould silently create terraform state alongsideresources.json, andunbindwould fail with "No state file was found!" because it looked for terraform state.Tests
bindandunbindwithbundle.engine: directin config and no env var set, verifying the engine is resolved from config.