-
Notifications
You must be signed in to change notification settings - Fork 26
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
Configure agent nodes based on jenkins instance type #513
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,8 @@ export interface CIStackProps extends StackProps { | |
readonly enableViews?: boolean; | ||
/** Use Production Agents */ | ||
readonly useProdAgents?: boolean; | ||
/** Specify jenkins instance type */ | ||
readonly jenkinsType?: string; | ||
} | ||
|
||
function getServerAccess(serverAccessType: string, restrictServerAccessTo: string): IPeer { | ||
|
@@ -113,6 +115,11 @@ export class CIStack extends Stack { | |
useProdAgents = 'false'; | ||
} | ||
|
||
let jenkinsType = `${props?.jenkinsType ?? this.node.tryGetContext('jenkinsType')}`; | ||
if (useProdAgents.toString() === 'true' && jenkinsType.toString() === 'undefined') { | ||
jenkinsType = 'default'; | ||
} | ||
|
||
const serverAccessType = this.node.tryGetContext('serverAccessType'); | ||
const restrictServerAccessTo = this.node.tryGetContext('restrictServerAccessTo'); | ||
const serverAcess = props?.restrictServerAccessTo ?? getServerAccess(serverAccessType, restrictServerAccessTo); | ||
|
@@ -146,34 +153,15 @@ export class CIStack extends Stack { | |
const listenerCertificate = ListenerCertificate.fromArn(certificateArn.secretValue.toString()); | ||
const agentNode = new AgentNodes(this); | ||
|
||
if (useProdAgents.toString() === 'true') { | ||
// eslint-disable-next-line no-console | ||
console.warn('Please note that if you have decided to use the provided production jenkins agents then ' | ||
// eslint-disable-next-line no-console | ||
console.warn('Please note that if you have decided to use the provided production jenkins agents then ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the conditional |
||
+ 'please make sure that you are deploying the stack in US-EAST-1 region as the AMIs used are only publicly ' | ||
+ 'available in US-EAST-1 region. ' | ||
+ 'If you want to deploy the stack in another region then please make sure you copy the public AMIs used ' | ||
+ 'from us-east-1 region to your region of choice and update the ami-id in agent-nodes.ts file accordingly. ' | ||
+ 'If you do not copy the AMI in required region and update the code then the jenkins agents will not spin up.'); | ||
|
||
this.agentNodes = [ | ||
agentNode.AL2023_X64, | ||
agentNode.AL2_X64_DOCKER_HOST, | ||
agentNode.AL2023_X64_DOCKER_HOST, | ||
agentNode.AL2023_ARM64, | ||
agentNode.AL2_ARM64_DOCKER_HOST, | ||
agentNode.AL2023_ARM64_DOCKER_HOST, | ||
agentNode.AL2023_X64_BENCHMARK_TEST, | ||
agentNode.UBUNTU2004_X64_GRADLE_CHECK, | ||
agentNode.UBUNTU2004_X64_DOCKER_BUILDER, | ||
agentNode.MACOS13_X64_MULTI_HOST, | ||
agentNode.MACOS13_ARM64_MULTI_HOST, | ||
agentNode.WINDOWS2019_X64_DOCKER_HOST, | ||
agentNode.WINDOWS2019_X64_DOCKER_BUILDER, | ||
agentNode.WINDOWS2019_X64_GRADLE_CHECK, | ||
]; | ||
} else { | ||
this.agentNodes = [agentNode.AL2_X64_DEFAULT_AGENT, agentNode.AL2_ARM64_DEFAULT_AGENT]; | ||
} | ||
this.agentNodes = agentNode.getRequiredAgentNodes(jenkinsType.toString()); | ||
|
||
const mainJenkinsNode = new JenkinsMainNode(this, { | ||
vpc, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,4 +281,15 @@ export class AgentNodes { | |
remoteFs: '/home/ec2-user', | ||
}; | ||
} | ||
|
||
public getRequiredAgentNodes(type: string): any[] { | ||
return Object.keys(this) | ||
.filter((key) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly we are just checking if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are doing similar thing with jenkinsType variable. The Drawback is agentnodes used by BTR instance cannot be differentiated from their names like we do with benchmark and gradle. We can think of updating agentnodes names used by BTR with a key_name(RELEASE) if it's straightforward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think since we have a defined number of instance type, better have a check, may be enums, to verify if a valid instance type name is passed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Have enums for instance types. Also what is BTR? 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes Sayali |
||
if (type === 'BTR') { | ||
return !key.toLowerCase().includes('default'); | ||
} | ||
return key.toLowerCase().includes(type.toLowerCase()); | ||
}) | ||
.map((key) => (this as any)[key]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
jenkinsDeploymentType
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or jenkinsInstanceType, Which name would you recommend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with both.