From 0dc784dfa27bae78b725ddcf95d67deed906474e Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 26 Oct 2026 00:01:54 -0400 Subject: [PATCH] fix(builder): use a local node-agent image when it can't be pulled Co-Authored-By: Claude Opus 5.5 --- cmd/gbrgames/agentboot.go | 14 ++++++++++++++ cmd/gbrgames/build.go | 4 ++-- cmd/gbrgames/firstboot.go | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/gbrgames/agentboot.go b/cmd/gbrgames/agentboot.go index 3e4dbff..d145077 100644 --- a/cmd/gbrgames/agentboot.go +++ b/cmd/gbrgames/agentboot.go @@ -21,6 +21,20 @@ func agentImageFromEnv() string { return defaultAgentImage } +// pullAgentImage fetches the latest node-agent image. A copy that is only local (a test build) is used as +// it is. +func pullAgentImage(img string) error { + out, err := runCmd("docker", "pull", "-q", img) + if err == nil { + return nil + } + if _, inspectErr := runCmd("docker", "image", "inspect", img); inspectErr == nil { + fmt.Printf("[agent] could not pull %s (%s); using the local copy\n", img, firstLine(out)) + return nil + } + return fmt.Errorf("docker pull %s: %v: %s", img, err, out) +} + // runAgentBootTest deploys a payload with BootTest and returns its output; passed is its verdict. func runAgentBootTest(payload map[string]any, agentImage string) (output string, passed bool, err error) { container := fmt.Sprint(payload["containerName"]) diff --git a/cmd/gbrgames/build.go b/cmd/gbrgames/build.go index e4a07d6..e4f48b8 100644 --- a/cmd/gbrgames/build.go +++ b/cmd/gbrgames/build.go @@ -255,8 +255,8 @@ func firstBoot(name, image, steamApp string, steam bool, startup string) (*bootR // bootCheck deploys the template with the node-agent's BootTest, the same check CI runs, and when the // game wrote files outside its volume on the first boot, boots it once more to see that it no longer does. func bootCheck(gamesDir, id, agentImage string, wantOutside bool) (problems, verified []string, err error) { - if out, err := runCmd("docker", "pull", "-q", agentImage); err != nil { - return nil, nil, fmt.Errorf("docker pull %s: %v: %s", agentImage, err, out) + if err := pullAgentImage(agentImage); err != nil { + return nil, nil, err } output, passed, problems, err := agentBoot(gamesDir, id, agentImage, false) if err != nil || problems != nil { diff --git a/cmd/gbrgames/firstboot.go b/cmd/gbrgames/firstboot.go index 1b33b04..cc80955 100644 --- a/cmd/gbrgames/firstboot.go +++ b/cmd/gbrgames/firstboot.go @@ -146,8 +146,8 @@ func runFirstBoot(args []string) error { return err } } - if out, err := runCmd("docker", "pull", "-q", b.agentImage); err != nil { - return fmt.Errorf("docker pull %s: %v: %s", b.agentImage, err, out) + if err := pullAgentImage(b.agentImage); err != nil { + return err } if !*keep { defer b.cleanup()