mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #10030 from rhatdan/build
Fix flake on failed podman-remote build
This commit is contained in:
@ -462,12 +462,17 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
buildOptions.Timestamp = &ts
|
buildOptions.Timestamp = &ts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
imageID string
|
||||||
|
failed bool
|
||||||
|
)
|
||||||
|
|
||||||
runCtx, cancel := context.WithCancel(context.Background())
|
runCtx, cancel := context.WithCancel(context.Background())
|
||||||
var imageID string
|
|
||||||
go func() {
|
go func() {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
imageID, _, err = runtime.Build(r.Context(), buildOptions, query.Dockerfile)
|
imageID, _, err = runtime.Build(r.Context(), buildOptions, query.Dockerfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
failed = true
|
||||||
stderr.Write([]byte(err.Error() + "\n"))
|
stderr.Write([]byte(err.Error() + "\n"))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -483,8 +488,6 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
flush()
|
flush()
|
||||||
|
|
||||||
var failed bool
|
|
||||||
|
|
||||||
body := w.(io.Writer)
|
body := w.(io.Writer)
|
||||||
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||||
if v, found := os.LookupEnv("PODMAN_RETAIN_BUILD_ARTIFACT"); found {
|
if v, found := os.LookupEnv("PODMAN_RETAIN_BUILD_ARTIFACT"); found {
|
||||||
@ -525,7 +528,6 @@ loop:
|
|||||||
}
|
}
|
||||||
flush()
|
flush()
|
||||||
case e := <-stderr.Chan():
|
case e := <-stderr.Chan():
|
||||||
failed = true
|
|
||||||
m.Error = string(e)
|
m.Error = string(e)
|
||||||
if err := enc.Encode(m); err != nil {
|
if err := enc.Encode(m); err != nil {
|
||||||
logrus.Warnf("Failed to json encode error %v", err)
|
logrus.Warnf("Failed to json encode error %v", err)
|
||||||
|
Reference in New Issue
Block a user