refactor(orchestrator): reuse parsed metadata for copy-build SQL output - #3308
Conversation
The -team SQL path re-read metadata.json from the destination with an ad-hoc struct just to extract kernel and firecracker versions. Reuse the metadata already parsed from the source at the start of the copy, introduced in 62add04 ("fix(orchestrator): make copy-build handle filesystem-only snapshots (#3299)"). Deprecated (V1) metadata is stripped to a bare version on deserialize, so its kernel/firecracker versions are no longer available to the SQL path; fail loudly for such builds instead of emitting an env_builds row with empty version strings.
PR SummaryLow Risk Overview Reviewed by Cursor Bugbot for commit dee410a. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Code Review
This pull request removes the logic for reading and decoding metadata.json from GCS or local storage in packages/orchestrator/cmd/copy-build/main.go. However, this change leaves the meta variable undefined, which will result in a compilation error. There are no review comments to evaluate, and thus we have no feedback to provide on the review.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
LGTM — straightforward refactor that removes a redundant metadata re-read and closes a silent-failure gap.
Extended reasoning...
Overview
Single-file change to packages/orchestrator/cmd/copy-build/main.go, an operator-run CLI tool (not a long-running service). It removes the ad-hoc second parse of metadata.json from the destination (used only for the -team SQL-generation path) and instead reuses the metadata.Template already parsed from the source at the top of main() (added in #3299). It also adds an explicit log.Fatalf when kernel/firecracker version fields are empty, instead of silently emitting an env_builds row with blank version strings.
Security risks
None. This tool is invoked manually by operators/CI to copy build artifacts and optionally emit SQL for manual DB seeding; there's no new external input handling, and the SQL is still printed to stdout for a human to run, unchanged from before.
Level of scrutiny
Low-to-moderate is appropriate: it's an internal ops utility, the diff is small and mechanical, and I confirmed the semantics against packages/orchestrator/pkg/template/metadata/template_metadata.go — deserialize() does strip V1/deprecated metadata down to a bare Template{Version: DeprecatedVersion}, so the new empty-version check correctly catches that case and fails loudly rather than emitting bad SQL, matching the PR description. Reusing the source-parsed meta instead of re-reading from the destination is safe here because the destination copy is verified to succeed (via the earlier errgroup.Wait()) before the -team block runs, so source and destination metadata are equivalent by construction.
Other factors
Verified the file still builds (go build ./cmd/copy-build/...) after the import removal. No tests exist for this CLI (consistent with the rest of the file, which was already untested before this PR), and the bug-hunting pass found no issues.
The -team SQL path re-read metadata.json from the destination with an ad-hoc struct just to extract kernel and firecracker versions. Reuse the metadata already parsed from the source at the start of the copy, introduced in 62add04 ("fix(orchestrator): make copy-build handle filesystem-only snapshots (#3299)").
Deprecated (V1) metadata is stripped to a bare version on deserialize, so its kernel/firecracker versions are no longer available to the SQL path; fail loudly for such builds instead of emitting an env_builds row with empty version strings.