From e1a63c80f3cf9ec0bc454480c543fb8d59d98d40 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 15 Jun 2016 16:33:27 -0700 Subject: [PATCH] Fix containerds stomping on each other --- os-config.tpl.yml | 1 + trash.conf | 6 +-- .../docker/containerd/subreaper/reaper.go | 6 ++- .../docker/libcontainerd/remote_linux.go | 2 +- .../docker/docker/libcontainerd/rpc_bridge.go | 7 +-- vendor/github.com/docker/docker/trash.conf | 2 +- .../docker-from-scratch/Dockerfile.dapper | 10 +++-- .../rancher/docker-from-scratch/scratch.go | 43 ++++++++++++++++++- 8 files changed, 61 insertions(+), 16 deletions(-) diff --git a/os-config.tpl.yml b/os-config.tpl.yml index 20c6eb96..c19002f6 100644 --- a/os-config.tpl.yml +++ b/os-config.tpl.yml @@ -340,6 +340,7 @@ rancher: exec: true args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -b, docker-sys, --fixed-cidr, 172.18.42.1/16, --restart=false, -g, /var/lib/system-docker, -G, root, + -p, /var/run/system-docker.pid, --exec-root=/var/run/system-docker, --config-file=/etc/docker/system-daemon.json, -H, 'unix:///var/run/system-docker.sock', --userland-proxy=false] upgrade: url: {{.OS_RELEASES_YML}} diff --git a/trash.conf b/trash.conf index 51d510e9..6b68bd8f 100644 --- a/trash.conf +++ b/trash.conf @@ -9,9 +9,9 @@ github.com/coreos/coreos-cloudinit v1.11.0-3-gb1c1753 https://github.com/rancher github.com/coreos/go-systemd v4 github.com/coreos/yaml 6b16a5714269b2f70720a45406b1babd947a17ef github.com/davecgh/go-spew 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d -github.com/docker/containerd 8c538d6b92f2c512c3ad8a854826461ac9095b74 https://github.com/ibuildthecloud/containerd.git +github.com/docker/containerd 1674135d5e32ea16d2ed0967f00325c7276b984b https://github.com/ibuildthecloud/containerd.git github.com/docker/distribution 467fc068d88aa6610691b7f1a677271a3fac4aac -github.com/docker/docker 8ba9ee769ba6c451e1d2abf05368580323201667 https://github.com/rancher/docker.git +github.com/docker/docker c030e8ed127f498be702c331337e87e9525e9f76 https://github.com/rancher/docker.git github.com/docker/engine-api v0.3.3 github.com/docker/go-connections v0.2.0 github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 @@ -33,7 +33,7 @@ github.com/opencontainers/runtime-spec f955d90e70a98ddfb886bd930ffd076da9b67998 github.com/opencontainers/specs f955d90e70a98ddfb886bd930ffd076da9b67998 github.com/packethost/packngo 92012705236896736875186c9e49557897c6af90 https://github.com/ibuildthecloud/packngo.git github.com/pmezard/go-difflib d8ed2627bdf02c080bf22230dbb337003b7aba2d -github.com/rancher/docker-from-scratch 2a4ea96a0a45eac0127049a3a96b60270d0f0a8b +github.com/rancher/docker-from-scratch d0332743084cd128eb8c13b06ef6b85330afc563 github.com/rancher/netconf ddd7e35a6aacd7e80991920774083dd4408ec018 github.com/rcrowley/go-metrics eeba7bd0dd01ace6e690fa833b3f22aaec29af43 github.com/ryanuber/go-glob 0067a9abd927e50aed5190662702f81231413ae0 diff --git a/vendor/github.com/docker/containerd/subreaper/reaper.go b/vendor/github.com/docker/containerd/subreaper/reaper.go index f7932043..0d0a3c38 100644 --- a/vendor/github.com/docker/containerd/subreaper/reaper.go +++ b/vendor/github.com/docker/containerd/subreaper/reaper.go @@ -31,6 +31,7 @@ func (s *Subscription) SetPid(pid int) { s.exit = exit s.wg.Done() Unsubscribe(s) + break } } }() @@ -61,7 +62,10 @@ func Unsubscribe(sub *Subscription) { subLock.Lock() defer subLock.Unlock() - delete(subscriptions, sub.id) + if _, ok := subscriptions[sub.id]; ok { + close(sub.c) + delete(subscriptions, sub.id) + } } func Start() error { diff --git a/vendor/github.com/docker/docker/libcontainerd/remote_linux.go b/vendor/github.com/docker/docker/libcontainerd/remote_linux.go index fa339ce4..c54093e6 100644 --- a/vendor/github.com/docker/docker/libcontainerd/remote_linux.go +++ b/vendor/github.com/docker/docker/libcontainerd/remote_linux.go @@ -225,7 +225,7 @@ func (r *remote) handleEventStream(events containerd.API_EventsClient) { func (r *remote) runContainerdDaemon() error { var err error - r.apiClient, err = newBridge(stateDir, 10, "docker-runc", r.runtimeArgs) + r.apiClient, err = newBridge(r.stateDir, 10, "docker-runc", r.runtimeArgs) return err } diff --git a/vendor/github.com/docker/docker/libcontainerd/rpc_bridge.go b/vendor/github.com/docker/docker/libcontainerd/rpc_bridge.go index d745298a..554143ef 100644 --- a/vendor/github.com/docker/docker/libcontainerd/rpc_bridge.go +++ b/vendor/github.com/docker/docker/libcontainerd/rpc_bridge.go @@ -1,6 +1,7 @@ package libcontainerd import ( + "path/filepath" "sync" "time" @@ -11,10 +12,6 @@ import ( "github.com/docker/containerd/supervisor" ) -var ( - stateDir = "/run/containerd" -) - type bridge struct { s types.APIServer } @@ -31,7 +28,7 @@ func daemon(stateDir string, concurrency int, runtimeName string, runtimeArgs [] if err := subreaper.Start(); err != nil { logrus.WithField("error", err).Error("containerd: start subreaper") } - sv, err := supervisor.New(stateDir, runtimeName, "", runtimeArgs, 15*time.Second, 500) + sv, err := supervisor.New(filepath.Join(stateDir, "containerd"), runtimeName, "", runtimeArgs, 15*time.Second, 500) if err != nil { return nil, err } diff --git a/vendor/github.com/docker/docker/trash.conf b/vendor/github.com/docker/docker/trash.conf index d0387800..784a7ad9 100644 --- a/vendor/github.com/docker/docker/trash.conf +++ b/vendor/github.com/docker/docker/trash.conf @@ -14,7 +14,7 @@ github.com/codegangsta/cli 9fec0fad02befc9209347cc6d620e68e1b45f74d github.com/coreos/etcd v2.2.0 github.com/coreos/go-systemd v4 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d -github.com/docker/containerd 8c538d6b92f2c512c3ad8a854826461ac9095b74 https://github.com/ibuildthecloud/containerd.git +github.com/docker/containerd 1674135d5e32ea16d2ed0967f00325c7276b984b https://github.com/ibuildthecloud/containerd.git github.com/docker/distribution 467fc068d88aa6610691b7f1a677271a3fac4aac github.com/docker/engine-api v0.3.3 github.com/docker/go v1.5.1-1-1-gbaf439e diff --git a/vendor/github.com/rancher/docker-from-scratch/Dockerfile.dapper b/vendor/github.com/rancher/docker-from-scratch/Dockerfile.dapper index 803f74d0..a16b4c26 100644 --- a/vendor/github.com/rancher/docker-from-scratch/Dockerfile.dapper +++ b/vendor/github.com/rancher/docker-from-scratch/Dockerfile.dapper @@ -4,6 +4,9 @@ RUN apt-get update && \ apt-get -y install locales sudo vim less curl wget git rsync build-essential isolinux xorriso gccgo \ libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates pkg-config tox +COPY ./scripts/install-libs.sh /tmp/ +RUN /tmp/install-libs.sh + RUN wget -O - https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz | tar -xz -C /usr/local RUN wget -O /usr/local/bin/docker -L https://get.docker.com/builds/Linux/x86_64/docker-1.10.3 && \ chmod +x /usr/local/bin/docker @@ -26,14 +29,13 @@ RUN wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0 wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0.4.0/base-files_arm.tar.gz && \ wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0.4.0/base-files_arm64.tar.gz -ENV DOCKER_VERSION=1.11.1 DOCKER_PATCH_VERSION=v1.11.1-ros4 +ENV DOCKER_VERSION=1.11.2 DOCKER_PATCH_VERSION=v1.11.2-ros1 +ENV VERSION=v${DOCKER_VERSION} + RUN wget -O docker-${DOCKER_VERSION}_amd64.tgz -L https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz && \ wget -L https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm.tgz && \ wget -L https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm64.tgz WORKDIR ${DAPPER_SOURCE} -COPY ./scripts/install-libs.sh /tmp/ -RUN /tmp/install-libs.sh - CMD ./scripts/ci diff --git a/vendor/github.com/rancher/docker-from-scratch/scratch.go b/vendor/github.com/rancher/docker-from-scratch/scratch.go index 82178fd2..13c1e3ee 100644 --- a/vendor/github.com/rancher/docker-from-scratch/scratch.go +++ b/vendor/github.com/rancher/docker-from-scratch/scratch.go @@ -61,6 +61,7 @@ type Config struct { NoFiles uint64 Environment []string GraphDirectory string + DaemonConfig string } func createMounts(mounts ...[]string) error { @@ -338,7 +339,7 @@ ff02::2 ip6-allrouters } } - if config.BridgeName != "" { + if config.BridgeName != "" && config.BridgeName != "none" { log.Debugf("Creating bridge %s (%s)", config.BridgeName, config.BridgeAddress) if err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{ Interfaces: map[string]netconf.InterfaceConfig{ @@ -364,6 +365,8 @@ func ParseConfig(config *Config, args ...string) []string { config.BridgeAddress = util.GetValue(i, args) } else if strings.HasPrefix(arg, "-b") || strings.HasPrefix(arg, "--bridge") { config.BridgeName = util.GetValue(i, args) + } else if strings.HasPrefix(arg, "--config-file") { + config.DaemonConfig = util.GetValue(i, args) } else if strings.HasPrefix(arg, "--mtu") { mtu, err := strconv.Atoi(util.GetValue(i, args)) if err != nil { @@ -452,6 +455,38 @@ func touchSockets(args ...string) error { return nil } +func createDaemonConfig(config *Config) error { + if config.DaemonConfig == "" { + return nil + } + + if _, err := os.Stat(config.DaemonConfig); os.IsNotExist(err) { + if err := os.MkdirAll(path.Dir(config.DaemonConfig), 0755); err != nil { + return err + } + + return ioutil.WriteFile(config.DaemonConfig, []byte("{}"), 0600) + } + + return nil +} + +func cleanupFiles(graphDirectory string) { + zeroFiles := []string{ + "/etc/docker/key.json", + path.Join(graphDirectory, "image/overlay/repositories.json"), + } + + for _, file := range zeroFiles { + if stat, err := os.Stat(file); err == nil { + if stat.Size() < 2 { + log.Warnf("Deleting invalid json file: %s", file) + os.Remove(file) + } + } + } +} + func createLayout(config *Config) error { if err := createDirs("/tmp", "/root/.ssh", "/var", "/usr/lib"); err != nil { return err @@ -467,6 +502,12 @@ func createLayout(config *Config) error { return err } + if err := createDaemonConfig(config); err != nil { + return err + } + + cleanupFiles(graphDirectory) + selinux.SetFileContext(graphDirectory, "system_u:object_r:var_lib_t:s0") return CreateSymlinks([][]string{