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

Resource's state is removed even though the delete returned a error #212

Open
jortiz98 opened this issue Apr 30, 2021 · 0 comments
Open
Labels
bug Something isn't working priority:high

Comments

@jortiz98
Copy link

Describe the bug
When running deletes on resources, gyro still removes the resource from it's state even if it is returned an error on the delete request

To Reproduce
Create a google::compute-region-instance-group-manager with a google::compute-region-autoscaler and google::compute-backend-service. Then build out a google::compute-instance-template that uses that instance-group-manager. When gyro goes to delete the google::compute instance-template resource, it first runs the deletes on it's subresources as a prerequisite. The deletes follow this order:

  1. Deleting google::compute-backend-service
  2. Deleting google::compute-region-autoscaler
  3. Deleting google::compute-region-instance-group-manager
  4. Deleting google::compute-instance-template frontend

When gyro sends the DELETE request to the instance-group-manager, which is a resource that is using the google::compute-instance-template resource, gyro sends that DELETE request then moves on to send a DELETE request for the instance-template resource. However, a error is sent back:

 - Deleting google::compute-backend-service frontend-verify (https://www.googleapis.com/compute/v1/projects/project-id/global/backendServices/resource-name)
    OK

    - Deleting google::compute-region-autoscaler frontend (https://www.googleapis.com/compute/v1/projects/project-id/regions/region/autoscalers/resource-name)
    OK

    - Deleting google::compute-region-instance-group-manager frontend (https://www.googleapis.com/compute/v1/projects/project-id/regions/region/instanceGroupManagers/resource-name)
    OK

    - Deleting google::compute-instance-template frontend (https://www.googleapis.com/compute/v1/projects/project-id/global/instanceTemplates/resource-name)

Error: Can't replace google::compute-instance-template frontend resource!

Caused by: Error: Can't delete google::compute-instance-template frontend resource!

Caused by: Error: The instance_template resource 'projects/project-id/global/instanceTemplates/resource-name' is already being used by 'projects/project-id/regions/region/instanceGroupManagers/resource-name'

The reason gyro fails to delete the instance-template is because the instance-group is still being deleted by GCP. Until the instance-group is completely deleted, you won't be able to delete the instance-template. This is not an issue on gyro's part. Our workflow should add a wait directive to compensate, the problem with gyro is that it still removes the instance-template resource from the state. However, the instance-template resource still exists and the gyro user either has to rebuild the state file by adding that resource's state back or manually delete the instance-template.

Expected behavior
If gyro sends a successful delete request, it should remove the resource from the state. If gyro sends an unsuccessful delete request and a error is returned, it should not remove the resource from the state.

Actual behavior
When gyro sends a successful delete request, it removes the resource from the state. When gyro sends an unsuccessful delete request and an error is returned, it incorrectly removes the resource from state.

@jortiz98 jortiz98 added the bug Something isn't working label Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:high
Projects
None yet
Development

No branches or pull requests

2 participants