Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ jobs:
# Opt the preview into the in-VPC OTel collector (prd-only otherwise —
# a cash-flow call, see `stageDeploysCollector`).
MAPLE_DEPLOY_AWS_COLLECTOR: ${{ contains(github.event.pull_request.labels.*.name, 'preview:collector') && '1' || '' }}
# Run the preview's gateway on the EC2 fleet (NVMe WAL, host
# networking) instead of Fargate — see `parseIngestFleets`.
MAPLE_INGEST_FLEETS: ${{ contains(github.event.pull_request.labels.*.name, 'preview:ingest-ec2') && 'ec2' || '' }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BRANCH: ${{ github.head_ref }}
# Stamped onto deployed telemetry as `vcs.ref.head.revision`. Use the PR
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"alchemy:deploy": "bun run alchemy:build-deps && alchemy deploy --yes",
"alchemy:deploy:prd": "bun run alchemy:build-deps && alchemy deploy --yes --adopt --stage prd",
"alchemy:deploy:pr": "bun run alchemy:build-deps && alchemy deploy --yes --adopt --stage pr-${PR_NUMBER}",
"alchemy:destroy": "alchemy destroy --yes",
"alchemy:destroy:pr": "alchemy destroy --yes --stage pr-${PR_NUMBER}",
"alchemy:destroy": "bun run alchemy:build-deps && alchemy destroy --yes",
"alchemy:destroy:pr": "bun run alchemy:build-deps && alchemy destroy --yes --stage pr-${PR_NUMBER}",
"test": "turbo test",
"tinybird:manifest": "bun run ./scripts/generate-tinybird-project-manifest.ts",
"tinybird:manifest:check": "bun run ./scripts/generate-tinybird-project-manifest.ts --check",
Expand Down
10 changes: 5 additions & 5 deletions packages/infra/src/aws/stage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ describe("resolveIngestScaling", () => {
})

describe("parseIngestFleets", () => {
it("is Fargate only when unset", () => {
expect(parseIngestFleets(undefined)).toEqual({ fargate: true, ec2: false })
expect(parseIngestFleets("")).toEqual({ fargate: true, ec2: false })
it("is EC2 only when unset", () => {
expect(parseIngestFleets(undefined)).toEqual({ fargate: false, ec2: true })
expect(parseIngestFleets("")).toEqual({ fargate: false, ec2: true })
})

it("runs both fleets during the cutover", () => {
it("can bring Fargate back beside EC2, or alone", () => {
expect(parseIngestFleets("fargate, ec2")).toEqual({ fargate: true, ec2: true })
expect(parseIngestFleets("ec2")).toEqual({ fargate: false, ec2: true })
expect(parseIngestFleets("fargate")).toEqual({ fargate: true, ec2: false })
})

it("rejects a fleet it does not know rather than deploying neither", () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/infra/src/aws/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ export function resolveIngestTaskSize(stage: MapleStage): IngestTaskSize {

/**
* Which fleets run the gateway. Both can run at once, each behind its own ALB,
* which is how the Fargate → EC2 cutover works: bring EC2 up beside Fargate,
* flip the proxied `ingest` CNAME, then drop Fargate.
* which is how a fleet cutover works: bring the new one up beside the old,
* flip the proxied `ingest` CNAME, then drop the old one.
*/
export interface IngestFleets {
fargate: boolean
Expand All @@ -165,14 +165,15 @@ export interface IngestFleets {

/**
* Parses `MAPLE_INGEST_FLEETS` (`fargate`, `ec2`, or `fargate,ec2`). Unset is
* Fargate only, the state before the cutover.
* EC2 only, where prd has run since the 2026-09-21 cutover; the variable is
* only set to bring Fargate back beside it.
*/
export function parseIngestFleets(value: string | undefined): IngestFleets {
const requested = (value ?? "")
.split(",")
.map((fleet) => fleet.trim())
.filter((fleet) => fleet !== "")
if (requested.length === 0) return { fargate: true, ec2: false }
if (requested.length === 0) return { fargate: false, ec2: true }
const unknown = requested.filter((fleet) => fleet !== "fargate" && fleet !== "ec2")
if (unknown.length > 0) {
throw new Error(
Expand Down
13 changes: 8 additions & 5 deletions scripts/ingest-preview-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ set -euo pipefail
: "${PR_NUMBER:?PR_NUMBER is required}"
region="${AWS_REGION:-us-east-1}"
cluster="maple-ingest-pr-${PR_NUMBER}"
# The EC2 fleet (`preview:ingest-ec2`) is its own ECS service beside where
# the Fargate one would be; the job's MAPLE_INGEST_FLEETS says which ran.
if [[ "${MAPLE_INGEST_FLEETS:-}" == "ec2" ]]; then
gateway_service="maple-ingest-ec2-pr-${PR_NUMBER}"
else
# Each fleet is its own ECS service. EC2 is the default (`parseIngestFleets`);
# only a job that set MAPLE_INGEST_FLEETS to Fargate alone runs the other one.
# Same parsing as the deploy: whitespace ignored, comma-separated membership.
fleets=",${MAPLE_INGEST_FLEETS:-},"
fleets="${fleets//[[:space:]]/}"
if [[ "$fleets" == *",fargate,"* && "$fleets" != *",ec2,"* ]]; then
gateway_service="maple-ingest-pr-${PR_NUMBER}"
else
gateway_service="maple-ingest-ec2-pr-${PR_NUMBER}"
fi
collector_service="maple-otel-collector-pr-${PR_NUMBER}"
namespace="maple-ingest-pr-${PR_NUMBER}.internal"
Expand Down
Loading