Skip to content
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

Custom delete for dbforpostgresql:Configuration to reset to the correct default #3752

Merged
merged 4 commits into from
Dec 6, 2024

Conversation

thomas11
Copy link
Contributor

@thomas11 thomas11 commented Dec 5, 2024

Resolves #3476.

The dbforpostgresql:Configuration resource cannot actually be deleted, so we reset it to its default value instead. However, there are many configuration parameters with different defaults. On delete, we first GET this configuration to read the correct default value, then set it. This is the same approach that az takes in az postgres flexible-server parameter set.

@thomas11 thomas11 self-assigned this Dec 5, 2024
@thomas11 thomas11 requested review from danielrbradley and a team December 5, 2024 15:25
Copy link

github-actions bot commented Dec 5, 2024

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 40.90909% with 39 lines in your changes missing coverage. Please review.

Project coverage is 56.80%. Comparing base (a8e5e1c) to head (ba9989d).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...esources/customresources/custom_postgres_config.go 29.16% 32 Missing and 2 partials ⚠️
...r/pkg/resources/customresources/customresources.go 66.66% 3 Missing and 1 partial ⚠️
provider/pkg/provider/provider.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3752      +/-   ##
==========================================
- Coverage   56.90%   56.80%   -0.10%     
==========================================
  Files          76       77       +1     
  Lines       11885    11947      +62     
==========================================
+ Hits         6763     6787      +24     
- Misses       4630     4665      +35     
- Partials      492      495       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -130 to -132
new global::Pulumi.Alias { Type = "azure-native:dbforpostgresql/v20200214preview:Configuration" },
new global::Pulumi.Alias { Type = "azure-native:dbforpostgresql/v20200214privatepreview:Configuration" },
new global::Pulumi.Alias { Type = "azure-native:dbforpostgresql/v20210410privatepreview:Configuration" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look fine because these resources don't actually exist in the SDK. This is because these are listed in the v2-removed-resources.json file

https://github.com/pulumi/pulumi-azure-native/blob/0d0261fd754ec20a98c1b6336897d6935bd0cceb/versions/v2-removed-resources.json#L2660-L2661

@thomas11 thomas11 force-pushed the tkappler/postgres-config-patch2 branch from 547aa68 to 8ea6ac6 Compare December 5, 2024 16:33
@thomas11 thomas11 force-pushed the tkappler/postgres-config-patch2 branch from 8ea6ac6 to 61d52b0 Compare December 5, 2024 16:55
@thomas11 thomas11 enabled auto-merge (squash) December 5, 2024 16:56
@thomas11 thomas11 force-pushed the tkappler/postgres-config-patch2 branch from 61d52b0 to 15819bc Compare December 6, 2024 06:32
Copy link
Member

@danielrbradley danielrbradley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this looks fine with the new singleton handling 👍

Comment on lines +973 to +975
func isSingleton(resource *resourceVariant) bool {
return resource.PathItem.Delete == nil || customresources.IsSingleton(resource.Path)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a nice place to explain what a singleton is

Suggested change
func isSingleton(resource *resourceVariant) bool {
return resource.PathItem.Delete == nil || customresources.IsSingleton(resource.Path)
}
// isSingleton indicates if the resource is created and therefore deleted as
// part of its parent resource. When deleting a singleton we will reset its
// properties back to a default state. However a custom resource might still
// provide a delete method to perform a custom reset.
func isSingleton(resource *resourceVariant) bool {
return resource.PathItem.Delete == nil || customresources.IsSingleton(resource.Path)
}

@@ -229,6 +240,13 @@ func HasCustomDelete(path string) bool {
return false
}

func IsSingleton(path string) bool {
if res, ok := featureLookup[path]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh .. I find this magic global state for featureLookup lookup somewhat confusing. I think it was added for easier access at runtime in the provider .. but I guess this is fine to call to call during codegen too.

@thomas11 thomas11 merged commit f189550 into master Dec 6, 2024
23 checks passed
@thomas11 thomas11 deleted the tkappler/postgres-config-patch2 branch December 6, 2024 14:30
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v2.76.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to delete an azure-native.dbforpostgresql.Configuration resource: PUT vs PATCH
3 participants