fix(builder): use a local node-agent image when it can't be pulled
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04967a8a16
commit
0dc784dfa2
3 files changed
+18
-4
No files matched your search
@@ -21,6 +21,20 @@ func agentImageFromEnv() string {
|
|||||||
return defaultAgentImage
|
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.
|
// 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) {
|
func runAgentBootTest(payload map[string]any, agentImage string) (output string, passed bool, err error) {
|
||||||
container := fmt.Sprint(payload["containerName"])
|
container := fmt.Sprint(payload["containerName"])
|
||||||
|
|||||||
@@ -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
|
// 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.
|
// 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) {
|
func bootCheck(gamesDir, id, agentImage string, wantOutside bool) (problems, verified []string, err error) {
|
||||||
if out, err := runCmd("docker", "pull", "-q", agentImage); err != nil {
|
if err := pullAgentImage(agentImage); err != nil {
|
||||||
return nil, nil, fmt.Errorf("docker pull %s: %v: %s", agentImage, err, out)
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
output, passed, problems, err := agentBoot(gamesDir, id, agentImage, false)
|
output, passed, problems, err := agentBoot(gamesDir, id, agentImage, false)
|
||||||
if err != nil || problems != nil {
|
if err != nil || problems != nil {
|
||||||
|
|||||||
@@ -146,8 +146,8 @@ func runFirstBoot(args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if out, err := runCmd("docker", "pull", "-q", b.agentImage); err != nil {
|
if err := pullAgentImage(b.agentImage); err != nil {
|
||||||
return fmt.Errorf("docker pull %s: %v: %s", b.agentImage, err, out)
|
return err
|
||||||
}
|
}
|
||||||
if !*keep {
|
if !*keep {
|
||||||
defer b.cleanup()
|
defer b.cleanup()
|
||||||
|
|||||||
Reference in new issue
Block a user