Repository navigation
feat: persist synchronously-available layer sizes to env_builds via gRPC #3119
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
Changes from all commits
72dba50
a131641
0cf3173
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package db | ||
|
|
||
| import ( | ||
| "github.com/google/uuid" | ||
|
|
||
| "github.com/e2b-dev/infra/packages/db/queries" | ||
| "github.com/e2b-dev/infra/packages/shared/pkg/grpc/orchestrator" | ||
| ) | ||
|
|
||
| // LayerSizesParams maps the orchestrator's synchronously-available logical layer | ||
| // sizes into params for SetEnvBuildLayerSizes. A zero value maps to NULL (e.g. | ||
| // the memfile logical size is 0 for filesystem-only snapshots). | ||
| func LayerSizesParams(buildID uuid.UUID, ls *orchestrator.LayerSizes) queries.SetEnvBuildLayerSizesParams { | ||
| p := queries.SetEnvBuildLayerSizesParams{BuildID: buildID} | ||
| if ls == nil { | ||
| return p | ||
| } | ||
|
|
||
| p.MemfileLogicalSizeBytes = sizePtr(ls.GetMemfileLogicalSize()) | ||
|
|
||
| return p | ||
| } | ||
|
|
||
| func sizePtr(v uint64) *int64 { | ||
| if v == 0 { | ||
| return nil | ||
| } | ||
|
|
||
| i := int64(v) | ||
|
|
||
| return &i | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- +goose Up | ||
| -- Memfile logical (virtual device) size captured synchronously at snapshot time. | ||
| -- The rootfs logical size is already stored as total_disk_size_mb. Mapped and | ||
| -- diff sizes (for both rootfs and memfile) are kept in the data objects' custom | ||
| -- metadata instead, so each size category lives entirely in one place. | ||
| ALTER TABLE public.env_builds | ||
| ADD COLUMN IF NOT EXISTS memfile_logical_size_bytes bigint; | ||
|
|
||
| -- +goose Down | ||
| ALTER TABLE public.env_builds | ||
| DROP COLUMN IF EXISTS memfile_logical_size_bytes; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -- name: SetEnvBuildLayerSizes :exec | ||
| -- Persists the synchronously-available memfile logical size for a build. Nullable | ||
| -- so a filesystem-only snapshot (no memfile) can be written as NULL. | ||
| UPDATE "public"."env_builds" | ||
| SET memfile_logical_size_bytes = sqlc.narg(memfile_logical_size_bytes) | ||
| WHERE id = @build_id; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layer sizes fail marks build failed
High Severity
SetFinishedrunsFinishTemplateBuildfirst, thenSetEnvBuildLayerSizes. If layer-size persistence fails, the whole call errors even though the build is alreadyuploaded. Poll treats that as unrecoverable and callsSetStatuswith failed, clobbering a successful template build. Pause/checkpoint log layer-size errors and do not fail the operation.Additional Locations (1)
packages/api/internal/template-manager/template_status.go#L123-L133Reviewed by Cursor Bugbot for commit a131641. Configure here.