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

allow service to be reused #578

Merged
merged 7 commits into from
Aug 11, 2022
Merged

allow service to be reused #578

merged 7 commits into from
Aug 11, 2022

Conversation

Integralist
Copy link
Collaborator

@Integralist Integralist commented Jul 19, 2022

Fixes #515

Summary: add reuse attribute to fastly_service_compute and fastly_service_vcl that causes terraform destroy to not fully delete the service.

See my notes for the full details and my manual validation of this change set, and the various caveats:
#515 (comment)

NOTE: I've manually tested this feature, and found it to work (see comment) but there are no tests written because the Terraform test framework expects resources to be destroyed at the end of each e2e test, and this PR implements a feature that sits outside that scenario, and so any test we write would fail unless written in a really janky way and additionally we'd need to implement a post-test process to then clean-up the service resource that was set to persist being destroyed.

Flow Examples

  • terraform destroy: service not activated
    • no attributes set == delete service API call (successful)
    • force_destroy == no deactivation service API call, delete service API call (successful)
    • reuse == no deactivation service API call, no delete service API call (basically a no-op)
  • terraform destroy: service activated
    • no attributes set == delete service API call (fails -- as I can't delete an active service without deactivating first)
    • force_destroy == deactivate service API call (successful), delete service API call (successful)
    • reuse == deactivate service API call (successful)

@Integralist Integralist added the enhancement New feature or request label Jul 19, 2022
@Integralist Integralist requested a review from phamann July 19, 2022 18:49
@Integralist Integralist requested review from a team and triblondon and removed request for phamann and a team August 10, 2022 15:03
@Integralist Integralist marked this pull request as ready for review August 10, 2022 15:03
})
if err != nil {
return diag.FromErr(err)
if !d.Get("reuse").(bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be clearer to make this a check for force_destroy instead of not reuse?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, because if the user doesn't specify anything then this breaks the current behaviour.

e.g. currently, if the user has a deactivated service and they don't specify force_destroy, then the service will successfully be deleted. By changing the condition to be d.Get("force_destroy").(bool) we're effectively saying they have to add force_destroy to delete their deactivated service. By negating the reuse check we can keep the existing behaviour while supporting the new behaviour.

@Integralist Integralist merged commit 6484e90 into main Aug 11, 2022
@Integralist Integralist deleted the integralist/reuse-service branch August 11, 2022 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add option to deactivate service as part of terraform destroy
2 participants