Skip to content

Conversation

@disintegrator
Copy link
Contributor

@disintegrator disintegrator commented Nov 5, 2025

This change implements a new temporal workflow that will reap unused fly.io machines. It is triggered as a child workflow every time a deployment is processed (the parent workflow). The child workflow is invoked with a given project id and it will reap all fly machines provisioned in old deployments leaving only machines in the 3 most recent deployments.

The goal is to keep fly.io machines, a capped resource, in check as more users play with Gram Functions.

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2025

⚠️ No Changeset found

Latest commit: 06a6177

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
gram Ready Ready Preview Comment Nov 11, 2025 11:12pm
gram-docs-redirect Ready Ready Preview Comment Nov 11, 2025 11:12pm
gram-landing-redirect Ready Ready Preview Comment Nov 11, 2025 11:12pm

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Squawk Report

✅ 0 violations across 1 file(s)


server/migrations/20251111180235_fly-apps-reap-state.sql

-- atlas:txmode none

-- Drop index "fly_apps_project_deployment_function_key" from table: "fly_apps"
DROP INDEX CONCURRENTLY "fly_apps_project_deployment_function_key";
-- Modify "fly_apps" table
ALTER TABLE "fly_apps" ADD COLUMN "reap_error" text NULL;
-- Create index "fly_apps_project_deployment_function_active_key" to table: "fly_apps"
CREATE UNIQUE INDEX CONCURRENTLY "fly_apps_project_deployment_function_active_key" ON "fly_apps" ("project_id", "deployment_id", "function_id") WHERE (reaped_at IS NULL);
-- Create index "fly_apps_reaper_idx" to table: "fly_apps"
CREATE INDEX CONCURRENTLY "fly_apps_reaper_idx" ON "fly_apps" ("project_id", "created_at" DESC) WHERE ((status = 'ready'::text) AND (reaped_at IS NULL));

✅ Rule Violations (0)

No violations found.


📚 More info on rules

⚡️ Powered by Squawk (1.6.1), a linter for PostgreSQL, focused on migrations

@disintegrator disintegrator marked this pull request as ready for review November 11, 2025 18:19
@disintegrator disintegrator requested a review from a team as a code owner November 11, 2025 18:19
This change implements a background worker that periodically checks for
and reaps unused Fly.io applications associated with function
deployments that are no longer active. For now, we will retain all apps
created in the past 3 deployments of every Gram project.
- schema: schema.sql
queries: ../internal/functions/queries.sql
engine: postgresql
database:
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this for?

TaskQueue: string(TaskQueueMain),
WorkflowIDConflictPolicy: enums.WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING,
WorkflowIDReusePolicy: enums.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE,
WorkflowRunTimeout: time.Minute * 2,
Copy link
Contributor

@ryan-timothy-albert ryan-timothy-albert Nov 11, 2025

Choose a reason for hiding this comment

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

If activity timeout StartToClose is 5 min. This needs to be 5 min * the number of retries.

Maybe lower the activity StartToClose timeout and set this accordingly. Or set a ScheduleToClose

@disintegrator disintegrator merged commit 9c9a9ee into main Nov 11, 2025
17 checks passed
@disintegrator disintegrator deleted the function-reaper branch November 11, 2025 23:21
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants