You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fix] Tolerate invalid keys in databricks_workspace_conf (#4102)
## Changes
Occasionally, support for configuration keys is removed from the
GetStatus/SetStatus APIs used to manage workspace configuration. When
this happens, users who depended on those keys are in a bad state. The
provider queries for the values for each configuration by key in the
Terraform state, but those keys no longer exist.
To work around this, this PR makes `databricks_workspace_conf` resilient
to keys being removed. On the read path, the provider queries for the
status of all keys in state. If any key is no longer valid, it is
removed from the request and the request is retried. Setting the value
for invalid configuration keys is not supported. When removing an
unsupported configuration key, the provider resets the key to an
original state (`false` or `""`). Failures to reset invalid keys are
ignored, both on the update path (removing an unsupported key from the
conf) and on the delete path (removing the `databricks_workspace_conf`
resource altogether).
## Tests
Integration tests verify that the new SafeGetStatus and SafeSetStatus
methods work with invalid keys as expected. On the read side, they are
ignored, and on the write side, they are ignored if marked for removal.
- [ ] `make test` run locally
- [ ] relevant change in `docs/` folder
- [ ] covered with integration tests in `internal/acceptance`
- [ ] relevant acceptance tests are passing
- [ ] using Go SDK
tflog.Warn(ctx, fmt.Sprintf("the following keys are not supported by the api: %s. Remove these keys from the configuration to avoid this warning.", strings.Join(invalidKeys, ", ")))
172
+
// Request again but remove invalid keys
173
+
validKeys:=make([]string, 0, len(keys))
174
+
for_, k:=rangekeys {
175
+
if!slices.Contains(invalidKeys, k) {
176
+
validKeys=append(validKeys, k)
177
+
}
178
+
}
179
+
iflen(validKeys) ==0 {
180
+
returnnil, fmt.Errorf("failed to get workspace conf because all keys are invalid: %s", strings.Join(keys, ", "))
0 commit comments