1
0
mirror of https://github.com/rancher/os.git synced 2025-07-04 18:46:15 +00:00

Merge pull request #702 from ibuildthecloud/one

Farewell PID one
This commit is contained in:
Darren Shepherd 2015-12-22 17:04:17 -07:00
commit bad2aca5b1
6 changed files with 47 additions and 2 deletions

View File

@ -1,6 +1,6 @@
IMAGE_NAME=rancher/os
VERSION=v0.4.3-dev
DOCKER_BINARY_URL=https://github.com/rancher/docker/releases/download/v1.9.1-ros1/docker-1.9.1
DOCKER_BINARY_URL=https://get.docker.com/builds/Linux/x86_64/docker-1.9.1
COMPILED_KERNEL_URL=https://github.com/rancher/os-kernel/releases/download/Ubuntu-4.2.0-16.19/linux-4.2.3-rancher-x86.tar.gz
DFS_IMAGE=rancher/docker:1.9.1-2

View File

@ -101,6 +101,7 @@ type DockerConfig struct {
CAKey string `yaml:"ca_key,omitempty"`
Environment []string `yaml:"environment,omitempty"`
StorageContext string `yaml:"storage_context,omitempty"`
Exec bool `yaml:"exec,omitempty"`
}
type StateConfig struct {

View File

@ -194,8 +194,12 @@ func RunInit() error {
}
launchConfig, args := getLaunchConfig(cfg, &cfg.Rancher.SystemDocker)
launchConfig.Fork = !cfg.Rancher.SystemDocker.Exec
log.Info("Launching System Docker")
_, err = dockerlaunch.LaunchDocker(launchConfig, config.DOCKER_BIN, args...)
return err
if err != nil {
return err
}
return pidOne()
}

28
init/one.go Normal file
View File

@ -0,0 +1,28 @@
// +build linux
package init
import (
"os"
"os/signal"
"syscall"
)
func pidOne() error {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGCHLD)
var (
ws syscall.WaitStatus
rus syscall.Rusage
)
for range c {
for {
if pid, err := syscall.Wait4(-1, &ws, syscall.WNOHANG, &rus); err != nil || pid <= 0 {
break
}
}
}
return nil
}

View File

@ -3,6 +3,7 @@ import subprocess
import pytest
import rostest.util as u
from rostest.util import SSH
import yaml
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
@ -91,3 +92,12 @@ def test_rancher_network(qemu, cloud_config):
assert v.split(' ')[2] == 'eth1'
assert v.split(' ')[5] + '/24' == cloud_config['rancher']['network']['interfaces']['eth1']['address']
def test_docker_not_pid_one(qemu):
SSH(qemu, ssh_command=ssh_command).check_call('bash', '-c', '''
set -e -x
for i in $(pidof docker); do
[ $i != 1 ]
done
'''.strip())

View File

@ -84,6 +84,8 @@ def wait_for_ssh(qemu, ssh_command=['./scripts/ssh', '--qemu'], command=['docker
i += 1
print('\nWaiting for ssh and docker... ' + str(i))
time.sleep(1)
if i > 60:
raise 'Failed to connect to SSH'
assert qemu.returncode is None