SHA256
1
0
forked from pool/docker
docker/fix_json_econnreset_bug.patch
2016-01-28 08:07:07 +00:00

137 lines
5.4 KiB
Diff

commit 7b5896702bd2951541af27925620172edb5d3505
Author: Michael Crosby <crosbymichael@gmail.com>
Date: Tue Jan 26 15:00:07 2016 -0800
Update libcontainer to 3d8a20bb772defc28c355534d83
Fixes #14203
This bump fixes the issue of having the container's pipes connection
reset by peer because of using the json.Encoder and having a \n added to
the output.
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Index: docker-1.9.1/hack/vendor.sh
===================================================================
--- docker-1.9.1.orig/hack/vendor.sh
+++ docker-1.9.1/hack/vendor.sh
@@ -48,7 +48,7 @@ clone git github.com/agl/ed25519 d2b94fd
# this runc commit from branch relabel_fix_docker_1.9.1, pls remove it when you
# update next time
-clone git github.com/opencontainers/runc 1349b37bd56f4f5ce2690b5b2c0f53f88a261c67 # libcontainer
+clone git github.com/opencontainers/runc 3d8a20bb772defc28c355534d83486416d1719b4 # libcontainer
# libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json)
clone git github.com/coreos/go-systemd v3
clone git github.com/godbus/dbus v2
Index: docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/container_linux.go
===================================================================
--- docker-1.9.1.orig/vendor/src/github.com/opencontainers/runc/libcontainer/container_linux.go
+++ docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/container_linux.go
@@ -18,6 +18,7 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/criurpc"
+ "github.com/opencontainers/runc/libcontainer/utils"
)
const stdioFdCount = 3
@@ -863,7 +864,7 @@ func (c *linuxContainer) updateState(pro
}
defer f.Close()
os.Remove(filepath.Join(c.root, "checkpoint"))
- return json.NewEncoder(f).Encode(state)
+ return utils.WriteJSON(f, state)
}
func (c *linuxContainer) currentStatus() (Status, error) {
Index: docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/factory_linux.go
===================================================================
--- docker-1.9.1.orig/vendor/src/github.com/opencontainers/runc/libcontainer/factory_linux.go
+++ docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/factory_linux.go
@@ -5,7 +5,6 @@ package libcontainer
import (
"encoding/json"
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -19,6 +18,7 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/configs/validate"
+ "github.com/opencontainers/runc/libcontainer/utils"
)
const (
@@ -225,10 +225,7 @@ func (l *LinuxFactory) StartInitializati
// if we have an error during the initialization of the container's init then send it back to the
// parent process in the form of an initError.
if err != nil {
- // ensure that any data sent from the parent is consumed so it doesn't
- // receive ECONNRESET when the child writes to the pipe.
- ioutil.ReadAll(pipe)
- if err := json.NewEncoder(pipe).Encode(newSystemError(err)); err != nil {
+ if err := utils.WriteJSON(pipe, newSystemError(err)); err != nil {
panic(err)
}
}
Index: docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/process_linux.go
===================================================================
--- docker-1.9.1.orig/vendor/src/github.com/opencontainers/runc/libcontainer/process_linux.go
+++ docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/process_linux.go
@@ -15,6 +15,7 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/system"
+ "github.com/opencontainers/runc/libcontainer/utils"
)
type parentProcess interface {
@@ -71,7 +72,7 @@ func (p *setnsProcess) start() (err erro
return newSystemError(err)
}
}
- if err := json.NewEncoder(p.parentPipe).Encode(p.config); err != nil {
+ if err := utils.WriteJSON(p.parentPipe, p.config); err != nil {
return newSystemError(err)
}
if err := syscall.Shutdown(int(p.parentPipe.Fd()), syscall.SHUT_WR); err != nil {
@@ -262,7 +263,7 @@ func (p *initProcess) startTime() (strin
func (p *initProcess) sendConfig() error {
// send the state to the container's init process then shutdown writes for the parent
- if err := json.NewEncoder(p.parentPipe).Encode(p.config); err != nil {
+ if err := utils.WriteJSON(p.parentPipe, p.config); err != nil {
return err
}
// shutdown writes for the parent side of the pipe
Index: docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/utils/utils.go
===================================================================
--- docker-1.9.1.orig/vendor/src/github.com/opencontainers/runc/libcontainer/utils/utils.go
+++ docker-1.9.1/vendor/src/github.com/opencontainers/runc/libcontainer/utils/utils.go
@@ -3,6 +3,7 @@ package utils
import (
"crypto/rand"
"encoding/hex"
+ "encoding/json"
"io"
"path/filepath"
"syscall"
@@ -43,3 +44,13 @@ func ExitStatus(status syscall.WaitStatu
}
return status.ExitStatus()
}
+
+// WriteJSON writes the provided struct v to w using standard json marshaling
+func WriteJSON(w io.Writer, v interface{}) error {
+ data, err := json.Marshal(v)
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(data)
+ return err
+}