Skip to content
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

Building Amazon Linux RPMs and a Windows executable #4220

Merged
merged 27 commits into from
Jul 2, 2024

Conversation

Ephylouise
Copy link
Contributor

Summary

The following changes were made to ensure that the project can build all necessary artifacts before deprecating a legacy component. It specifically modifies the buildspecs to include build capabilities for the full ECS-init RPM/DEB package as well as a Windows executable file. This will ensure that all required images are created during the Agent build process.

The goal is to have the artifacts built from CodeBuild jobs, which run the project's buildspecs, to be used in testing. Providing updates to the buildspecs and minor adjustments to the Makefile will enable CloudFormation and CodeBuild configurations that produce the full package of images in the development artifacts bucket.

Implementation details

A new make target called amazon-linux-rpm-codebuild was created. It uses similar logic as the amazon-linux-rpm-integrated target, but with minor changes to accommodate the CodeBuild build process. To avoid altering the integrated target, which can be used in Koji builds, the new target was created. The new target is called in the build specifications along with the Windows executable file, which relies on the docker-release target.

A new file was added, called pr-build-amzn.yml to accommodate the dependencies of the Amazon Linux builds. Amazon Linux 2, for example uses package manager yum, while Amazon Linux 2023 uses package manager dnf which are used to install Go, as required versions do not come preinstalled. Combining the Amazon Linux 2023 script with the pr-build.yml was considered, but that would result in a complex artifact build script that would be difficult to maintain and debug if issues arise. To keep the code clean and decoupled, the Amazon Linux RPMs (AL2 amd, AL2 arm, AL23 amd, AL23 arm) are all addressed in the new file.

Files changed:

  • Makefile
    • Added a new make target amazon-linux-rpm-codebuild
  • pr-build-ubuntu.yml
    • Modified the forked testing path adjustment if/then statement to [single brackets] instead of [[double]], which was breaking the build due to the Ubuntu platform syntax expectations
  • pr-build.yml
    • Removed a duplicate command to return go version (left one in the install stage)
    • Added WINDOW_EXE path assignment
    • Add make docker-release TARGET_OS="windows" to build amazon-ecs-agent.exe
    • Moved the windows artifact to the current directory
    • Moved the list command from before the renaming function to after it
    • Added windows artifact to files section to be stored in S3
  • pr-build-amzn.yml
    • A new buildspecs file specifically to handle Amazon Linux OS within CodeBuild builds.
    • Assigns AL version and CB image variables
    • Add function to determine the Go installation process depending on OS image and version
    • Add make amazon-linux-rpm-integrated to build AL rpms
    • Rename rpm based on architecture
    • Add RPM and Build Log to artifacts files

Building the Amazon Linux RPMs will require 4 new CodeBuild (CB) projects, one for each Amazon Linux variant and architecture combination. This is due to the build process used to create the artifacts stored in the S3 bucket, as the Amazon Linux builds require separate image configurations.

  • The existing Agent build process utilizes 4 CB projects that run on different images:
    • agent-dev-amd (amazonlinux2-x86_64-standard:5.0)
    • agent-dev-arm (amazonlinux2-aarch64-standard:3.0)
    • agent-dev-ubuntu-amd (Linux EC2 with external docker registry)
    • agent-dev-ubuntu-arm (ARM with external docker registry)
  • The new CB jobs for the Amazon Linux RPMs will also require their own images, as follows:
    • agent-dev-amzn2-arm (amazonlinux2-aarch64-standard:2.0) - Amazon Linux 2 ARM
    • agent-dev-amzn2-amd (amazonlinux2-x86_64-standard:4.0) - Amazon Linux 2 AMD
    • agent-dev-amzn2023-arm (amazonlinux2-aarch64-standard:3.0) - Amazon-Linux 2023 ARM
    • agent-dev-amzn2023-amd (amazonlinux2-x86_64-standard:5.0) - Amazon-Linux 2023 AMD
  • It's worth noting that while the AL2023 images match the existing dev-amd/dev-arm CB images, they require separate buildspecs files due to differences in dependency handling.

Testing

