Update containerd dependencies

sys/unix
cgroups
go-runc
console

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-07-07 11:46:54 -07:00
parent b9fb2793a8
commit d46b562043
51 changed files with 508 additions and 196 deletions

View File

@@ -245,6 +245,9 @@ func (c *cgroup) processes(subsystem Name, recursive bool) ([]Process, error) {
return err
}
if !recursive && info.IsDir() {
if p == path {
return nil
}
return filepath.SkipDir
}
dir, name := filepath.Split(p)

View File

@@ -84,15 +84,14 @@ func (c *cpusetController) ensureParent(current, root string) error {
if _, err := filepath.Rel(root, parent); err != nil {
return nil
}
if cleanPath(parent) == root {
return nil
}
// Avoid infinite recursion.
if parent == current {
return fmt.Errorf("cpuset: cgroup parent path outside cgroup root")
}
if err := c.ensureParent(parent, root); err != nil {
return err
if cleanPath(parent) != root {
if err := c.ensureParent(parent, root); err != nil {
return err
}
}
if err := os.MkdirAll(current, defaultDirPerm); err != nil {
return err

View File

@@ -1,5 +1,10 @@
package cgroups
func getClockTicks() uint64 {
// The value comes from `C.sysconf(C._SC_CLK_TCK)`, and
// on Linux it's a constant which is safe to be hard coded,
// so we can avoid using cgo here.
// See https://github.com/containerd/cgroups/pull/12 for
// more details.
return 100
}

View File

@@ -207,7 +207,9 @@ func parseCgroupFromReader(r io.Reader) (map[string]string, error) {
return nil, fmt.Errorf("invalid cgroup entry: must contain at least two colons: %v", text)
}
for _, subs := range strings.Split(parts[1], ",") {
cgroups[subs] = parts[2]
if subs != "" {
cgroups[subs] = parts[2]
}
}
}
return cgroups, nil

View File

@@ -26,6 +26,8 @@ type Console interface {
Reset() error
// Size returns the window size of the console
Size() (WinSize, error)
// Fd returns the console's file descriptor
Fd() uintptr
}
// WinSize specifies the window size of the console

View File

@@ -114,6 +114,10 @@ func (m *master) Size() (WinSize, error) {
return ws, nil
}
func (m *master) Fd() uintptr {
return m.f.Fd()
}
// checkConsole checks if the provided file is a console
func checkConsole(f *os.File) error {
var termios unix.Termios

View File

@@ -150,6 +150,10 @@ func (m *master) Write(b []byte) (int, error) {
panic("not implemented on windows")
}
func (m *master) Fd() uintptr {
return m.in
}
// makeInputRaw puts the terminal (Windows Console) connected to the given
// file descriptor into raw mode
func makeInputRaw(fd uintptr, mode uint32) error {

View File

@@ -9,11 +9,16 @@ import (
)
func tcget(fd uintptr, p *unix.Termios) error {
return ioctl(fd, unix.TCGETS, uintptr(unsafe.Pointer(p)))
termios, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
if err != nil {
return err
}
*p = *termios
return nil
}
func tcset(fd uintptr, p *unix.Termios) error {
return ioctl(fd, unix.TCSETS, uintptr(unsafe.Pointer(p)))
return unix.IoctlSetTermios(int(fd), unix.TCSETS, p)
}
func ioctl(fd, flag, data uintptr) error {
@@ -32,15 +37,14 @@ func unlockpt(f *os.File) error {
// ptsname retrieves the name of the first available pts for the given master.
func ptsname(f *os.File) (string, error) {
var n int32
if err := ioctl(f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil {
n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN)
if err != nil {
return "", err
}
return fmt.Sprintf("/dev/pts/%d", n), nil
}
func saneTerminal(f *os.File) error {
// Go doesn't have a wrapper for any of the termios ioctls.
var termios unix.Termios
if err := tcget(f.Fd(), &termios); err != nil {
return err

View File

@@ -12,10 +12,12 @@ func (r *Runc) command(context context.Context, args ...string) *exec.Cmd {
command = DefaultCommand
}
cmd := exec.CommandContext(context, command, append(r.args(), args...)...)
if r.PdeathSignal != 0 {
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: r.PdeathSignal,
}
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: r.Setpgid,
}
if r.PdeathSignal != 0 {
cmd.SysProcAttr.Pdeathsig = r.PdeathSignal
}
return cmd
}

View File

@@ -42,9 +42,13 @@ func (m *defaultMonitor) Start(c *exec.Cmd) error {
}
func (m *defaultMonitor) Wait(c *exec.Cmd) (int, error) {
status, err := c.Process.Wait()
if err != nil {
if err := c.Wait(); err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus(), nil
}
}
return -1, err
}
return status.Sys().(syscall.WaitStatus).ExitStatus(), nil
return 0, nil
}

View File

@@ -39,6 +39,7 @@ type Runc struct {
Log string
LogFormat Format
PdeathSignal syscall.Signal
Setpgid bool
Criu string
SystemdCgroup string
}