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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Dec 13, 2020

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
Copy link
Contributor Author

nh2 commented Dec 13, 2020

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.

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 nh2 force-pushed the fix-allow-recreate-on-spot-instances branch from bbe427b to 085c7a2 Compare December 13, 2020 01:26
@nh2 nh2 changed the title ec2: Fix --allow-recreate not recreating terminate spot instances. ec2: Fix --allow-recreate not recreating terminated spot instances Dec 13, 2020
@tewfik-ghariani
Copy link
Contributor

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants