-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Tolerate
databricks_workspace_conf
deletion failures (#3737)
## Changes Currently, deleting `databricks_workspace_conf` can fail in some cases. The provider currently tries to do a best-effort to reset config values to an "original" state by setting all boolean fields to `false` and string fields to `""`. However, the provider isn't aware of three key bits of information: the set of allowed keys in the workspace configuration, the types of values accepted for those keys, and the default values for new workspaces (the last of which can vary from workspace to workspace). As a result, it does a best-effort approach to interpret the value for each key as a boolean, setting it to `false` on delete if it can be interpreted as a boolean, otherwise setting the value for the key to `""`. This can fail, however, if a user has specified a value like `TRue`, this may not be interpreted as a boolean by the provider. The provider then tries to reset its value to `""`, which fails. This PR adds two layers of protection around deletion: first, it attempts to lower-case the value before checking if it is a boolean to handle possible issues with case-sensitivity with the values in workspace_conf. Secondly, if the configuration update fail due to invalid key types, the provider will print a warning message guiding users to our docs page to help them review their workspace config, but it will consider the resource to be successfully deleted. As part of this, I added a small internal module to provide links to docs pages when the provider needs to print them in log messages. Resolves #3316, #1802. ## Tests - [x] `make test` run locally - [x] relevant change in `docs/` folder - [x] covered with integration tests in `internal/acceptance` - [x] relevant acceptance tests are passing - [x] using Go SDK
- Loading branch information
Showing
6 changed files
with
180 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package docs | ||
|
||
import "github.com/databricks/terraform-provider-databricks/common" | ||
|
||
func ProviderRegistryUrl() string { | ||
return "https://registry.terraform.io/providers/databricks/databricks/" + common.Version() + "/" | ||
} | ||
|
||
func ProviderDocumentationRootUrl() string { | ||
return ProviderRegistryUrl() + "docs/" | ||
} | ||
|
||
func ResourceDocumentationUrl(resource string) string { | ||
return ProviderDocumentationRootUrl() + "resources/" + resource | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package docs_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/databricks/terraform-provider-databricks/common" | ||
"github.com/databricks/terraform-provider-databricks/internal/docs" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestProviderRegistryUrl(t *testing.T) { | ||
assert.Equal(t, "https://registry.terraform.io/providers/databricks/databricks/"+common.Version()+"/", docs.ProviderRegistryUrl()) | ||
} | ||
|
||
func TestProviderDocumentationRootUrl(t *testing.T) { | ||
assert.Equal(t, "https://registry.terraform.io/providers/databricks/databricks/"+common.Version()+"/docs/", docs.ProviderDocumentationRootUrl()) | ||
} | ||
|
||
func TestResourceDocumentationUrl(t *testing.T) { | ||
assert.Equal(t, "https://registry.terraform.io/providers/databricks/databricks/"+common.Version()+"/docs/resources/my_resource", docs.ResourceDocumentationUrl("my_resource")) | ||
} |
This file contains 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
This file contains 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