1
0
mirror of https://github.com/rancher/os.git synced 2025-07-05 11:06:13 +00:00

Fix containerds stomping on each other

This commit is contained in:
Darren Shepherd 2016-06-15 16:33:27 -07:00
parent e98fc80d12
commit e1a63c80f3
8 changed files with 61 additions and 16 deletions

View File

@ -340,6 +340,7 @@ rancher:
exec: true exec: true
args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -b, docker-sys, 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, --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] -H, 'unix:///var/run/system-docker.sock', --userland-proxy=false]
upgrade: upgrade:
url: {{.OS_RELEASES_YML}} url: {{.OS_RELEASES_YML}}

View File

@ -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/go-systemd v4
github.com/coreos/yaml 6b16a5714269b2f70720a45406b1babd947a17ef github.com/coreos/yaml 6b16a5714269b2f70720a45406b1babd947a17ef
github.com/davecgh/go-spew 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d 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/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/engine-api v0.3.3
github.com/docker/go-connections v0.2.0 github.com/docker/go-connections v0.2.0
github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
@ -33,7 +33,7 @@ github.com/opencontainers/runtime-spec f955d90e70a98ddfb886bd930ffd076da9b67998
github.com/opencontainers/specs f955d90e70a98ddfb886bd930ffd076da9b67998 github.com/opencontainers/specs f955d90e70a98ddfb886bd930ffd076da9b67998
github.com/packethost/packngo 92012705236896736875186c9e49557897c6af90 https://github.com/ibuildthecloud/packngo.git github.com/packethost/packngo 92012705236896736875186c9e49557897c6af90 https://github.com/ibuildthecloud/packngo.git
github.com/pmezard/go-difflib d8ed2627bdf02c080bf22230dbb337003b7aba2d 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/rancher/netconf ddd7e35a6aacd7e80991920774083dd4408ec018
github.com/rcrowley/go-metrics eeba7bd0dd01ace6e690fa833b3f22aaec29af43 github.com/rcrowley/go-metrics eeba7bd0dd01ace6e690fa833b3f22aaec29af43
github.com/ryanuber/go-glob 0067a9abd927e50aed5190662702f81231413ae0 github.com/ryanuber/go-glob 0067a9abd927e50aed5190662702f81231413ae0

View File

@ -31,6 +31,7 @@ func (s *Subscription) SetPid(pid int) {
s.exit = exit s.exit = exit
s.wg.Done() s.wg.Done()
Unsubscribe(s) Unsubscribe(s)
break
} }
} }
}() }()
@ -61,7 +62,10 @@ func Unsubscribe(sub *Subscription) {
subLock.Lock() subLock.Lock()
defer subLock.Unlock() defer subLock.Unlock()
delete(subscriptions, sub.id) if _, ok := subscriptions[sub.id]; ok {
close(sub.c)
delete(subscriptions, sub.id)
}
} }
func Start() error { func Start() error {

View File

@ -225,7 +225,7 @@ func (r *remote) handleEventStream(events containerd.API_EventsClient) {
func (r *remote) runContainerdDaemon() error { func (r *remote) runContainerdDaemon() error {
var err 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 return err
} }

View File

@ -1,6 +1,7 @@
package libcontainerd package libcontainerd
import ( import (
"path/filepath"
"sync" "sync"
"time" "time"
@ -11,10 +12,6 @@ import (
"github.com/docker/containerd/supervisor" "github.com/docker/containerd/supervisor"
) )
var (
stateDir = "/run/containerd"
)
type bridge struct { type bridge struct {
s types.APIServer s types.APIServer
} }
@ -31,7 +28,7 @@ func daemon(stateDir string, concurrency int, runtimeName string, runtimeArgs []
if err := subreaper.Start(); err != nil { if err := subreaper.Start(); err != nil {
logrus.WithField("error", err).Error("containerd: start subreaper") 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 { if err != nil {
return nil, err return nil, err
} }

View File

@ -14,7 +14,7 @@ github.com/codegangsta/cli 9fec0fad02befc9209347cc6d620e68e1b45f74d
github.com/coreos/etcd v2.2.0 github.com/coreos/etcd v2.2.0
github.com/coreos/go-systemd v4 github.com/coreos/go-systemd v4
github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d 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/distribution 467fc068d88aa6610691b7f1a677271a3fac4aac
github.com/docker/engine-api v0.3.3 github.com/docker/engine-api v0.3.3
github.com/docker/go v1.5.1-1-1-gbaf439e github.com/docker/go v1.5.1-1-1-gbaf439e

View File

@ -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 \ 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 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 - 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 && \ 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 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_arm.tar.gz && \
wget https://github.com/rancher/docker-from-scratch/releases/download/bin-v0.4.0/base-files_arm64.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 && \ 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}_arm.tgz && \
wget -L https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm64.tgz wget -L https://github.com/rancher/docker/releases/download/${DOCKER_PATCH_VERSION}/docker-${DOCKER_VERSION}_arm64.tgz
WORKDIR ${DAPPER_SOURCE} WORKDIR ${DAPPER_SOURCE}
COPY ./scripts/install-libs.sh /tmp/
RUN /tmp/install-libs.sh
CMD ./scripts/ci CMD ./scripts/ci

View File

@ -61,6 +61,7 @@ type Config struct {
NoFiles uint64 NoFiles uint64
Environment []string Environment []string
GraphDirectory string GraphDirectory string
DaemonConfig string
} }
func createMounts(mounts ...[]string) error { 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) log.Debugf("Creating bridge %s (%s)", config.BridgeName, config.BridgeAddress)
if err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{ if err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{
Interfaces: map[string]netconf.InterfaceConfig{ Interfaces: map[string]netconf.InterfaceConfig{
@ -364,6 +365,8 @@ func ParseConfig(config *Config, args ...string) []string {
config.BridgeAddress = util.GetValue(i, args) config.BridgeAddress = util.GetValue(i, args)
} else if strings.HasPrefix(arg, "-b") || strings.HasPrefix(arg, "--bridge") { } else if strings.HasPrefix(arg, "-b") || strings.HasPrefix(arg, "--bridge") {
config.BridgeName = util.GetValue(i, args) 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") { } else if strings.HasPrefix(arg, "--mtu") {
mtu, err := strconv.Atoi(util.GetValue(i, args)) mtu, err := strconv.Atoi(util.GetValue(i, args))
if err != nil { if err != nil {
@ -452,6 +455,38 @@ func touchSockets(args ...string) error {
return nil 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 { func createLayout(config *Config) error {
if err := createDirs("/tmp", "/root/.ssh", "/var", "/usr/lib"); err != nil { if err := createDirs("/tmp", "/root/.ssh", "/var", "/usr/lib"); err != nil {
return err return err
@ -467,6 +502,12 @@ func createLayout(config *Config) error {
return err return err
} }
if err := createDaemonConfig(config); err != nil {
return err
}
cleanupFiles(graphDirectory)
selinux.SetFileContext(graphDirectory, "system_u:object_r:var_lib_t:s0") selinux.SetFileContext(graphDirectory, "system_u:object_r:var_lib_t:s0")
return CreateSymlinks([][]string{ return CreateSymlinks([][]string{