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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user