Skip to content

feat(codebuild): attribute-based compute type for Fleet#32251

Merged
mergify[bot] merged 34 commits intoaws:mainfrom
badmintoncryer:compute-config
Feb 6, 2025
Merged

feat(codebuild): attribute-based compute type for Fleet#32251
mergify[bot] merged 34 commits intoaws:mainfrom
badmintoncryer:compute-config

Conversation

@badmintoncryer
Copy link
Copy Markdown
Contributor

Issue # (if applicable)

None

Reason for this change

AWS Codebuild supports for creating Fleet with attribute based compute type.
https://docs.aws.amazon.com/codebuild/latest/userguide/fleets.html#fleets.attribute-compute

You can specify minimum vCPU, disk and memory sizes. Codebuild automatically selects the instance type based on the compute configuration.

Description of changes

Add computeConfiguraion prop to FleetProps.

Description of how you validated changes

Add both unit and integ tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Nov 22, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team November 22, 2024 13:30
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Nov 22, 2024
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@badmintoncryer badmintoncryer marked this pull request as ready for review November 22, 2024 13:41
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 22, 2024 13:43

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (29a9a6d) to head (350b159).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32251   +/-   ##
=======================================
  Coverage   80.83%   80.83%           
=======================================
  Files         236      236           
  Lines       14253    14253           
  Branches     2490     2490           
=======================================
  Hits        11522    11522           
  Misses       2446     2446           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.57% <ø> (ø)
packages/aws-cdk-lib/core 82.20% <ø> (ø)

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 22, 2024
@badmintoncryer
Copy link
Copy Markdown
Contributor Author

CodeQL job has failed, but this is caused by automatically generated test code and I think this is not a problem.

@nmussy
Copy link
Copy Markdown
Contributor

nmussy commented Dec 19, 2024

I swear I searched for issues and PRs before starting #32574 🤦 I'll close mine and give yours a review today

Copy link
Copy Markdown
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick first look by comparing our implementations, I'll try again with a more neutral outlook later. Thanks!

Comment on lines +225 to +228
disk: props.computeConfiguration.disk?.toGibibytes(),
machineType: props.computeConfiguration.machineType,
memory: props.computeConfiguration.memory?.toGibibytes(),
vCpu: props.computeConfiguration.vCpu,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite what the CloudFormation documentation says, the numeric props are not optional, see https://github.com/nmussy/aws-cdk/blob/6120d8f54103f81c4ec601221c1f56e5a4549236/packages/%40aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-fleet-attribute-based-compute.ts#L67-L73

Could you give them a default value, like this for example, and add an integ with just { machineType: GENERAL }?

throw new Error('baseCapacity must be greater than or equal to 1');
}

if (props.computeConfiguration) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had this validation to make sure the user saw how ATTRIBUTE_BASED_COMPUTE worked, leaving it up to you if you want to add it as well:

Suggested change
if (props.computeConfiguration) {
if (props.computeType === FleetComputeType.ATTRIBUTE_BASED &&
(!props.computeConfiguration || Object.keys(props.computeConfiguration).length === 0)) {
throw new Error('At least one compute configuration criteria must be specified if computeType is "ATTRIBUTE_BASED"');
}
if (props.computeConfiguration) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing a getter for the fromFleetArn Import class:

public get computeConfiguration(): FleetComputeConfiguration | undefined {
  throw new Error('Cannot retrieve computeConfiguration property from an imported Fleet');
}

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 19, 2024
GavinZZ
GavinZZ previously approved these changes Feb 5, 2025
Copy link
Copy Markdown
Member

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you as always!

Comment on lines +59 to +65
const listFleets = test.assertions.awsApiCall('Codebuild', 'listFleets');
for (const { fleet, project } of stacks) {
listFleets.expect(integ.ExpectedResult.objectLike({
fleets: integ.Match.arrayWith([fleet.fleetArn]),
}));

const startBuild = test.assertions.awsApiCall('Codebuild', 'startBuild', { projectName: project.projectName });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice assertions!

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot dismissed GavinZZ’s stale review February 5, 2025 19:14

Pull request has been modified.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 5, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mrgrain
Copy link
Copy Markdown
Contributor

mrgrain commented Feb 6, 2025

@Mergifyio dequeue

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

This pull request has been removed from the queue for the following reason: pull request dequeued.

Pull request #32251 has been dequeued by a dequeue command

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

dequeue

✅ The pull request has been removed from the queue default-squash

@mrgrain
Copy link
Copy Markdown
Contributor

mrgrain commented Feb 6, 2025

@Mergifyio dequeue

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

dequeue

☑️ The pull request is not queued

@mrgrain
Copy link
Copy Markdown
Contributor

mrgrain commented Feb 6, 2025

@Mergifyio requeue

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

requeue

✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 350b159
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 6, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 9fd62cb into aws:main Feb 6, 2025
19 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants