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

fix(appbuilder): Prevent parallel build processes on the same template #6172

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

mbfreder
Copy link
Contributor

@mbfreder mbfreder commented Dec 6, 2024

Context

We currently allow multiple build processes to run at the same time for the same template.

Problem

When running a build, it’s possible to start a second build for the same project. This results in both builds failings

Solution

Prevent parallel builds on the same template


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.

License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mbfreder mbfreder requested a review from a team as a code owner December 6, 2024 16:57
@mbfreder mbfreder changed the title fix(appBuilder): Prevent parallel build processes on the same template fix(appbuilder): Prevent parallel build processes on the same template Dec 6, 2024
@mbfreder mbfreder force-pushed the parallel-build branch 2 times, most recently from 654bf52 to 3471429 Compare December 10, 2024 04:52
Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

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

Left few comments, thanks for implementing these changes!

- updated test with a small delay to avoid possible race condition and test flakiness
@mbfreder mbfreder requested a review from roger-zhangg January 23, 2025 18:16
Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all the feedback, LGTM

@mbfreder mbfreder requested a review from jpinkney-aws January 25, 2025 03:25

export async function registerTemplateBuild(templatePath: string) {
const expirationDate = Date.now() + 5 * 60 * 1000 // five minutes
await updateRecentResponse(buildProcessMementoRootKey, globalIdentifier, templatePath, expirationDate.toString())
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if a build takes longer than 5 minutes? Customer feedback shows that builds can be very, very slow. If the user Cancels the build is that correctly handled?

}
}

export async function registerTemplateBuild(templatePath: string) {
Copy link
Contributor

@justinmk3 justinmk3 Jan 26, 2025

Choose a reason for hiding this comment

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

"registering" is usually a sign of a design flaw. registries require lifecycle management, and can get "corrupted" by logic bugs (like any "cache" in general).

Is there instead a way we can check SAM CLI's state (e.g. in the .sam-... directory) to see if it's currently building something? Or a way to run sam ... and it will tell us if a build is in-progress? Calculating answers (querying) is much more reliable and robust than storing flags and cleaning up state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently can't check sam cli state in the toolkit. I think this is the best we can do right now, until we find a solution in SAM CLI.

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.

5 participants