You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the project works very well for creating runners with platforms like EC2, adding a new platform can be complicated due to the initial approach of how the project was developed.
Use Case
Add different types of platforms that allow us to reduce costs and execution times such as: AWS Fargate (Spot), AWS Lambda, etc.
Suggest a Fix
To ensure that the project support multiple types of platforms we have to refactor some parts of the code, this is a small analysis of what we have to update:
Possible conflicts with interfaces
This is a list of the data types that we need to update or standardize in order to support different types of platforms.
export type RunnerType = 'Org' | 'Repo';
We will need an interface similar to this one (RunnerType) to define the type of runners we are going to support. A name like RunnerInstanceType could be a good option, but this might create conflicts with the type of EC2 instances. Therefore, a more appropriate name could be RunnerPlatformType. This would look something like:
exporttypeRunnerPlatformType='EC2'|'Fargate';
export interface ListRunnerFilters {}
We need to add a new attribute to the interface because the way of listing/filtering EC2 instances is different for Fargate type instances.
This interface is used in the CreateEC2RunnerConfig interface, and it seems to be duplicating some attributes like:
environment
subnets
launchTemplateName
ec2instanceCriteria
numberOfRunners
amiIdSsmParameterName
tracingEnabled
onDemandFailoverOnError
If we modify the RunnerInputParameters interface as a generic interface, we can use it to create interfaces for each type of runner (EC2, Fargate, etc.) that we need to configure. The following diagram shows the current state:
Proposal
The proposal would be to modify the RunnerInputParameters interface with parameters that are used by all runners and create a specific interface for each type of runner (EC2, Fargate, etc.).
This is a list of the functions that need to be updated to add support for Fargate instances.
export async function listEC2Runners() {} runners.ts
We need to rename the function listEC2Runners to something like listRunners(). This function receives an object of type ListRunnerFilters. This interface has already been modified to support instances of different types (EC2, Fargate).
export async function createRunner() {} runners.ts
We will need to update this function. To avoid a major refactoring, we can change the data type of runnerParameters so that it can receive an object of type EC2 or Fargate, something like:
If we keep the function createRunner() with the same name, we'll probably need to rename this function to something like createEC2Instances(). This way, we can have a function to separate the logic of creating different types of instances (EC2, Fargate), something like:
export async function terminateRunner() {} runners.ts
I don't see the need to rename the function, but we should add an attribute to identify how the runner will be deleted, in case it's an EC2 or Fargate runner, something like:
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs. Thank you for your contributions.
Overview
Currently the project works very well for creating runners with platforms like EC2, adding a new platform can be complicated due to the initial approach of how the project was developed.
Use Case
Add different types of platforms that allow us to reduce costs and execution times such as: AWS Fargate (Spot), AWS Lambda, etc.
Suggest a Fix
To ensure that the project support multiple types of platforms we have to refactor some parts of the code, this is a small analysis of what we have to update:
Possible conflicts with interfaces
This is a list of the data types that we need to update or standardize in order to support different types of platforms.
export type RunnerType = 'Org' | 'Repo';
We will need an interface similar to this one (RunnerType) to define the type of runners we are going to support. A name like
RunnerInstanceType
could be a good option, but this might create conflicts with the type of EC2 instances. Therefore, a more appropriate name could beRunnerPlatformType
. This would look something like:export interface ListRunnerFilters {}
We need to add a new attribute to the interface because the way of listing/filtering EC2 instances is different for Fargate type instances.
export interface ListRunnerFilters { runnerType?: RunnerType; + runnerPlatformType?: RunnerPlatformType; runnerOwner?: string; environment?: string; statuses?: string[]; }
export interface RunnerInputParameters {...}
This interface is used in the
CreateEC2RunnerConfig
interface, and it seems to be duplicating some attributes like:environment
subnets
launchTemplateName
ec2instanceCriteria
numberOfRunners
amiIdSsmParameterName
tracingEnabled
onDemandFailoverOnError
If we modify the
RunnerInputParameters
interface as a generic interface, we can use it to create interfaces for each type of runner (EC2, Fargate, etc.) that we need to configure. The following diagram shows the current state:Proposal
The proposal would be to modify the
RunnerInputParameters
interface with parameters that are used by all runners and create a specific interface for each type of runner (EC2, Fargate, etc.).Code example:
EC2
Fargate
Probable functions conflicts
This is a list of the functions that need to be updated to add support for Fargate instances.
export async function listEC2Runners() {}
runners.ts
We need to rename the function listEC2Runners to something like
listRunners()
. This function receives an object of typeListRunnerFilters
. This interface has already been modified to support instances of different types (EC2, Fargate).export async function createRunner() {}
runners.ts
We will need to update this function. To avoid a major refactoring, we can change the data type of
runnerParameters
so that it can receive an object of type EC2 or Fargate, something like:I'm not sure if this complicates things, but the other option is to create a function for each type of instance, something like:
async function createInstances() {}
runners.ts
If we keep the function
createRunner()
with the same name, we'll probably need to rename this function to something likecreateEC2Instances()
. This way, we can have a function to separate the logic of creating different types of instances (EC2, Fargate), something like:export async function terminateRunner() {}
runners.ts
I don't see the need to rename the function, but we should add an attribute to identify how the runner will be deleted, in case it's an EC2 or Fargate runner, something like:
The text was updated successfully, but these errors were encountered: