Ensure build instance replacement on rack version updates#3780
Open
Ensure build instance replacement on rack version updates#3780
Conversation
ntner
added a commit
that referenced
this pull request
Mar 26, 2026
## Summary
- Add `Version` parameter reference to `BuildLaunchTemplate` UserData to guarantee a new LaunchTemplate version is created on every rack update
- Eliminates a race condition where the rack API receives new TLS certificates before the build instance is replaced, causing a `tls: unknown certificate authority` error window during updates
## Background
During a rack version update, self-signed Docker TLS certificates are regenerated by a CloudFormation custom resource Lambda. The rack API ECS tasks restart with the new certificates quickly, but the build EC2 instance replacement depends on CloudFormation detecting a change in the `BuildLaunchTemplate` UserData (via custom resource output propagation). If that propagation chain doesn't produce a detectable change, the ASG rolling update is not triggered, leaving the build instance running with stale certificates.
Even when the rolling update IS triggered, the API tasks can restart with new certificates before the build instance replacement completes, creating a failure window where builds fail with:
```
remote error: tls: unknown certificate authority
```
## Change
One line added to `BuildLaunchTemplate` UserData in `provider/aws/formation/rack.json`:
```json
"# rack-version: ", { "Ref": "Version" }, "\n",
```
This is a cloud-config comment with no effect on instance boot behavior. Because `{ "Ref": "Version" }` resolves to a different value on every rack version update, the UserData content always changes, which forces a new LaunchTemplate version, which triggers the `AutoScalingRollingUpdate` policy on the `BuildInstances` ASG.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Versionparameter reference toBuildLaunchTemplateUserData to guarantee a new LaunchTemplate version is created on every rack updatetls: unknown certificate authorityerror window during updatesBackground
During a rack version update, self-signed Docker TLS certificates are regenerated by a CloudFormation custom resource Lambda. The rack API ECS tasks restart with the new certificates quickly, but the build EC2 instance replacement depends on CloudFormation detecting a change in the
BuildLaunchTemplateUserData (via custom resource output propagation). If that propagation chain doesn't produce a detectable change, the ASG rolling update is not triggered, leaving the build instance running with stale certificates.Even when the rolling update IS triggered, the API tasks can restart with new certificates before the build instance replacement completes, creating a failure window where builds fail with:
Change
One line added to
BuildLaunchTemplateUserData inprovider/aws/formation/rack.json:This is a cloud-config comment with no effect on instance boot behavior. Because
{ "Ref": "Version" }resolves to a different value on every rack version update, the UserData content always changes, which forces a new LaunchTemplate version, which triggers theAutoScalingRollingUpdatepolicy on theBuildInstancesASG.