Update deps with sys/unix changes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
		
							
								
								
									
										8
									
								
								vendor/github.com/crosbymichael/cgroups/memory.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/crosbymichael/cgroups/memory.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,6 +11,8 @@ import ( | ||||
| 	"strings" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
|  | ||||
| 	specs "github.com/opencontainers/runtime-spec/specs-go" | ||||
| ) | ||||
|  | ||||
| @@ -153,12 +155,12 @@ func (m *memoryController) OOMEventFD(path string) (uintptr, error) { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	defer f.Close() | ||||
| 	fd, _, serr := syscall.RawSyscall(syscall.SYS_EVENTFD2, 0, syscall.FD_CLOEXEC, 0) | ||||
| 	fd, _, serr := unix.RawSyscall(unix.SYS_EVENTFD2, 0, unix.FD_CLOEXEC, 0) | ||||
| 	if serr != 0 { | ||||
| 		return 0, serr | ||||
| 	} | ||||
| 	if err := writeEventFD(root, f.Fd(), fd); err != nil { | ||||
| 		syscall.Close(int(fd)) | ||||
| 		unix.Close(int(fd)) | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return fd, nil | ||||
| @@ -284,7 +286,7 @@ func getMemorySettings(resources *specs.LinuxResources) []memorySettings { | ||||
| func checkEBUSY(err error) error { | ||||
| 	if pathErr, ok := err.(*os.PathError); ok { | ||||
| 		if errNo, ok := pathErr.Err.(syscall.Errno); ok { | ||||
| 			if errNo == syscall.EBUSY { | ||||
| 			if errNo == unix.EBUSY { | ||||
| 				return fmt.Errorf( | ||||
| 					"failed to set memory.kmem.limit_in_bytes, because either tasks have already joined this cgroup or it has children") | ||||
| 			} | ||||
|   | ||||
							
								
								
									
										17
									
								
								vendor/github.com/crosbymichael/cgroups/prometheus/metrics.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/github.com/crosbymichael/cgroups/prometheus/metrics.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,7 +11,10 @@ import ( | ||||
| 	"github.com/prometheus/client_golang/prometheus" | ||||
| ) | ||||
|  | ||||
| var ErrAlreadyCollected = errors.New("cgroup is already being collected") | ||||
| var ( | ||||
| 	ErrAlreadyCollected = errors.New("cgroup is already being collected") | ||||
| 	ErrCgroupNotExists  = errors.New("cgroup does not exist in the collector") | ||||
| ) | ||||
|  | ||||
| // New registers the Collector with the provided namespace and returns it so | ||||
| // that cgroups can be added for collection | ||||
| @@ -80,6 +83,18 @@ func (c *Collector) Add(id string, cg cgroups.Cgroup) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Get returns the cgroup that is being collected under the provided id | ||||
| // returns ErrCgroupNotExists if the id is not being collected | ||||
| func (c *Collector) Get(id string) (cgroups.Cgroup, error) { | ||||
| 	c.mu.Lock() | ||||
| 	defer c.mu.Unlock() | ||||
| 	cg, ok := c.cgroups[id] | ||||
| 	if !ok { | ||||
| 		return nil, ErrCgroupNotExists | ||||
| 	} | ||||
| 	return cg, nil | ||||
| } | ||||
|  | ||||
| // Remove removes the provided cgroup by id from the collector | ||||
| func (c *Collector) Remove(id string) { | ||||
| 	c.mu.Lock() | ||||
|   | ||||
							
								
								
									
										23
									
								
								vendor/github.com/crosbymichael/cgroups/prometheus/oom.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/crosbymichael/cgroups/prometheus/oom.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -2,7 +2,8 @@ package prometheus | ||||
|  | ||||
| import ( | ||||
| 	"sync" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
|  | ||||
| 	"github.com/Sirupsen/logrus" | ||||
| 	"github.com/crosbymichael/cgroups" | ||||
| @@ -10,7 +11,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| func NewOOMCollector(ns *metrics.Namespace) (*OOMCollector, error) { | ||||
| 	fd, err := syscall.EpollCreate1(syscall.EPOLL_CLOEXEC) | ||||
| 	fd, err := unix.EpollCreate1(unix.EPOLL_CLOEXEC) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @@ -49,11 +50,11 @@ func (o *OOMCollector) Add(id string, cg cgroups.Cgroup) error { | ||||
| 	} | ||||
| 	// set the gauge's default value | ||||
| 	o.memoryOOM.WithValues(id).Set(0) | ||||
| 	event := syscall.EpollEvent{ | ||||
| 	event := unix.EpollEvent{ | ||||
| 		Fd:     int32(fd), | ||||
| 		Events: syscall.EPOLLHUP | syscall.EPOLLIN | syscall.EPOLLERR, | ||||
| 		Events: unix.EPOLLHUP | unix.EPOLLIN | unix.EPOLLERR, | ||||
| 	} | ||||
| 	if err := syscall.EpollCtl(o.fd, syscall.EPOLL_CTL_ADD, int(fd), &event); err != nil { | ||||
| 	if err := unix.EpollCtl(o.fd, unix.EPOLL_CTL_ADD, int(fd), &event); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return nil | ||||
| @@ -61,15 +62,15 @@ func (o *OOMCollector) Add(id string, cg cgroups.Cgroup) error { | ||||
|  | ||||
| // Close closes the epoll fd | ||||
| func (o *OOMCollector) Close() error { | ||||
| 	return syscall.Close(int(o.fd)) | ||||
| 	return unix.Close(int(o.fd)) | ||||
| } | ||||
|  | ||||
| func (o *OOMCollector) start() { | ||||
| 	var events [128]syscall.EpollEvent | ||||
| 	var events [128]unix.EpollEvent | ||||
| 	for { | ||||
| 		n, err := syscall.EpollWait(o.fd, events[:], -1) | ||||
| 		n, err := unix.EpollWait(o.fd, events[:], -1) | ||||
| 		if err != nil { | ||||
| 			if err == syscall.EINTR { | ||||
| 			if err == unix.EINTR { | ||||
| 				continue | ||||
| 			} | ||||
| 			logrus.WithField("error", err).Fatal("cgroups: epoll wait") | ||||
| @@ -97,7 +98,7 @@ func (o *OOMCollector) process(fd uintptr, event uint32) { | ||||
| 		o.mu.Lock() | ||||
| 		delete(o.set, fd) | ||||
| 		o.mu.Unlock() | ||||
| 		syscall.Close(int(fd)) | ||||
| 		unix.Close(int(fd)) | ||||
| 		return | ||||
| 	} | ||||
| 	o.memoryOOM.WithValues(info.id).Inc(1) | ||||
| @@ -105,6 +106,6 @@ func (o *OOMCollector) process(fd uintptr, event uint32) { | ||||
|  | ||||
| func flush(fd uintptr) error { | ||||
| 	buf := make([]byte, 8) | ||||
| 	_, err := syscall.Read(int(fd), buf) | ||||
| 	_, err := unix.Read(int(fd), buf) | ||||
| 	return err | ||||
| } | ||||
|   | ||||
							
								
								
									
										15
									
								
								vendor/github.com/crosbymichael/console/console_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/github.com/crosbymichael/console/console_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,15 +5,16 @@ import "C" | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
|  | ||||
| // NewPty creates a new pty pair | ||||
| // The master is returned as the first console and a string | ||||
| // with the path to the pty slave is returned as the second | ||||
| func NewPty() (Console, string, error) { | ||||
| 	f, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0) | ||||
| 	f, err := os.OpenFile("/dev/ptmx", unix.O_RDWR|unix.O_NOCTTY|unix.O_CLOEXEC, 0) | ||||
| 	if err != nil { | ||||
| 		return nil, "", err | ||||
| 	} | ||||
| @@ -34,7 +35,7 @@ func NewPty() (Console, string, error) { | ||||
|  | ||||
| type master struct { | ||||
| 	f       *os.File | ||||
| 	termios *syscall.Termios | ||||
| 	termios *unix.Termios | ||||
| } | ||||
|  | ||||
| func (m *master) Read(b []byte) (int, error) { | ||||
| @@ -52,7 +53,7 @@ func (m *master) Close() error { | ||||
| func (m *master) Resize(ws WinSize) error { | ||||
| 	return ioctl( | ||||
| 		m.f.Fd(), | ||||
| 		uintptr(syscall.TIOCSWINSZ), | ||||
| 		uintptr(unix.TIOCSWINSZ), | ||||
| 		uintptr(unsafe.Pointer(&ws)), | ||||
| 	) | ||||
| } | ||||
| @@ -73,7 +74,7 @@ func (m *master) Reset() error { | ||||
| } | ||||
|  | ||||
| func (m *master) SetRaw() error { | ||||
| 	m.termios = &syscall.Termios{} | ||||
| 	m.termios = &unix.Termios{} | ||||
| 	if err := tcget(m.f.Fd(), m.termios); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -87,7 +88,7 @@ func (m *master) Size() (WinSize, error) { | ||||
| 	var ws WinSize | ||||
| 	if err := ioctl( | ||||
| 		m.f.Fd(), | ||||
| 		uintptr(syscall.TIOCGWINSZ), | ||||
| 		uintptr(unix.TIOCGWINSZ), | ||||
| 		uintptr(unsafe.Pointer(&ws)), | ||||
| 	); err != nil { | ||||
| 		return ws, err | ||||
| @@ -97,7 +98,7 @@ func (m *master) Size() (WinSize, error) { | ||||
|  | ||||
| // checkConsole checks if the provided file is a console | ||||
| func checkConsole(f *os.File) error { | ||||
| 	var termios syscall.Termios | ||||
| 	var termios unix.Termios | ||||
| 	if tcget(f.Fd(), &termios) != nil { | ||||
| 		return ErrNotAConsole | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										21
									
								
								vendor/github.com/crosbymichael/console/tc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/crosbymichael/console/tc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -5,20 +5,21 @@ package console | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
|  | ||||
| func tcget(fd uintptr, p *syscall.Termios) error { | ||||
| 	return ioctl(fd, syscall.TCGETS, uintptr(unsafe.Pointer(p))) | ||||
| func tcget(fd uintptr, p *unix.Termios) error { | ||||
| 	return ioctl(fd, unix.TCGETS, uintptr(unsafe.Pointer(p))) | ||||
| } | ||||
|  | ||||
| func tcset(fd uintptr, p *syscall.Termios) error { | ||||
| 	return ioctl(fd, syscall.TCSETS, uintptr(unsafe.Pointer(p))) | ||||
| func tcset(fd uintptr, p *unix.Termios) error { | ||||
| 	return ioctl(fd, unix.TCSETS, uintptr(unsafe.Pointer(p))) | ||||
| } | ||||
|  | ||||
| func ioctl(fd, flag, data uintptr) error { | ||||
| 	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, flag, data); err != 0 { | ||||
| 	if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 { | ||||
| 		return err | ||||
| 	} | ||||
| 	return nil | ||||
| @@ -28,13 +29,13 @@ func ioctl(fd, flag, data uintptr) error { | ||||
| // unlockpt should be called before opening the slave side of a pty. | ||||
| func unlockpt(f *os.File) error { | ||||
| 	var u int32 | ||||
| 	return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) | ||||
| 	return ioctl(f.Fd(), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) | ||||
| } | ||||
|  | ||||
| // 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(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil { | ||||
| 	if err := ioctl(f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 	return fmt.Sprintf("/dev/pts/%d", n), nil | ||||
| @@ -42,11 +43,11 @@ func ptsname(f *os.File) (string, error) { | ||||
|  | ||||
| func saneTerminal(f *os.File) error { | ||||
| 	// Go doesn't have a wrapper for any of the termios ioctls. | ||||
| 	var termios syscall.Termios | ||||
| 	var termios unix.Termios | ||||
| 	if err := tcget(f.Fd(), &termios); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	// Set -onlcr so we don't have to deal with \r. | ||||
| 	termios.Oflag &^= syscall.ONLCR | ||||
| 	termios.Oflag &^= unix.ONLCR | ||||
| 	return tcset(f.Fd(), &termios) | ||||
| } | ||||
|   | ||||
							
								
								
									
										24
									
								
								vendor/github.com/crosbymichael/go-runc/console.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/crosbymichael/go-runc/console.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,3 +1,5 @@ | ||||
| // +build cgo | ||||
|  | ||||
| package runc | ||||
|  | ||||
| import ( | ||||
| @@ -11,7 +13,7 @@ import ( | ||||
|  | ||||
| // NewConsoleSocket creates a new unix socket at the provided path to accept a | ||||
| // pty master created by runc for use by the container | ||||
| func NewConsoleSocket(path string) (*ConsoleSocket, error) { | ||||
| func NewConsoleSocket(path string) (*Socket, error) { | ||||
| 	abs, err := filepath.Abs(path) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -20,25 +22,25 @@ func NewConsoleSocket(path string) (*ConsoleSocket, error) { | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &ConsoleSocket{ | ||||
| 	return &Socket{ | ||||
| 		l:    l, | ||||
| 		path: abs, | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| // ConsoleSocket is a unix socket that accepts the pty master created by runc | ||||
| type ConsoleSocket struct { | ||||
| // Socket is a unix socket that accepts the pty master created by runc | ||||
| type Socket struct { | ||||
| 	path string | ||||
| 	l    net.Listener | ||||
| } | ||||
|  | ||||
| // Path returns the path to the unix socket on disk | ||||
| func (c *ConsoleSocket) Path() string { | ||||
| func (c *Socket) Path() string { | ||||
| 	return c.path | ||||
| } | ||||
|  | ||||
| // ReceiveMaster blocks until the socket receives the pty master | ||||
| func (c *ConsoleSocket) ReceiveMaster() (console.Console, error) { | ||||
| func (c *Socket) ReceiveMaster() (console.Console, error) { | ||||
| 	conn, err := c.l.Accept() | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -60,14 +62,6 @@ func (c *ConsoleSocket) ReceiveMaster() (console.Console, error) { | ||||
| } | ||||
|  | ||||
| // Close closes the unix socket | ||||
| func (c *ConsoleSocket) Close() error { | ||||
| func (c *Socket) Close() error { | ||||
| 	return c.l.Close() | ||||
| } | ||||
|  | ||||
| // WinSize specifies the console size | ||||
| type WinSize struct { | ||||
| 	// Width of the console | ||||
| 	Width uint16 | ||||
| 	// Height of the console | ||||
| 	Height uint16 | ||||
| } | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/crosbymichael/go-runc/io.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/crosbymichael/go-runc/io.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,7 +4,8 @@ import ( | ||||
| 	"io" | ||||
| 	"os" | ||||
| 	"os/exec" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
|  | ||||
| type IO interface { | ||||
| @@ -60,10 +61,10 @@ func newPipe(uid, gid int) (*pipe, error) { | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := syscall.Fchown(int(r.Fd()), uid, gid); err != nil { | ||||
| 	if err := unix.Fchown(int(r.Fd()), uid, gid); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := syscall.Fchown(int(w.Fd()), uid, gid); err != nil { | ||||
| 	if err := unix.Fchown(int(w.Fd()), uid, gid); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &pipe{ | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/github.com/crosbymichael/go-runc/runc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/crosbymichael/go-runc/runc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,7 +24,7 @@ const ( | ||||
| 	JSON Format = "json" | ||||
| 	Text Format = "text" | ||||
| 	// DefaultCommand is the default command for Runc | ||||
| 	DefaultCommand string = "runc" | ||||
| 	DefaultCommand = "runc" | ||||
| ) | ||||
|  | ||||
| // Runc is the client to the runc cli | ||||
| @@ -64,11 +64,15 @@ func (r *Runc) State(context context.Context, id string) (*Container, error) { | ||||
| 	return &c, nil | ||||
| } | ||||
|  | ||||
| type ConsoleSocket interface { | ||||
| 	Path() string | ||||
| } | ||||
|  | ||||
| type CreateOpts struct { | ||||
| 	IO | ||||
| 	// PidFile is a path to where a pid file should be created | ||||
| 	PidFile       string | ||||
| 	ConsoleSocket *ConsoleSocket | ||||
| 	ConsoleSocket ConsoleSocket | ||||
| 	Detach        bool | ||||
| 	NoPivot       bool | ||||
| 	NoNewKeyring  bool | ||||
| @@ -146,7 +150,7 @@ func (r *Runc) Start(context context.Context, id string) error { | ||||
| type ExecOpts struct { | ||||
| 	IO | ||||
| 	PidFile       string | ||||
| 	ConsoleSocket *ConsoleSocket | ||||
| 	ConsoleSocket ConsoleSocket | ||||
| 	Detach        bool | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby