summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-04-14 15:55:09 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-04-14 16:51:13 -0400
commit855a5a89dd24e9ef5527a34b14ef0d37cd039a26 (patch)
tree86b4870d4c4967b4dfbb3329e1b09fedae257e14 /pkg/bindings
parent9f36efda372bec12abb60523b787730ffb98c3a2 (diff)
downloadpodman-855a5a89dd24e9ef5527a34b14ef0d37cd039a26.tar.gz
podman-855a5a89dd24e9ef5527a34b14ef0d37cd039a26.tar.bz2
podman-855a5a89dd24e9ef5527a34b14ef0d37cd039a26.zip
Fix flake on failed podman-remote build : try 2
This time we are checking if the function actually succeeded, otherwise we will report an error. Also if we did not get the id, report unexpected failure. [NO TESTS NEEDED] Still no good way to test this, but manually. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/images/build.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 34d6cee05..c0e5706a5 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -340,6 +340,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
re := regexp.MustCompile(`[0-9a-f]{12}`)
var id string
+ var mErr error
for {
var s struct {
Stream string `json:"stream,omitempty"`
@@ -347,11 +348,21 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
}
if err := dec.Decode(&s); err != nil {
if errors.Is(err, io.EOF) {
- return &entities.BuildReport{ID: id}, nil
+ if mErr == nil && id == "" {
+ mErr = errors.New("stream dropped, unexpected failure")
+ }
+ break
}
s.Error = err.Error() + "\n"
}
+ select {
+ case <-response.Request.Context().Done():
+ return &entities.BuildReport{ID: id}, mErr
+ default:
+ // non-blocking select
+ }
+
switch {
case s.Stream != "":
stdout.Write([]byte(s.Stream))
@@ -359,11 +370,12 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
id = strings.TrimSuffix(s.Stream, "\n")
}
case s.Error != "":
- return nil, errors.New(s.Error)
+ mErr = errors.New(s.Error)
default:
return &entities.BuildReport{ID: id}, errors.New("failed to parse build results stream, unexpected input")
}
}
+ return &entities.BuildReport{ID: id}, mErr
}
func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {