nixops-aws icon indicating copy to clipboard operation
nixops-aws copied to clipboard

ec2: Fix --allow-recreate not recreating terminated spot instances

Open nh2 opened this issue 5 years ago • 2 comments

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.

nh2 avatar Dec 13 '20 01:12 nh2

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.

nh2 avatar Dec 13 '20 01:12 nh2

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'

tewfik-ghariani avatar Dec 23 '20 12:12 tewfik-ghariani