Testing was performed in a separate AWS account using CodeBuild projects and webhooks to validate the modifications. The existing Agent CodeBuild jobs and the 4 new proposed projects were replicated in the separate account. The result was successful, with the following new artifacts and associated build logs landing in the expected S3 bucket:

  • amazon-ecs-agent.exe
  • amazon-ecs-init-1.82.4-1.amzn2.aarch64.rpm
  • amazon-ecs-init-1.82.4-1.amzn2.x86_64.rpm
  • amazon-ecs-init-1.82.4-1.amzn2023.aarch64.rpm
  • amazon-ecs-init-1.82.4-1.amzn2023.x86_64.rpm
  • Build logs for each new project, named build__.log“

Licensing

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

@Ephylouise Ephylouise requested a review from a team as a code owner June 27, 2024 20:09
@sparrc sparrc added bot/test and removed bot/test labels Jun 27, 2024
Commenting out GOPATH adjustment block

Uncomments GOPATH adjustment, adds symlink
Remove trailing space in original GOPATH if/then function

Update pr-build.yml to modify go path logic

Added an echo to check the github username. Removed the If/then statement that was creating the codebuild failures.

GO path: remove if/then statement
This commit adds forked username to pr-build-ubuntu and echos go version

Comment out golang dependency in ecs-agent.spec
Replace 2 with 2023 for AL name/path

Correct AMZN_LINUX_2023_RPM path (remove 'int')
Add Windows Make target and comment out 'generic' build commands

Fix indentation in amzn2/2023 buildspec files

Add /out/ to Windows path in pr-build.yml

Add line to echo the contents of expected artifact path

Uncomment pr-build/agent.spec blocks, simplify sudo dnf update

Add an 'automatic yes' to the version update pr-build-amzn2023.yml

Edit file artifact variable name in amzn23 spec file
Removed troubleshooting lines that echo patath

Comment out custom Go path
Minor edit to renaming in amzn2 spec, and windows artifact path
Edit syntax for goroot setting in amzn2 buildspec

Edit gorspath in amzn2 buildspec, move .exe artifact in pr-build

Remove the move command for .exe, reorder go path commands AL2

Copy .exe to codebuild dir, remove go path for AL2 arm build

Remove path redirecting for .exe file, add list command for /out/ dir
Retry moving .exe to codebuild dir in pr-build

Edit path adjustment for .exe~~  in pr-build

Cleaning up pr-build.yml
Minor cleanup to minimize changes to files
Add go version logic form pr-build to amzn2 buildspec

Remove default codebuild goroot for amzn2 buildspec
Ad variables and renaming logic to handlle AL2/23 in pr-build-amzn2

Add an echo to find where GO_VERSION is being retreived

Remove else statement to check the if statement installs correct go version

Add logic to retreive AL2023 version

Remove quotes for variable definitions

Move go and AL23 variables to install phase

Remove qtrailing quotation mark for go variable
Edit AL23 package manager update command

Add CB image variables for go installation function

Define variables within build image detecting function

Redefine RPM variable to be flexible enough to only include one in the artifact file section
Changing github username back to aws in preparation for PR
Change name of AL target to match Makefile
Restore order of make targets in pr-build.yml
@Ephylouise
Copy link
Contributor Author

The commit history on this PR #4220 was rather long. I used git rebase to squash several commits and consolidate the PR.

sparrc
sparrc previously approved these changes Jul 1, 2024
buildspecs/pr-build-amzn.yml Outdated Show resolved Hide resolved
buildspecs/pr-build-amzn.yml Show resolved Hide resolved
buildspecs/pr-build-amzn.yml Outdated Show resolved Hide resolved
@Ephylouise Ephylouise merged commit 6d6c9a8 into aws:dev Jul 2, 2024
40 checks passed
Ephylouise added a commit to Ephylouise/amazon-ecs-agent that referenced this pull request Jul 2, 2024
* Remove goenv installed version of go for AL buildspecs

* Add logic to retrieve AL2023 version

* Install go based on AL23 version update

* Use the os-release file to detect Amazon Linux version

* Add AL23 ref doc and install specific go version
Ephylouise added a commit to Ephylouise/amazon-ecs-agent that referenced this pull request Jul 2, 2024
@amogh09 amogh09 mentioned this pull request Jul 8, 2024
jiuchoe4 pushed a commit to saurabhc123/amazon-ecs-agent that referenced this pull request Jul 12, 2024
* Remove goenv installed version of go for AL buildspecs

* Add logic to retrieve AL2023 version

* Install go based on AL23 version update

* Use the os-release file to detect Amazon Linux version

* Add AL23 ref doc and install specific go version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants