1
0
mirror of https://github.com/rancher/os.git synced 2025-09-03 15:54:24 +00:00

migrate to upstream libcompose in one and a half go

This commit is contained in:
Ivan Mikushin
2015-11-26 17:41:42 +05:00
parent 1d691cd8d6
commit 5a363ab97d
1291 changed files with 40107 additions and 123532 deletions

View File

@@ -13,6 +13,7 @@ import (
"syscall"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/system"
)
@@ -57,7 +58,7 @@ func (p *setnsProcess) signal(sig os.Signal) error {
if !ok {
return errors.New("os: unsupported signal type")
}
return syscall.Kill(p.cmd.Process.Pid, s)
return syscall.Kill(p.pid(), s)
}
func (p *setnsProcess) start() (err error) {
@@ -66,7 +67,7 @@ func (p *setnsProcess) start() (err error) {
return newSystemError(err)
}
if len(p.cgroupPaths) > 0 {
if err := cgroups.EnterPid(p.cgroupPaths, p.cmd.Process.Pid); err != nil {
if err := cgroups.EnterPid(p.cgroupPaths, p.pid()); err != nil {
return newSystemError(err)
}
}
@@ -83,6 +84,7 @@ func (p *setnsProcess) start() (err error) {
return newSystemError(err)
}
if ierr != nil {
p.wait()
return newSystemError(ierr)
}
@@ -138,11 +140,9 @@ func (p *setnsProcess) terminate() error {
func (p *setnsProcess) wait() (*os.ProcessState, error) {
err := p.cmd.Wait()
if err != nil {
return p.cmd.ProcessState, err
}
return p.cmd.ProcessState, nil
// Return actual ProcessState even on Wait error
return p.cmd.ProcessState, err
}
func (p *setnsProcess) pid() int {
@@ -175,9 +175,9 @@ func (p *initProcess) externalDescriptors() []string {
return p.fds
}
func (p *initProcess) start() error {
func (p *initProcess) start() (err error) {
defer p.parentPipe.Close()
err := p.cmd.Start()
err = p.cmd.Start()
p.childPipe.Close()
if err != nil {
return newSystemError(err)
@@ -202,6 +202,19 @@ func (p *initProcess) start() error {
p.manager.Destroy()
}
}()
if p.config.Config.Hooks != nil {
s := configs.HookState{
Version: p.container.config.Version,
ID: p.container.id,
Pid: p.pid(),
Root: p.config.Config.Rootfs,
}
for _, hook := range p.config.Config.Hooks.Prestart {
if err := hook.Run(s); err != nil {
return newSystemError(err)
}
}
}
if err := p.createNetworkInterfaces(); err != nil {
return newSystemError(err)
}
@@ -278,7 +291,7 @@ func (p *initProcess) signal(sig os.Signal) error {
if !ok {
return errors.New("os: unsupported signal type")
}
return syscall.Kill(p.cmd.Process.Pid, s)
return syscall.Kill(p.pid(), s)
}
func (p *initProcess) setExternalDescriptors(newFds []string) {
@@ -286,9 +299,7 @@ func (p *initProcess) setExternalDescriptors(newFds []string) {
}
func getPipeFds(pid int) ([]string, error) {
var fds []string
fds = make([]string, 3)
fds := make([]string, 3)
dirPath := filepath.Join("/proc", strconv.Itoa(pid), "/fd")
for i := 0; i < 3; i++ {