-
Notifications
You must be signed in to change notification settings - Fork 184
direct: Fix spurious recreate of external volumes with trailing-slash storage_location #5145
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
Changes from all commits
f6229e8
b6e814e
b4f00e8
0ded0ac
22517b3
2598f17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| volumes: | ||
| foo: | ||
| name: test-volume-$UNIQUE_NAME | ||
| catalog_name: main | ||
| schema_name: default | ||
| volume_type: EXTERNAL | ||
| storage_location: s3://test-bucket/path/ | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,9 @@ import ( | |
| "strings" | ||
|
|
||
| "github.com/databricks/cli/bundle/config/resources" | ||
| "github.com/databricks/cli/bundle/deployplan" | ||
| "github.com/databricks/cli/libs/log" | ||
| "github.com/databricks/cli/libs/structs/structpath" | ||
| "github.com/databricks/cli/libs/utils" | ||
| "github.com/databricks/databricks-sdk-go" | ||
| "github.com/databricks/databricks-sdk-go/service/catalog" | ||
|
|
@@ -112,6 +114,35 @@ func (r *ResourceVolume) DoDelete(ctx context.Context, id string) error { | |
| return r.client.Volumes.DeleteByName(ctx, id) | ||
| } | ||
|
|
||
| // OverrideChangeDesc suppresses drift for storage_location when the only difference | ||
| // is a trailing slash. The UC API strips trailing slashes on create, so remote returns | ||
| // "s3://bucket/path" while the config may have "s3://bucket/path/". | ||
| // | ||
| // This matches the Terraform provider's suppressLocationDiff behavior. | ||
| // https://github.com/databricks/terraform-provider-databricks/blob/v1.65.1/catalog/resource_volume.go#L25 | ||
| func (*ResourceVolume) OverrideChangeDesc(_ context.Context, path *structpath.PathNode, change *ChangeDesc, _ *catalog.VolumeInfo) error { | ||
| if change.Action == deployplan.Skip { | ||
| return nil | ||
| } | ||
|
|
||
| if path.String() != "storage_location" { | ||
| return nil | ||
| } | ||
|
|
||
| newStr, newOk := change.New.(string) | ||
| remoteStr, remoteOk := change.Remote.(string) | ||
| if !newOk || !remoteOk { | ||
| return nil | ||
| } | ||
|
|
||
| if newStr != remoteStr && strings.TrimRight(newStr, "/") == strings.TrimRight(remoteStr, "/") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we store the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, state is tracking the config. If user has slash in the config, we do that as well. Normalized comparison is more explicit. |
||
| change.Action = deployplan.Skip | ||
| change.Reason = deployplan.ReasonURLNormalization | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func getNameFromID(id string) (string, error) { | ||
| items := strings.Split(id, ".") | ||
| if len(items) == 0 { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider multiple
/as suffix to ensure TrimRight does the expected thing