summaryrefslogtreecommitdiff
path: root/pkg/bindings/connection.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-07-26 11:55:33 +0200
committerValentin Rothberg <rothberg@redhat.com>2021-07-28 14:46:15 +0200
commit4df6e31ccbad8dd7800e413a0377fa0d1a0774ce (patch)
tree4b81a37fa61e156d871d98f6874d2afe0ba1ab19 /pkg/bindings/connection.go
parenta5de8314188d7376f645d8ac6c6f7a6f685b6a45 (diff)
downloadpodman-4df6e31ccbad8dd7800e413a0377fa0d1a0774ce.tar.gz
podman-4df6e31ccbad8dd7800e413a0377fa0d1a0774ce.tar.bz2
podman-4df6e31ccbad8dd7800e413a0377fa0d1a0774ce.zip
remote build: fix streaming and error handling
Address a number of issues in the streaming logic in remote build, most importantly an error in using buffered channels on the server side. The pattern below does not guarantee that the channel is entirely read before the context fires. for { select { case <- bufferedChannel: ... case <- ctx.Done(): ... } } Fixes: #10154 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/bindings/connection.go')
-rw-r--r--pkg/bindings/connection.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index fd93c5ac7..62b1655ac 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -327,7 +327,7 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string,
uri := fmt.Sprintf("http://d/v%d.%d.%d/libpod"+endpoint, params...)
logrus.Debugf("DoRequest Method: %s URI: %v", httpMethod, uri)
- req, err := http.NewRequest(httpMethod, uri, httpBody)
+ req, err := http.NewRequestWithContext(context.WithValue(context.Background(), clientKey, c), httpMethod, uri, httpBody)
if err != nil {
return nil, err
}
@@ -337,7 +337,6 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string,
for key, val := range header {
req.Header.Set(key, val)
}
- req = req.WithContext(context.WithValue(context.Background(), clientKey, c))
// Give the Do three chances in the case of a comm/service hiccup
for i := 0; i < 3; i++ {
response, err = c.Client.Do(req) // nolint