nixops-aws
nixops-aws copied to clipboard
ec2: Fix --allow-recreate not recreating terminated spot instances
Until now, nixops deploy --check --allow-recreate would fail to
recreate terminated spot instances, instead emitting the error:
Exception: spot instance request got fulfilled unexpectedly as instance ‘i-0543dd70c68337dea’
This was because _reset_state() did not reset the
self._cached_instance, and so the _get_instance() call in
create_instance() would continue to refer to the ID of the disappeared
instance, eventually producing the error.
Note I wrote and tested this patch for NixOps 1.7, I haven't tested it on nixops-aws yet because I am not using that yet. Please give it a try.
I just tested it after manually cancelling a spot request and terminating the instance but it failed throwing this error
File "/data/home/src/nixops-aws-nh2/nixops_aws/backends/ec2.py", line 1344, in create
self.private_host_key.replace("\n", "|"),
AttributeError: 'NoneType' object has no attribute 'replace'