Skip to content

Commit 18bc87e

Browse files
committed
Wait for built compose images
1 parent 6691a37 commit 18bc87e

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

lib/compose/build.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/json"
1111
"fmt"
1212
"io"
13-
"net/url"
1413
"os"
1514
"path/filepath"
1615
"sort"
@@ -77,19 +76,9 @@ func (r *Runner) planBuild(ctx context.Context, build desiredBuild) (Action, err
7776
return action, nil
7877
}
7978

80-
_, err = r.client.Images.Get(ctx, url.PathEscape(build.Image), r.opts...)
81-
if err == nil {
82-
action.Action = "unchanged"
83-
action.Reason = "image already exists"
84-
action.buildInput.ImageRef = build.Image
85-
return action, nil
86-
}
87-
if isHTTPNotFound(err) {
88-
action.Action = "create"
89-
action.Reason = "image missing"
90-
return action, nil
91-
}
92-
return Action{}, fmt.Errorf("check build image %s: %w", build.Image, err)
79+
action.Action = "create"
80+
action.Reason = "build missing"
81+
return action, nil
9382
}
9483

9584
func (r *Runner) findReadyBuild(ctx context.Context, build desiredBuild) (*hypeman.Build, error) {
@@ -140,7 +129,11 @@ func (r *Runner) runBuild(ctx context.Context, build desiredBuild, verbose bool)
140129
if err != nil {
141130
return "", err
142131
}
143-
return runnableBuildImage(readyBuild), nil
132+
imageRef := runnableBuildImage(readyBuild)
133+
if imageRef == "" {
134+
return "", fmt.Errorf("build %s did not report a runnable image", started.ID)
135+
}
136+
return imageRef, nil
144137
}
145138

146139
func (r *Runner) waitBuildReady(ctx context.Context, buildID string) (*hypeman.Build, error) {

lib/compose/reconcile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func (r *Runner) Up(ctx context.Context, opts UpOptions) (Plan, error) {
114114
if err := updatePlannedInstanceImage(result.Actions, r.spec.Name, action.Service, action.Name); err != nil {
115115
return result, err
116116
}
117+
if err := r.ensureImageReady(ctx, action.Name, opts.Verbose); err != nil {
118+
return result, err
119+
}
117120
}
118121
if action.Type == "image" {
119122
if err := r.ensureImageReady(ctx, action.Name, opts.Verbose); err != nil {
@@ -225,6 +228,9 @@ func (r *Runner) applyCreate(ctx context.Context, action *Action, opts UpOptions
225228
if imageRef != "" {
226229
action.Name = imageRef
227230
}
231+
if err := r.ensureImageReady(ctx, action.Name, opts.Verbose); err != nil {
232+
return err
233+
}
228234
return nil
229235
case "image":
230236
return r.ensureImageReady(ctx, action.Name, opts.Verbose)

0 commit comments

Comments
 (0)