Forces VMs to be replaced when placement policy is destroyed#1849
Conversation
tpdownes
left a comment
There was a problem hiding this comment.
I trust that this works but I think google_compute_resource_policy.placement_policy might be a list/array all by itself and replace_triggered_by takes a list. So I think the solution might be a bit fragile. Can you wrap the array with flatten and repeat test?
I tried but I get From poking around online it looks like Additionally the documentation for
So I think they have accounted for it to take a reference to a array resource, as is in this case. I propose to leave it as is. |
tpdownes
left a comment
There was a problem hiding this comment.
I was not entirely sure how to read
If the reference is to a resource with multiple instances, a plan to update or replace any instance will trigger replacement.
but reading it again, it does feel like yours is the correct interpretation.
|
Spot check test failed in way that makes it seem that standard no placement policy case does not work, although this was tested manually. I am dismissing approval so this doesn't get merged until I have a chance to debug. |
4319310 to
3cffbeb
Compare
|
While it looks like |
tpdownes
left a comment
There was a problem hiding this comment.
I see what you are doing here. I think the most direct route would be this:
- Create a random suffix and have its lifecycle managed via the same null_resource you've created.
- Apply that random suffix to the name of the resource policy
- Remove the lifecycle from the VM
You can consider this at nit level but I think the basic problem is that the self_link of the resource policy isn't changing and you probably should change it if you're changing its properties.
|
I cannot get rid of the lifecycle on the VM. I get the following error: It looks like it still tries to modify the resource policy on the live VM instead of destroying the VM. |
Tested:
max_distancefrom 1 -> 2; re-deployEach time it recognizes that VM must be destroyed.
Note: If one does not turn
auto_delete_boot_disk: falseyou will still get an error on second apply as it will not find disk. This can be worked around by doing another apply. This disk issue is a known pain point that is unrelated to the placement policy error.Submission Checklist
Please take the following actions before submitting this pull request.