A feature request: The possibility to specify secondary instance type in case of "There is no Spot capacity available that matches your request", code: 'InsufficientInstanceCapacity' error.
I think we could have a fallback launch template with another instance type or overwrite InstanceType
in the current launch template in case if AWS answers with 'InsufficientInstanceCapacity' error.
Yes, we had the same issue and our idea was to do the same. Is someone already working on it?
Here is a WIP for this idea - https://github.com/Kostiantyn-Vorobiov/terraform-aws-github-runner/pull/1 (haven't tested in the real environment)
Any thoughts? I'm not a TS guy @gertjanmaas, @npalm
Hi @Kostiantyn-Vorobiov.
I really like the idea. I don't think the implementation will work because we use EC2 Launch Templates. As far as I know the Launch Templates options and the instance type options do not mix in the runInstances
call.
So instead of changing the instance type, we could create a second Launch Template in Terraform and change the launchTemplateName
and launchTemplateVersion
to the secondary template on a InsufficientInstanceCapacity
error. See terraform code here: https://github.com/philips-labs/terraform-aws-github-runner/blob/8ed8a8491298d5023f37b207e432e92129183adc/modules/runners/main.tf#L36
@npalm how does this sound to you?
According to the documentation -
"LaunchTemplate — (map) -
The launch template to use to launch the instances. Any parameters that you specify in RunInstances override the same parameters in the launch template."
So there is a chance that it could work in this way. But the second launch template could also work fine.
Also, there is a more robust solution with spot fleet requests. But that requires a lot of changes.
In that case overwriting should be the way forward
link to docs: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html
@Kostiantyn-Vorobiov feel free to open a draft (WIP) PR
Most helpful comment
According to the documentation -
"LaunchTemplate — (map) -
The launch template to use to launch the instances. Any parameters that you specify in RunInstances override the same parameters in the launch template."
So there is a chance that it could work in this way. But the second launch template could also work fine.
Also, there is a more robust solution with spot fleet requests. But that requires a lot of changes.