-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: Refresh and destroy on resources with an out of band deletion #154
Conversation
…e is an out of band deletion #146
72eaf83
to
c3d27ac
Compare
statusCode := pulumiapi.GetErrorStatusCode(err) | ||
if statusCode == http.StatusNotFound { | ||
// deleteResponse causes the resource to be deleted from the state. | ||
var deleteResponse = &pulumirpc.ReadResponse{Id: "", Properties: nil} | ||
// If it's a 404 error, this resource was probably deleted. | ||
return deleteResponse, nil | ||
} |
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.
This fixes the problem for DeploymentSettings, but it occurs to me that all of our other resources probably have the same bug. Can we do this check one layer up in the provider instead of the resource? I think this would cover it:
Aside: several resources don't implement Read
(ugh) but we don't need to fix that here. It would be so nice to some day generate this provider from an OpenAPI spec!
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.
I will take a look tomorrow morning about that, thx 🙇
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.
I just found teams is handling the "not found" in the way I mention yesterday to you, returning nil instead of propagating the error, I will change to handle it in the same way https://github.com/pulumi/pulumi-pulumiservice/blob/main/provider/pkg/provider/team.go#L192-L194 (unless the api is returning a 404 too and it is just returning an error? https://github.com/pulumi/pulumi-pulumiservice/blob/master/provider/pkg/internal/pulumiapi/teams.go#L108-L112)
For webhooks, it is weird, I guess it is returning a 404 too? (otherwise it accounts as it always exists as it is returning the req.id in the response, no?) I will ping you to see how can I actually test it (I dont want to use pulumi org and my personal one does not have it enabled https://github.com/pulumi/pulumi-pulumiservice/blob/main/provider/pkg/provider/webhook.go#L374-L419)
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.
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.
3d939e3
to
58096ef
Compare
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.
Amazing!
DeploymentSettings, Team and Webhook api client now returns nil on 404 responses so the provider treats it accordingly and recognize them as deleted resources
Fix #146