cdktf: Large terraform.<stack>.tfstate
file is cleaned when destroy
is cancelled
#3269
Labels
bug
Something isn't working
enhancement/new-workflow
Proposed new workflow
priority/backlog
Low priority (though possibly still important). Unlikely to be worked on within the next 6 months.
ux/cli
Expected Behavior
I am running
cdktf destroy
via a python usingsubprocess.run
. The exact command isWhen this is destroying instances, pressing
ctrl +c
should stop the destroy and leave theterraform.<stack>.tfstate
file with an accurate list of state.Actual Behavior
The
terraform.<stack>.tfstate
file is empty.Steps to Reproduce
I did a fair bit of testing to try and narrow down what exactly is happening here and get it to the smallest repeatable unit. It seems like the
python
subprocess call is required for the state to be emptied permanently, however using a rawcdktf destroy
I noticed that the state file is briefly emptied and then recreated. This seems dependent on the size of the state.I suspect what is happening is when the subprocess is cancelled, there isn't enough time given for the
cdktf
process to recreate the state file. Normally thecdktf
process would be given about 10 seconds before the kill is escalated.cdktf destroy
via pythonctrl +c
.I can reliably reproduce this with a ~5MB state file.
Versions
Providers
Gist
No response
Possible Solutions
It might be possible to write the state to a temporary file and then swap instead of emptying the existing state and rewriting it.
Workarounds
No response
Anything Else?
No response
References
No response
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: