From ce31366baf7a1b619e60822fff66595bede18ee2 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Thu, 8 Aug 2019 17:56:37 +0530 Subject: [PATCH] pinned cadvisor to a latest commit Signed-off-by: Tarun Pothulapati --- Godeps/LICENSES | 35 -- go.mod | 6 +- go.sum | 6 +- vendor/BUILD | 1 - .../google/cadvisor/cache/memory/memory.go | 8 +- .../google/cadvisor/container/common/BUILD | 2 +- .../cadvisor/container/common/helpers.go | 11 +- .../container/common/inotify_watcher.go | 4 +- .../cadvisor/container/libcontainer/BUILD | 2 +- .../container/libcontainer/handler.go | 46 ++- .../container/libcontainer/helpers.go | 1 + .../google/cadvisor/container/raw/BUILD | 2 +- .../google/cadvisor/container/raw/handler.go | 3 + .../google/cadvisor/container/raw/watcher.go | 10 +- .../google/cadvisor/info/v1/container.go | 19 ++ .../google/cadvisor/info/v2/container.go | 8 + .../google/cadvisor/info/v2/conversion.go | 7 + .../google/cadvisor/metrics/prometheus.go | 49 ++- .../cadvisor/utils/cloudinfo/aws/aws.go | 33 +- .../cadvisor/utils/cpuload/netlink/BUILD | 3 +- .../cadvisor/utils/cpuload/netlink/defs.go | 26 -- .../cadvisor/utils/cpuload/netlink/netlink.go | 21 +- vendor/github.com/sigma/go-inotify/BUILD | 23 -- vendor/github.com/sigma/go-inotify/LICENSE | 27 -- vendor/github.com/sigma/go-inotify/PATENTS | 22 -- vendor/github.com/sigma/go-inotify/README.md | 5 - .../sigma/go-inotify/inotify_linux.go | 306 ------------------ vendor/modules.txt | 4 +- 28 files changed, 165 insertions(+), 525 deletions(-) delete mode 100644 vendor/github.com/google/cadvisor/utils/cpuload/netlink/defs.go delete mode 100644 vendor/github.com/sigma/go-inotify/BUILD delete mode 100644 vendor/github.com/sigma/go-inotify/LICENSE delete mode 100644 vendor/github.com/sigma/go-inotify/PATENTS delete mode 100644 vendor/github.com/sigma/go-inotify/README.md delete mode 100644 vendor/github.com/sigma/go-inotify/inotify_linux.go diff --git a/Godeps/LICENSES b/Godeps/LICENSES index 1b31aedbd78..1e9b0478e6f 100644 --- a/Godeps/LICENSES +++ b/Godeps/LICENSES @@ -16396,41 +16396,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================================ -================================================================================ -= vendor/github.com/sigma/go-inotify licensed under: = - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -= vendor/github.com/sigma/go-inotify/LICENSE 5d4950ecb7b26d2c5e4e7b4e0dd74707 -================================================================================ - - ================================================================================ = vendor/github.com/sirupsen/logrus licensed under: = diff --git a/go.mod b/go.mod index 05de03fd92e..d7b05cab965 100644 --- a/go.mod +++ b/go.mod @@ -64,7 +64,7 @@ require ( github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903 github.com/golang/mock v1.2.0 github.com/golang/protobuf v1.2.0 - github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a + github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 github.com/google/certificate-transparency-go v1.0.21 // indirect github.com/google/go-cmp v0.3.0 github.com/google/gofuzz v1.0.0 @@ -113,7 +113,6 @@ require ( github.com/robfig/cron v1.1.0 github.com/russross/blackfriday v1.5.2 github.com/seccomp/libseccomp-golang v0.9.1 // indirect - github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d // indirect github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect github.com/spf13/afero v1.2.2 github.com/spf13/cobra v0.0.4 @@ -273,7 +272,7 @@ replace ( github.com/golangplus/fmt => github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 github.com/golangplus/testing => github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e github.com/google/btree => github.com/google/btree v0.0.0-20160524151835-7d79101e329e - github.com/google/cadvisor => github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a + github.com/google/cadvisor => github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 github.com/google/certificate-transparency-go => github.com/google/certificate-transparency-go v1.0.21 github.com/google/go-cmp => github.com/google/go-cmp v0.3.0 github.com/google/gofuzz => github.com/google/gofuzz v1.0.0 @@ -371,7 +370,6 @@ replace ( github.com/russross/blackfriday => github.com/russross/blackfriday v1.5.2 github.com/satori/go.uuid => github.com/satori/go.uuid v1.2.0 github.com/seccomp/libseccomp-golang => github.com/seccomp/libseccomp-golang v0.9.1 - github.com/sigma/go-inotify => github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d github.com/sirupsen/logrus => github.com/sirupsen/logrus v1.4.2 github.com/smartystreets/assertions => github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d github.com/smartystreets/goconvey => github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a diff --git a/go.sum b/go.sum index 1ca5e8322d7..8b080351e02 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,8 @@ github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e h1:KhcknUwkWHKZ github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= github.com/google/btree v0.0.0-20160524151835-7d79101e329e h1:JHB7F/4TJCrYBW8+GZO8VkWDj1jxcWuCl6uxKODiyi4= github.com/google/btree v0.0.0-20160524151835-7d79101e329e/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a h1:4N3IykedbdXG1ganAZbAKlViPjrtfrx2nC4qzUHieOk= -github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a/go.mod h1:1nql6U13uTHaLYB8rLS5x9IJc2qT6Xd/Tr1sTX6NE48= +github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 h1:8PpCh6R0YjmmztPXOq9aKhiUqLGUrp6Fly3vWk7l2Fg= +github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966/go.mod h1:1nql6U13uTHaLYB8rLS5x9IJc2qT6Xd/Tr1sTX6NE48= github.com/google/certificate-transparency-go v1.0.21 h1:Yf1aXowfZ2nuboBsg7iYGLmwsOARdV86pfH3g95wXmE= github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= @@ -362,8 +362,6 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/seccomp/libseccomp-golang v0.9.1 h1:NJjM5DNFOs0s3kYE1WUOr6G8V97sdt46rlXTMfXGWBo= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= -github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d h1:G1nNtZVTzcCvVKMwcG0Vispo3bhc15EbjO5uamiLikI= -github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d/go.mod h1:stlh9OsqBQSdwxTxX73mu41BBtRbIpZLQ7flcAoxAfo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= diff --git a/vendor/BUILD b/vendor/BUILD index b85d5df8907..48d5b12d093 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -329,7 +329,6 @@ filegroup( "//vendor/github.com/russross/blackfriday:all-srcs", "//vendor/github.com/satori/go.uuid:all-srcs", "//vendor/github.com/seccomp/libseccomp-golang:all-srcs", - "//vendor/github.com/sigma/go-inotify:all-srcs", "//vendor/github.com/sirupsen/logrus:all-srcs", "//vendor/github.com/soheilhy/cmux:all-srcs", "//vendor/github.com/spf13/afero:all-srcs", diff --git a/vendor/github.com/google/cadvisor/cache/memory/memory.go b/vendor/github.com/google/cadvisor/cache/memory/memory.go index fbeb2070d84..99454c77735 100644 --- a/vendor/github.com/google/cadvisor/cache/memory/memory.go +++ b/vendor/github.com/google/cadvisor/cache/memory/memory.go @@ -70,7 +70,7 @@ type InMemoryCache struct { lock sync.RWMutex containerCacheMap map[string]*containerCache maxAge time.Duration - backend storage.StorageDriver + backend []storage.StorageDriver } func (self *InMemoryCache) AddStats(cInfo *info.ContainerInfo, stats *info.ContainerStats) error { @@ -86,11 +86,11 @@ func (self *InMemoryCache) AddStats(cInfo *info.ContainerInfo, stats *info.Conta } }() - if self.backend != nil { + for _, backend := range self.backend { // TODO(monnand): To deal with long delay write operations, we // may want to start a pool of goroutines to do write // operations. - if err := self.backend.AddStats(cInfo, stats); err != nil { + if err := backend.AddStats(cInfo, stats); err != nil { klog.Error(err) } } @@ -131,7 +131,7 @@ func (self *InMemoryCache) RemoveContainer(containerName string) error { func New( maxAge time.Duration, - backend storage.StorageDriver, + backend []storage.StorageDriver, ) *InMemoryCache { ret := &InMemoryCache{ containerCacheMap: make(map[string]*containerCache, 32), diff --git a/vendor/github.com/google/cadvisor/container/common/BUILD b/vendor/github.com/google/cadvisor/container/common/BUILD index dcfca84dc6e..f23b8c643a9 100644 --- a/vendor/github.com/google/cadvisor/container/common/BUILD +++ b/vendor/github.com/google/cadvisor/container/common/BUILD @@ -18,8 +18,8 @@ go_library( "//vendor/github.com/google/cadvisor/utils:go_default_library", "//vendor/github.com/karrick/godirwalk:go_default_library", "//vendor/github.com/pkg/errors:go_default_library", - "//vendor/github.com/sigma/go-inotify:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/inotify:go_default_library", ], ) diff --git a/vendor/github.com/google/cadvisor/container/common/helpers.go b/vendor/github.com/google/cadvisor/container/common/helpers.go index 3a84c2550f5..b09f150e262 100644 --- a/vendor/github.com/google/cadvisor/container/common/helpers.go +++ b/vendor/github.com/google/cadvisor/container/common/helpers.go @@ -116,6 +116,15 @@ func GetSpec(cgroupPaths map[string]string, machineInfoFactory info.MachineInfoF } } + // Processes, read it's value from pids path directly + pidsRoot, ok := cgroupPaths["pids"] + if ok { + if utils.FileExists(pidsRoot) { + spec.HasProcesses = true + spec.Processes.Limit = readUInt64(pidsRoot, "pids.max") + } + } + spec.HasNetwork = hasNetwork spec.HasFilesystem = hasFilesystem @@ -143,7 +152,7 @@ func readString(dirpath string, file string) string { func readUInt64(dirpath string, file string) uint64 { out := readString(dirpath, file) - if out == "" { + if out == "" || out == "max" { return 0 } diff --git a/vendor/github.com/google/cadvisor/container/common/inotify_watcher.go b/vendor/github.com/google/cadvisor/container/common/inotify_watcher.go index 787f599a22b..7480dfc5fd1 100644 --- a/vendor/github.com/google/cadvisor/container/common/inotify_watcher.go +++ b/vendor/github.com/google/cadvisor/container/common/inotify_watcher.go @@ -17,7 +17,7 @@ package common import ( "sync" - inotify "github.com/sigma/go-inotify" + inotify "k8s.io/utils/inotify" ) // Watcher for container-related inotify events in the cgroup hierarchy. @@ -55,7 +55,7 @@ func (iw *InotifyWatcher) AddWatch(containerName, dir string) (bool, error) { // Register an inotify notification. if !cgroupsWatched[dir] { - err := iw.watcher.AddWatch(dir, inotify.IN_CREATE|inotify.IN_DELETE|inotify.IN_MOVE) + err := iw.watcher.AddWatch(dir, inotify.InCreate|inotify.InDelete|inotify.InMove) if err != nil { return alreadyWatched, err } diff --git a/vendor/github.com/google/cadvisor/container/libcontainer/BUILD b/vendor/github.com/google/cadvisor/container/libcontainer/BUILD index bd6bb9783c4..d2b55712dd9 100644 --- a/vendor/github.com/google/cadvisor/container/libcontainer/BUILD +++ b/vendor/github.com/google/cadvisor/container/libcontainer/BUILD @@ -6,7 +6,6 @@ go_library( "handler.go", "helpers.go", ], - cgo = True, importmap = "k8s.io/kubernetes/vendor/github.com/google/cadvisor/container/libcontainer", importpath = "github.com/google/cadvisor/container/libcontainer", visibility = ["//visibility:public"], @@ -15,6 +14,7 @@ go_library( "//vendor/github.com/google/cadvisor/info/v1:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library", + "//vendor/golang.org/x/sys/unix:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/vendor/github.com/google/cadvisor/container/libcontainer/handler.go b/vendor/github.com/google/cadvisor/container/libcontainer/handler.go index 1951a1d6700..7aaec7e005a 100644 --- a/vendor/github.com/google/cadvisor/container/libcontainer/handler.go +++ b/vendor/github.com/google/cadvisor/container/libcontainer/handler.go @@ -27,18 +27,15 @@ import ( "github.com/google/cadvisor/container" info "github.com/google/cadvisor/info/v1" + "golang.org/x/sys/unix" "bytes" + "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/cgroups" "k8s.io/klog" ) -/* -#include -*/ -import "C" - type Handler struct { cgroupManager cgroups.Manager rootFs string @@ -133,6 +130,9 @@ func (h *Handler) GetStats() (*info.ContainerStats, error) { klog.V(4).Infof("Unable to get Process Stats: %v", err) } } + + // if include processes metrics, just set threads metrics if exist, and has no relationship with cpu path + setThreadsStats(cgroupStats, stats) } // For backwards compatibility. @@ -144,7 +144,7 @@ func (h *Handler) GetStats() (*info.ContainerStats, error) { } func processStatsFromProcs(rootFs string, cgroupPath string) (info.ProcessStats, error) { - var fdCount uint64 + var fdCount, socketCount uint64 filePath := path.Join(cgroupPath, "cgroup.procs") out, err := ioutil.ReadFile(filePath) if err != nil { @@ -168,11 +168,23 @@ func processStatsFromProcs(rootFs string, cgroupPath string) (info.ProcessStats, continue } fdCount += uint64(len(fds)) + for _, fd := range fds { + fdPath := path.Join(dirPath, fd.Name()) + linkName, err := os.Readlink(fdPath) + if err != nil { + klog.V(4).Infof("error while reading %q link: %v", fdPath, err) + continue + } + if strings.HasPrefix(linkName, "socket") { + socketCount++ + } + } } processStats := info.ProcessStats{ ProcessCount: uint64(len(pids)), FdCount: fdCount, + SocketCount: socketCount, } return processStats, nil @@ -514,19 +526,12 @@ func setCpuStats(s *cgroups.Stats, ret *info.ContainerStats, withPerCPU bool) { } -// Copied from -// https://github.com/moby/moby/blob/8b1adf55c2af329a4334f21d9444d6a169000c81/daemon/stats/collector_unix.go#L73 -// Apache 2.0, Copyright Docker, Inc. func getNumberOnlineCPUs() (uint32, error) { - i, err := C.sysconf(C._SC_NPROCESSORS_ONLN) - // According to POSIX - errno is undefined after successful - // sysconf, and can be non-zero in several cases, so look for - // error in returned value not in errno. - // (https://sourceware.org/bugzilla/show_bug.cgi?id=21536) - if i == -1 { + var availableCPUs unix.CPUSet + if err := unix.SchedGetaffinity(0, &availableCPUs); err != nil { return 0, err } - return uint32(i), nil + return uint32(availableCPUs.Count()), nil } func setDiskIoStats(s *cgroups.Stats, ret *info.ContainerStats) { @@ -598,6 +603,15 @@ func setNetworkStats(libcontainerStats *libcontainer.Stats, ret *info.ContainerS } } +// read from pids path not cpu +func setThreadsStats(s *cgroups.Stats, ret *info.ContainerStats) { + if s != nil { + ret.Processes.ThreadsCurrent = s.PidsStats.Current + ret.Processes.ThreadsMax = s.PidsStats.Limit + } + +} + func newContainerStats(libcontainerStats *libcontainer.Stats, includedMetrics container.MetricSet) *info.ContainerStats { ret := &info.ContainerStats{ Timestamp: time.Now(), diff --git a/vendor/github.com/google/cadvisor/container/libcontainer/helpers.go b/vendor/github.com/google/cadvisor/container/libcontainer/helpers.go index 9877d75a6dc..53d79232054 100644 --- a/vendor/github.com/google/cadvisor/container/libcontainer/helpers.go +++ b/vendor/github.com/google/cadvisor/container/libcontainer/helpers.go @@ -106,6 +106,7 @@ var supportedSubsystems map[string]struct{} = map[string]struct{}{ "cpu": {}, "cpuacct": {}, "memory": {}, + "pids": {}, "cpuset": {}, "blkio": {}, "devices": {}, diff --git a/vendor/github.com/google/cadvisor/container/raw/BUILD b/vendor/github.com/google/cadvisor/container/raw/BUILD index 8942aacffe7..51120fb0c12 100644 --- a/vendor/github.com/google/cadvisor/container/raw/BUILD +++ b/vendor/github.com/google/cadvisor/container/raw/BUILD @@ -20,8 +20,8 @@ go_library( "//vendor/github.com/google/cadvisor/watcher:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs:go_default_library", "//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library", - "//vendor/github.com/sigma/go-inotify:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/utils/inotify:go_default_library", ], ) diff --git a/vendor/github.com/google/cadvisor/container/raw/handler.go b/vendor/github.com/google/cadvisor/container/raw/handler.go index 2912e8948aa..b80f8d2d8e8 100644 --- a/vendor/github.com/google/cadvisor/container/raw/handler.go +++ b/vendor/github.com/google/cadvisor/container/raw/handler.go @@ -77,6 +77,9 @@ func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSu pid := 0 if isRootCgroup(name) { pid = 1 + + // delete pids from cgroup paths because /sys/fs/cgroup/pids/pids.current not exist + delete(cgroupPaths, "pids") } handler := libcontainer.NewHandler(cgroupManager, rootFs, pid, includedMetrics) diff --git a/vendor/github.com/google/cadvisor/container/raw/watcher.go b/vendor/github.com/google/cadvisor/container/raw/watcher.go index 201b870bf0c..cec04da84df 100644 --- a/vendor/github.com/google/cadvisor/container/raw/watcher.go +++ b/vendor/github.com/google/cadvisor/container/raw/watcher.go @@ -26,7 +26,7 @@ import ( "github.com/google/cadvisor/container/common" "github.com/google/cadvisor/container/libcontainer" "github.com/google/cadvisor/watcher" - inotify "github.com/sigma/go-inotify" + inotify "k8s.io/utils/inotify" "k8s.io/klog" ) @@ -172,13 +172,13 @@ func (self *rawContainerWatcher) processEvent(event *inotify.Event, events chan // Convert the inotify event type to a container create or delete. var eventType watcher.ContainerEventType switch { - case (event.Mask & inotify.IN_CREATE) > 0: + case (event.Mask & inotify.InCreate) > 0: eventType = watcher.ContainerAdd - case (event.Mask & inotify.IN_DELETE) > 0: + case (event.Mask & inotify.InDelete) > 0: eventType = watcher.ContainerDelete - case (event.Mask & inotify.IN_MOVED_FROM) > 0: + case (event.Mask & inotify.InMovedFrom) > 0: eventType = watcher.ContainerDelete - case (event.Mask & inotify.IN_MOVED_TO) > 0: + case (event.Mask & inotify.InMovedTo) > 0: eventType = watcher.ContainerAdd default: // Ignore other events. diff --git a/vendor/github.com/google/cadvisor/info/v1/container.go b/vendor/github.com/google/cadvisor/info/v1/container.go index b54233d535c..056de8d6778 100644 --- a/vendor/github.com/google/cadvisor/info/v1/container.go +++ b/vendor/github.com/google/cadvisor/info/v1/container.go @@ -41,6 +41,10 @@ type MemorySpec struct { SwapLimit uint64 `json:"swap_limit,omitempty"` } +type ProcessSpec struct { + Limit uint64 `json:"limit,omitempty"` +} + type ContainerSpec struct { // Time at which the container was created. CreationTime time.Time `json:"creation_time,omitempty"` @@ -58,6 +62,9 @@ type ContainerSpec struct { HasNetwork bool `json:"has_network"` + HasProcesses bool `json:"has_processes"` + Processes ProcessSpec `json:"processes,omitempty"` + HasFilesystem bool `json:"has_filesystem"` // HasDiskIo when true, indicates that DiskIo stats will be available. @@ -563,6 +570,15 @@ type ProcessStats struct { // Number of open file descriptors FdCount uint64 `json:"fd_count"` + + // Number of sockets + SocketCount uint64 `json:"socket_count"` + + // Number of threads currently in container + ThreadsCurrent uint64 `json:"threads_current,omitempty"` + + // Maxium number of threads allowed in container + ThreadsMax uint64 `json:"threads_max,omitempty"` } type ContainerStats struct { @@ -630,6 +646,9 @@ func (a *ContainerStats) StatsEq(b *ContainerStats) bool { if !reflect.DeepEqual(a.Network, b.Network) { return false } + if !reflect.DeepEqual(a.Processes, b.Processes) { + return false + } if !reflect.DeepEqual(a.Filesystem, b.Filesystem) { return false } diff --git a/vendor/github.com/google/cadvisor/info/v2/container.go b/vendor/github.com/google/cadvisor/info/v2/container.go index 4288d003dbf..43a8c8793af 100644 --- a/vendor/github.com/google/cadvisor/info/v2/container.go +++ b/vendor/github.com/google/cadvisor/info/v2/container.go @@ -90,6 +90,9 @@ type ContainerSpec struct { HasCustomMetrics bool `json:"has_custom_metrics"` CustomMetrics []v1.MetricSpec `json:"custom_metrics,omitempty"` + HasProcesses bool `json:"has_processes"` + Processes v1.ProcessSpec `json:"processes,omitempty"` + // Following resources have no associated spec, but are being isolated. HasNetwork bool `json:"has_network"` HasFilesystem bool `json:"has_filesystem"` @@ -117,6 +120,9 @@ type DeprecatedContainerStats struct { // Network statistics HasNetwork bool `json:"has_network"` Network NetworkStats `json:"network,omitempty"` + // Processes statistics + HasProcesses bool `json:"has_processes"` + Processes v1.ProcessStats `json:"processes,omitempty"` // Filesystem statistics HasFilesystem bool `json:"has_filesystem"` Filesystem []v1.FsStats `json:"filesystem,omitempty"` @@ -142,6 +148,8 @@ type ContainerStats struct { Memory *v1.MemoryStats `json:"memory,omitempty"` // Network statistics Network *NetworkStats `json:"network,omitempty"` + // Processes statistics + Processes *v1.ProcessStats `json:"processes,omitempty"` // Filesystem statistics Filesystem *FilesystemStats `json:"filesystem,omitempty"` // Task load statistics diff --git a/vendor/github.com/google/cadvisor/info/v2/conversion.go b/vendor/github.com/google/cadvisor/info/v2/conversion.go index 74279a20a13..1e86687870d 100644 --- a/vendor/github.com/google/cadvisor/info/v2/conversion.go +++ b/vendor/github.com/google/cadvisor/info/v2/conversion.go @@ -124,6 +124,9 @@ func ContainerStatsFromV1(containerName string, spec *v1.ContainerSpec, stats [] Interfaces: val.Network.Interfaces, } } + if spec.HasProcesses { + stat.Processes = &val.Processes + } if spec.HasFilesystem { if len(val.Filesystem) == 1 { stat.Filesystem = &FilesystemStats{ @@ -180,6 +183,9 @@ func DeprecatedStatsFromV1(cont *v1.ContainerInfo) []DeprecatedContainerStats { if stat.HasNetwork { stat.Network.Interfaces = val.Network.Interfaces } + if stat.HasProcesses { + stat.Processes = val.Processes + } if stat.HasFilesystem { stat.Filesystem = val.Filesystem } @@ -255,6 +261,7 @@ func ContainerSpecFromV1(specV1 *v1.ContainerSpec, aliases []string, namespace s HasMemory: specV1.HasMemory, HasFilesystem: specV1.HasFilesystem, HasNetwork: specV1.HasNetwork, + HasProcesses: specV1.HasProcesses, HasDiskIo: specV1.HasDiskIo, HasCustomMetrics: specV1.HasCustomMetrics, Image: specV1.Image, diff --git a/vendor/github.com/google/cadvisor/metrics/prometheus.go b/vendor/github.com/google/cadvisor/metrics/prometheus.go index a74039fdb6a..aefb6f27463 100644 --- a/vendor/github.com/google/cadvisor/metrics/prometheus.go +++ b/vendor/github.com/google/cadvisor/metrics/prometheus.go @@ -1045,7 +1045,42 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri return metricValues{{value: float64(s.Processes.FdCount), timestamp: s.Timestamp}} }, }, + { + name: "container_sockets", + help: "Number of open sockets for the container.", + valueType: prometheus.GaugeValue, + getValues: func(s *info.ContainerStats) metricValues { + return metricValues{{value: float64(s.Processes.SocketCount), timestamp: s.Timestamp}} + }, + }, + { + name: "container_threads_max", + help: "Maximum number of threads allowed inside the container, infinity if value is zero", + valueType: prometheus.GaugeValue, + getValues: func(s *info.ContainerStats) metricValues { + return metricValues{ + { + value: float64(s.Processes.ThreadsMax), + timestamp: s.Timestamp, + }, + } + }, + }, + { + name: "container_threads", + help: "Number of threads running inside the container", + valueType: prometheus.GaugeValue, + getValues: func(s *info.ContainerStats) metricValues { + return metricValues{ + { + value: float64(s.Processes.ThreadsCurrent), + timestamp: s.Timestamp, + }, + } + }, + }, }...) + } return c @@ -1156,8 +1191,18 @@ func (c *PrometheusCollector) collectContainersInfo(ch chan<- prometheus.Metric) labels := make([]string, 0, len(rawLabels)) containerLabels := c.containerLabelsFunc(cont) for l := range rawLabels { - labels = append(labels, sanitizeLabelName(l)) - values = append(values, containerLabels[l]) + duplicate := false + sl := sanitizeLabelName(l) + for _, x := range labels { + if sl == x { + duplicate = true + break + } + } + if !duplicate { + labels = append(labels, sl) + values = append(values, containerLabels[l]) + } } // Container spec diff --git a/vendor/github.com/google/cadvisor/utils/cloudinfo/aws/aws.go b/vendor/github.com/google/cadvisor/utils/cloudinfo/aws/aws.go index 3b699516599..2c1f611ec6d 100644 --- a/vendor/github.com/google/cadvisor/utils/cloudinfo/aws/aws.go +++ b/vendor/github.com/google/cadvisor/utils/cloudinfo/aws/aws.go @@ -16,7 +16,6 @@ package cloudinfo import ( "io/ioutil" - "os" "strings" "github.com/aws/aws-sdk-go/aws" @@ -28,9 +27,10 @@ import ( ) const ( - productVerFileName = "/sys/class/dmi/id/product_version" - biosVerFileName = "/sys/class/dmi/id/bios_vendor" - amazon = "amazon" + productVerFileName = "/sys/class/dmi/id/product_version" + biosVerFileName = "/sys/class/dmi/id/bios_vendor" + systemdOSReleaseFileName = "/etc/os-release" + amazon = "amazon" ) func init() { @@ -42,23 +42,18 @@ type provider struct{} var _ cloudinfo.CloudProvider = provider{} func (provider) IsActiveProvider() bool { - var dataProduct []byte - var dataBios []byte - if _, err := os.Stat(productVerFileName); err == nil { - dataProduct, err = ioutil.ReadFile(productVerFileName) - if err != nil { - return false - } + return fileContainsAmazonIdentifier(productVerFileName) || + fileContainsAmazonIdentifier(biosVerFileName) || + fileContainsAmazonIdentifier(systemdOSReleaseFileName) +} + +func fileContainsAmazonIdentifier(filename string) bool { + fileContent, err := ioutil.ReadFile(filename) + if err != nil { + return false } - if _, err := os.Stat(biosVerFileName); err == nil { - dataBios, err = ioutil.ReadFile(biosVerFileName) - if err != nil { - return false - } - } - - return strings.Contains(string(dataProduct), amazon) || strings.Contains(strings.ToLower(string(dataBios)), amazon) + return strings.Contains(string(fileContent), amazon) } func getAwsMetadata(name string) string { diff --git a/vendor/github.com/google/cadvisor/utils/cpuload/netlink/BUILD b/vendor/github.com/google/cadvisor/utils/cpuload/netlink/BUILD index fd9b4d5acf9..39084f23528 100644 --- a/vendor/github.com/google/cadvisor/utils/cpuload/netlink/BUILD +++ b/vendor/github.com/google/cadvisor/utils/cpuload/netlink/BUILD @@ -4,16 +4,15 @@ go_library( name = "go_default_library", srcs = [ "conn.go", - "defs.go", "netlink.go", "reader.go", ], - cgo = True, importmap = "k8s.io/kubernetes/vendor/github.com/google/cadvisor/utils/cpuload/netlink", importpath = "github.com/google/cadvisor/utils/cpuload/netlink", visibility = ["//visibility:public"], deps = [ "//vendor/github.com/google/cadvisor/info/v1:go_default_library", + "//vendor/golang.org/x/sys/unix:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/vendor/github.com/google/cadvisor/utils/cpuload/netlink/defs.go b/vendor/github.com/google/cadvisor/utils/cpuload/netlink/defs.go deleted file mode 100644 index a45d8703a8d..00000000000 --- a/vendor/github.com/google/cadvisor/utils/cpuload/netlink/defs.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package netlink - -/* -#include -*/ -import "C" - -type TaskStats C.struct_taskstats - -const ( - __TASKSTATS_CMD_MAX = C.__TASKSTATS_CMD_MAX -) diff --git a/vendor/github.com/google/cadvisor/utils/cpuload/netlink/netlink.go b/vendor/github.com/google/cadvisor/utils/cpuload/netlink/netlink.go index e32b3fd9bda..e2d9d72d579 100644 --- a/vendor/github.com/google/cadvisor/utils/cpuload/netlink/netlink.go +++ b/vendor/github.com/google/cadvisor/utils/cpuload/netlink/netlink.go @@ -22,16 +22,7 @@ import ( "syscall" info "github.com/google/cadvisor/info/v1" -) - -const ( - // Kernel constants for tasks stats. - genlIdCtrl = syscall.NLMSG_MIN_TYPE // GENL_ID_CTRL - taskstatsGenlName = "TASKSTATS" // TASKSTATS_GENL_NAME - cgroupStatsCmdAttrFd = 0x1 // CGROUPSTATS_CMD_ATTR_FD - ctrlAttrFamilyId = 0x1 // CTRL_ATTR_FAMILY_ID - ctrlAttrFamilyName = 0x2 // CTRL_ATTR_FAMILY_NAME - ctrlCmdGetFamily = 0x3 // CTRL_CMD_GETFAMILY + "golang.org/x/sys/unix" ) var ( @@ -124,15 +115,15 @@ func prepareMessage(headerType uint16, cmd uint8, attributes []byte) (msg netlin // Prepares message to query family id for task stats. func prepareFamilyMessage() (msg netlinkMessage) { buf := bytes.NewBuffer([]byte{}) - addAttribute(buf, ctrlAttrFamilyName, taskstatsGenlName, len(taskstatsGenlName)+1) - return prepareMessage(genlIdCtrl, ctrlCmdGetFamily, buf.Bytes()) + addAttribute(buf, unix.CTRL_ATTR_FAMILY_NAME, unix.TASKSTATS_GENL_NAME, len(unix.TASKSTATS_GENL_NAME)+1) + return prepareMessage(unix.GENL_ID_CTRL, unix.CTRL_CMD_GETFAMILY, buf.Bytes()) } // Prepares message to query task stats for a task group. func prepareCmdMessage(id uint16, cfd uintptr) (msg netlinkMessage) { buf := bytes.NewBuffer([]byte{}) - addAttribute(buf, cgroupStatsCmdAttrFd, uint32(cfd), 4) - return prepareMessage(id, __TASKSTATS_CMD_MAX+1, buf.Bytes()) + addAttribute(buf, unix.CGROUPSTATS_CMD_ATTR_FD, uint32(cfd), 4) + return prepareMessage(id, unix.CGROUPSTATS_CMD_GET, buf.Bytes()) } // Extracts returned family id from the response. @@ -158,7 +149,7 @@ func parseFamilyResp(msg syscall.NetlinkMessage) (uint16, error) { if err != nil { return 0, err } - if attr.Type == ctrlAttrFamilyId { + if attr.Type == unix.CTRL_ATTR_FAMILY_ID { err = binary.Read(buf, Endian, &id) if err != nil { return 0, err diff --git a/vendor/github.com/sigma/go-inotify/BUILD b/vendor/github.com/sigma/go-inotify/BUILD deleted file mode 100644 index ffe8ab90bcf..00000000000 --- a/vendor/github.com/sigma/go-inotify/BUILD +++ /dev/null @@ -1,23 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["inotify_linux.go"], - importmap = "k8s.io/kubernetes/vendor/github.com/sigma/go-inotify", - importpath = "github.com/sigma/go-inotify", - visibility = ["//visibility:public"], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/sigma/go-inotify/LICENSE b/vendor/github.com/sigma/go-inotify/LICENSE deleted file mode 100644 index 6a66aea5eaf..00000000000 --- a/vendor/github.com/sigma/go-inotify/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/sigma/go-inotify/PATENTS b/vendor/github.com/sigma/go-inotify/PATENTS deleted file mode 100644 index 733099041f8..00000000000 --- a/vendor/github.com/sigma/go-inotify/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/github.com/sigma/go-inotify/README.md b/vendor/github.com/sigma/go-inotify/README.md deleted file mode 100644 index 0c723a8d2b4..00000000000 --- a/vendor/github.com/sigma/go-inotify/README.md +++ /dev/null @@ -1,5 +0,0 @@ -This is a fork of golang.org/x/exp/inotify before it was deleted. - -Please use gopkg.in/fsnotify.v0 instead. - -For updates, see: https://fsnotify.org/ diff --git a/vendor/github.com/sigma/go-inotify/inotify_linux.go b/vendor/github.com/sigma/go-inotify/inotify_linux.go deleted file mode 100644 index f3071d2cadf..00000000000 --- a/vendor/github.com/sigma/go-inotify/inotify_linux.go +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package inotify implements a wrapper for the Linux inotify system. - -Example: - watcher, err := inotify.NewWatcher() - if err != nil { - log.Fatal(err) - } - err = watcher.Watch("/tmp") - if err != nil { - log.Fatal(err) - } - for { - select { - case ev := <-watcher.Event: - log.Println("event:", ev) - case err := <-watcher.Error: - log.Println("error:", err) - } - } - -*/ -package inotify // import "github.com/sigma/go-inotify" - -import ( - "errors" - "fmt" - "os" - "strings" - "sync" - "syscall" - "unsafe" -) - -type Event struct { - Mask uint32 // Mask of events - Cookie uint32 // Unique cookie associating related events (for rename(2)) - Name string // File name (optional) -} - -type watch struct { - wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall) - flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags) -} - -type Watcher struct { - mu sync.Mutex - fd int // File descriptor (as returned by the inotify_init() syscall) - watches map[string]*watch // Map of inotify watches (key: path) - paths map[int]string // Map of watched paths (key: watch descriptor) - Error chan error // Errors are sent on this channel - Event chan *Event // Events are returned on this channel - done chan bool // Channel for sending a "quit message" to the reader goroutine - isClosed bool // Set to true when Close() is first called -} - -// NewWatcher creates and returns a new inotify instance using inotify_init(2) -func NewWatcher() (*Watcher, error) { - fd, errno := syscall.InotifyInit() - if fd == -1 { - return nil, os.NewSyscallError("inotify_init", errno) - } - w := &Watcher{ - fd: fd, - watches: make(map[string]*watch), - paths: make(map[int]string), - Event: make(chan *Event), - Error: make(chan error), - done: make(chan bool, 1), - } - - go w.readEvents() - return w, nil -} - -// Close closes an inotify watcher instance -// It sends a message to the reader goroutine to quit and removes all watches -// associated with the inotify instance -func (w *Watcher) Close() error { - if w.isClosed { - return nil - } - w.isClosed = true - - // Send "quit" message to the reader goroutine - w.done <- true - for path := range w.watches { - w.RemoveWatch(path) - } - - return nil -} - -// AddWatch adds path to the watched file set. -// The flags are interpreted as described in inotify_add_watch(2). -func (w *Watcher) AddWatch(path string, flags uint32) error { - if w.isClosed { - return errors.New("inotify instance already closed") - } - - watchEntry, found := w.watches[path] - if found { - watchEntry.flags |= flags - flags |= syscall.IN_MASK_ADD - } - - w.mu.Lock() // synchronize with readEvents goroutine - - wd, err := syscall.InotifyAddWatch(w.fd, path, flags) - if err != nil { - w.mu.Unlock() - return &os.PathError{ - Op: "inotify_add_watch", - Path: path, - Err: err, - } - } - - if !found { - w.watches[path] = &watch{wd: uint32(wd), flags: flags} - w.paths[wd] = path - } - w.mu.Unlock() - return nil -} - -// Watch adds path to the watched file set, watching all events. -func (w *Watcher) Watch(path string) error { - return w.AddWatch(path, IN_ALL_EVENTS) -} - -// RemoveWatch removes path from the watched file set. -func (w *Watcher) RemoveWatch(path string) error { - watch, ok := w.watches[path] - if !ok { - return errors.New(fmt.Sprintf("can't remove non-existent inotify watch for: %s", path)) - } - success, errno := syscall.InotifyRmWatch(w.fd, watch.wd) - if success == -1 { - return os.NewSyscallError("inotify_rm_watch", errno) - } - delete(w.watches, path) - // Locking here to protect the read from paths in readEvents. - w.mu.Lock() - delete(w.paths, int(watch.wd)) - w.mu.Unlock() - return nil -} - -// readEvents reads from the inotify file descriptor, converts the -// received events into Event objects and sends them via the Event channel -func (w *Watcher) readEvents() { - var buf [syscall.SizeofInotifyEvent * 4096]byte - - for { - n, err := syscall.Read(w.fd, buf[:]) - // See if there is a message on the "done" channel - var done bool - select { - case done = <-w.done: - default: - } - - // If EOF or a "done" message is received - if n == 0 || done { - // The syscall.Close can be slow. Close - // w.Event first. - close(w.Event) - err := syscall.Close(w.fd) - if err != nil { - w.Error <- os.NewSyscallError("close", err) - } - close(w.Error) - return - } - if n < 0 { - w.Error <- os.NewSyscallError("read", err) - continue - } - if n < syscall.SizeofInotifyEvent { - w.Error <- errors.New("inotify: short read in readEvents()") - continue - } - - var offset uint32 = 0 - // We don't know how many events we just read into the buffer - // While the offset points to at least one whole event... - for offset <= uint32(n-syscall.SizeofInotifyEvent) { - // Point "raw" to the event in the buffer - raw := (*syscall.InotifyEvent)(unsafe.Pointer(&buf[offset])) - event := new(Event) - event.Mask = uint32(raw.Mask) - event.Cookie = uint32(raw.Cookie) - nameLen := uint32(raw.Len) - // If the event happened to the watched directory or the watched file, the kernel - // doesn't append the filename to the event, but we would like to always fill the - // the "Name" field with a valid filename. We retrieve the path of the watch from - // the "paths" map. - w.mu.Lock() - name, ok := w.paths[int(raw.Wd)] - w.mu.Unlock() - if ok { - event.Name = name - if nameLen > 0 { - // Point "bytes" at the first byte of the filename - bytes := (*[syscall.PathMax]byte)(unsafe.Pointer(&buf[offset+syscall.SizeofInotifyEvent])) - // The filename is padded with NUL bytes. TrimRight() gets rid of those. - event.Name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000") - } - // Send the event on the events channel - w.Event <- event - } - // Move to the next event in the buffer - offset += syscall.SizeofInotifyEvent + nameLen - } - } -} - -// String formats the event e in the form -// "filename: 0xEventMask = IN_ACCESS|IN_ATTRIB_|..." -func (e *Event) String() string { - var events string = "" - - m := e.Mask - for _, b := range eventBits { - if m&b.Value == b.Value { - m &^= b.Value - events += "|" + b.Name - } - } - - if m != 0 { - events += fmt.Sprintf("|%#x", m) - } - if len(events) > 0 { - events = " == " + events[1:] - } - - return fmt.Sprintf("%q: %#x%s", e.Name, e.Mask, events) -} - -const ( - // Options for inotify_init() are not exported - // IN_CLOEXEC uint32 = syscall.IN_CLOEXEC - // IN_NONBLOCK uint32 = syscall.IN_NONBLOCK - - // Options for AddWatch - IN_DONT_FOLLOW uint32 = syscall.IN_DONT_FOLLOW - IN_ONESHOT uint32 = syscall.IN_ONESHOT - IN_ONLYDIR uint32 = syscall.IN_ONLYDIR - - // The "IN_MASK_ADD" option is not exported, as AddWatch - // adds it automatically, if there is already a watch for the given path - // IN_MASK_ADD uint32 = syscall.IN_MASK_ADD - - // Events - IN_ACCESS uint32 = syscall.IN_ACCESS - IN_ALL_EVENTS uint32 = syscall.IN_ALL_EVENTS - IN_ATTRIB uint32 = syscall.IN_ATTRIB - IN_CLOSE uint32 = syscall.IN_CLOSE - IN_CLOSE_NOWRITE uint32 = syscall.IN_CLOSE_NOWRITE - IN_CLOSE_WRITE uint32 = syscall.IN_CLOSE_WRITE - IN_CREATE uint32 = syscall.IN_CREATE - IN_DELETE uint32 = syscall.IN_DELETE - IN_DELETE_SELF uint32 = syscall.IN_DELETE_SELF - IN_MODIFY uint32 = syscall.IN_MODIFY - IN_MOVE uint32 = syscall.IN_MOVE - IN_MOVED_FROM uint32 = syscall.IN_MOVED_FROM - IN_MOVED_TO uint32 = syscall.IN_MOVED_TO - IN_MOVE_SELF uint32 = syscall.IN_MOVE_SELF - IN_OPEN uint32 = syscall.IN_OPEN - - // Special events - IN_ISDIR uint32 = syscall.IN_ISDIR - IN_IGNORED uint32 = syscall.IN_IGNORED - IN_Q_OVERFLOW uint32 = syscall.IN_Q_OVERFLOW - IN_UNMOUNT uint32 = syscall.IN_UNMOUNT -) - -var eventBits = []struct { - Value uint32 - Name string -}{ - {IN_ACCESS, "IN_ACCESS"}, - {IN_ATTRIB, "IN_ATTRIB"}, - {IN_CLOSE, "IN_CLOSE"}, - {IN_CLOSE_NOWRITE, "IN_CLOSE_NOWRITE"}, - {IN_CLOSE_WRITE, "IN_CLOSE_WRITE"}, - {IN_CREATE, "IN_CREATE"}, - {IN_DELETE, "IN_DELETE"}, - {IN_DELETE_SELF, "IN_DELETE_SELF"}, - {IN_MODIFY, "IN_MODIFY"}, - {IN_MOVE, "IN_MOVE"}, - {IN_MOVED_FROM, "IN_MOVED_FROM"}, - {IN_MOVED_TO, "IN_MOVED_TO"}, - {IN_MOVE_SELF, "IN_MOVE_SELF"}, - {IN_OPEN, "IN_OPEN"}, - {IN_ISDIR, "IN_ISDIR"}, - {IN_IGNORED, "IN_IGNORED"}, - {IN_Q_OVERFLOW, "IN_Q_OVERFLOW"}, - {IN_UNMOUNT, "IN_UNMOUNT"}, -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 14491fbac9e..8c9e4c40dc9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -418,7 +418,7 @@ github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/wrappers # github.com/google/btree v0.0.0-20160524151835-7d79101e329e => github.com/google/btree v0.0.0-20160524151835-7d79101e329e github.com/google/btree -# github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a => github.com/google/cadvisor v0.33.2-0.20190411163913-9db8c7dee20a +# github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 => github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 github.com/google/cadvisor/accelerators github.com/google/cadvisor/cache/memory github.com/google/cadvisor/client/v2 @@ -728,8 +728,6 @@ github.com/russross/blackfriday github.com/satori/go.uuid # github.com/seccomp/libseccomp-golang v0.9.1 => github.com/seccomp/libseccomp-golang v0.9.1 github.com/seccomp/libseccomp-golang -# github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d => github.com/sigma/go-inotify v0.0.0-20181102212354-c87b6cf5033d -github.com/sigma/go-inotify # github.com/sirupsen/logrus v1.4.2 => github.com/sirupsen/logrus v1.4.2 github.com/sirupsen/logrus # github.com/soheilhy/cmux v0.1.3 => github.com/soheilhy/cmux v0.1.3