Using docker-machine to provision a spot instance opens a spot request and waits for it to be fulfilled. If this fails, docker-machine exits but the spot request remains open and may be fulfilled later. This results in a dangling spot request with an active instance.
This seems to happen in many other cases as well.
$ ./docker-machine-setup.sh # Run docker-machine create with spot instance..
Running pre-create checks...
Creating machine...
(aws01) Launching instance...
(aws01) Waiting for spot instance...
^C
[0] ~$ docker-machine rm aws01
About to remove aws01
Are you sure? (y/n): y
Error removing host "aws01": unknown instance
MissingParameter: The request must contain the parameter KeyName
status code: 400, request id:
Similarly if the spot request is canceled in the console. Same thing happens.
Also:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
aws01 - amazonec2 Error Unknown MissingParameter: The request must contain the parameter InstanceId
status code: 400, request id:
It seems like the docker-machine state machine is completely missing a state - the fact that this machine has not been allocated yet?!! Not having allocated a spot instance is not an 'Error' state.
This plagues our CI runners constantly with spot instances.
Same issue here. Someone figured a work-around?
I did a patch for a proper cleanup of dangling resource in case of AWS machine creation failure. #4317
Most helpful comment
This plagues our CI runners constantly with spot instances.