Fix yaml config-remote-sync snapshot creation when bundle is deployed without any resources#4889
Fix yaml config-remote-sync snapshot creation when bundle is deployed without any resources#4889ilyakuz-db wants to merge 4 commits intomainfrom
Conversation
Suggested reviewersBased on git history of the changed files, these people are best suited to review:
Confidence: low Eligible reviewersBased on CODEOWNERS, these people or teams could also review: @andrewnester, @anton-107, @pietern, @shreyas-goenka, @simonfaltum Suggestions based on git history of 5 changed files (1 scored). See CODEOWNERS for path-specific ownership rules. |
| } | ||
|
|
||
| func (m *uploadStateForYamlSync) convertState(ctx context.Context, b *bundle.Bundle, snapshotPath string) (diags diag.Diagnostics) { | ||
| func (m *uploadStateForYamlSync) convertState(ctx context.Context, b *bundle.Bundle, snapshotPath string) (bool, diag.Diagnostics) { |
There was a problem hiding this comment.
unrelated question, since it was added previously, but do you need to collect diagnostics? Why not just logs errors and warnings directly? (or logdiag.LogError/logdiag.LogError if you need diagnostics formatting).
| Ignore = [".databricks", "databricks.yml"] | ||
|
|
||
| [Env] | ||
| DATABRICKS_BUNDLE_ENABLE_EXPERIMENTAL_YAML_SYNC = "true" |
There was a problem hiding this comment.
I think we should have a test with empty bundle already somewhere (if not, we should have it). We can then use EnvMatrix to run it both with DATABRICKS_BUNDLE_ENABLE_EXPERIMENTAL_YAML_SYNC and without.
Perhaps there are more tests where we need to test this variant?
There was a problem hiding this comment.
Added matrix to the acceptance/bundle/deploy/empty-bundle/test.toml
Changes
UploadStateForYamlSync now handles the case where the terraform state file doesn't exist. When ParseResourcesState returns nil (no state), the mutator skips snapshot creation and returns successfully. Errors in snapshot creation/upload are now warnings instead of fatal errors.
Why
Bug:
First deploy of an empty bundle with yaml sync enabled and terraform engine failed with open .../terraform.tfstate: no such file or directory. Terraform skips apply when there are no resources, so the state file is never created. The mutator tried to read it unconditionally.
Tests
Added acceptance/bundle/config-remote-sync/empty_deploy — deploys an empty bundle with yaml sync + terraform engine.