address jon and vish comments
This commit is contained in:
parent
4d0f8fafbe
commit
ee52fdf4d1
@ -58,7 +58,7 @@ func RktPath() (string, error) {
|
|||||||
|
|
||||||
resp, err := client.GetInfo(context.Background(), &rktapi.GetInfoRequest{})
|
resp, err := client.GetInfo(context.Background(), &rktapi.GetInfoRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("couldn't GetInfo from rkt api servie: %v", err)
|
return "", fmt.Errorf("couldn't GetInfo from rkt api service: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Info.GlobalFlags.Dir, nil
|
return resp.Info.GlobalFlags.Dir, nil
|
||||||
|
@ -18,12 +18,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
rktapi "github.com/coreos/rkt/api/v1alpha"
|
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
"github.com/google/cadvisor/container/libcontainer"
|
"github.com/google/cadvisor/container/libcontainer"
|
||||||
"github.com/google/cadvisor/fs"
|
"github.com/google/cadvisor/fs"
|
||||||
info "github.com/google/cadvisor/info/v1"
|
info "github.com/google/cadvisor/info/v1"
|
||||||
"golang.org/x/net/context"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -60,8 +58,9 @@ func (self *rktFactory) NewContainerHandler(name string, inHostNamespace bool) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
func (self *rktFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
||||||
// TODO{SJP}: will ignore all cgroup names that don't either correspond to the machine.slice that is the pod
|
// will ignore all cgroup names that don't either correspond to the machine.slice that is the pod or the containers that belong to the pod
|
||||||
// or the containers that belong to the pod
|
// only works for machined rkt pods at the moment
|
||||||
|
|
||||||
if strings.HasPrefix(name, "/machine.slice/machine-rkt\\x2d") {
|
if strings.HasPrefix(name, "/machine.slice/machine-rkt\\x2d") {
|
||||||
accept, err := verifyName(name)
|
accept, err := verifyName(name)
|
||||||
return true, accept, err
|
return true, accept, err
|
||||||
@ -74,16 +73,15 @@ func (self *rktFactory) DebugInfo() map[string][]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Register(machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, ignoreMetrics container.MetricSet) error {
|
func Register(machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, ignoreMetrics container.MetricSet) error {
|
||||||
client, err := Client()
|
_, err := Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to communicate with Rkt api service: %v", err)
|
return fmt.Errorf("unable to communicate with Rkt api service: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.GetInfo(context.Background(), &rktapi.GetInfoRequest{})
|
rktPath, err := RktPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("couldn't GetInfo from rkt api servie: %v", err)
|
return fmt.Errorf("unable to get the RktPath variable %v", err)
|
||||||
}
|
}
|
||||||
rktPath := resp.Info.GlobalFlags.Dir
|
|
||||||
|
|
||||||
cgroupSubsystems, err := libcontainer.GetCgroupSubsystems()
|
cgroupSubsystems, err := libcontainer.GetCgroupSubsystems()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -66,34 +66,38 @@ type rktContainerHandler struct {
|
|||||||
|
|
||||||
rootfsStorageDir string
|
rootfsStorageDir string
|
||||||
|
|
||||||
|
labels map[string]string
|
||||||
|
|
||||||
// Filesystem handler.
|
// Filesystem handler.
|
||||||
fsHandler common.FsHandler
|
fsHandler common.FsHandler
|
||||||
|
|
||||||
ignoreMetrics container.MetricSet
|
ignoreMetrics container.MetricSet
|
||||||
|
|
||||||
|
apiPod *rktapi.Pod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetCgroupPaths() map[string]string {
|
func (handler *rktContainerHandler) GetCgroupPaths() map[string]string {
|
||||||
return self.cgroupPaths
|
return handler.cgroupPaths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetMachineInfoFactory() info.MachineInfoFactory {
|
func (handler *rktContainerHandler) GetMachineInfoFactory() info.MachineInfoFactory {
|
||||||
return self.machineInfoFactory
|
return handler.machineInfoFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetName() string {
|
func (handler *rktContainerHandler) GetName() string {
|
||||||
return self.name
|
return handler.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetExternalMounts() []common.Mount {
|
func (handler *rktContainerHandler) GetExternalMounts() []common.Mount {
|
||||||
return self.externalMounts
|
return handler.externalMounts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) HasNetwork() bool {
|
func (handler *rktContainerHandler) HasNetwork() bool {
|
||||||
return self.hasNetwork && !self.ignoreMetrics.Has(container.NetworkUsageMetrics)
|
return handler.hasNetwork && !handler.ignoreMetrics.Has(container.NetworkUsageMetrics)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) HasFilesystem() bool {
|
func (handler *rktContainerHandler) HasFilesystem() bool {
|
||||||
if !self.ignoreMetrics.Has(container.DiskUsageMetrics) {
|
if !handler.ignoreMetrics.Has(container.DiskUsageMetrics) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -103,6 +107,8 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
|
|||||||
aliases := make([]string, 1)
|
aliases := make([]string, 1)
|
||||||
isPod := false
|
isPod := false
|
||||||
|
|
||||||
|
apiPod := &rktapi.Pod{}
|
||||||
|
|
||||||
parsed, err := parseName(name)
|
parsed, err := parseName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
|
return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
|
||||||
@ -117,25 +123,29 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
pid := os.Getpid()
|
pid := os.Getpid()
|
||||||
if parsed.Container == "" {
|
labels := make(map[string]string)
|
||||||
resp, err := rktClient.InspectPod(context.Background(), &rktapi.InspectPodRequest{
|
resp, err := rktClient.InspectPod(context.Background(), &rktapi.InspectPodRequest{
|
||||||
Id: parsed.Pod,
|
Id: parsed.Pod,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
|
||||||
pid = int(resp.Pod.Pid)
|
|
||||||
} else {
|
} else {
|
||||||
glog.Infof("skipping as Container")
|
var annotations []*rktapi.KeyValue
|
||||||
|
if parsed.Container == "" {
|
||||||
|
pid = int(resp.Pod.Pid)
|
||||||
|
apiPod = resp.Pod
|
||||||
|
annotations = resp.Pod.Annotations
|
||||||
|
} else {
|
||||||
|
var ok bool
|
||||||
|
if annotations, ok = findAnnotations(resp.Pod.Apps, parsed.Container); !ok {
|
||||||
|
glog.Warningf("couldn't find application in Pod matching %v", parsed.Container)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
labels = createLabels(annotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
|
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
|
||||||
|
|
||||||
cHints, err := common.GetContainerHintsFromFile(*common.ArgContainerHints)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate the equivalent cgroup manager for this container.
|
// Generate the equivalent cgroup manager for this container.
|
||||||
cgroupManager := &cgroupfs.Manager{
|
cgroupManager := &cgroupfs.Manager{
|
||||||
Cgroups: &configs.Cgroup{
|
Cgroups: &configs.Cgroup{
|
||||||
@ -149,15 +159,6 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
|
|||||||
hasNetwork = true
|
hasNetwork = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//SJP: unsure the point of this code, if it event does anything today?
|
|
||||||
var externalMounts []common.Mount
|
|
||||||
for _, container := range cHints.AllHosts {
|
|
||||||
if name == container.FullName {
|
|
||||||
externalMounts = container.Mounts
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootfsStorageDir := getRootFs(rktPath, parsed)
|
rootfsStorageDir := getRootFs(rktPath, parsed)
|
||||||
|
|
||||||
handler := &rktContainerHandler{
|
handler := &rktContainerHandler{
|
||||||
@ -169,13 +170,14 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
|
|||||||
cgroupManager: cgroupManager,
|
cgroupManager: cgroupManager,
|
||||||
fsInfo: fsInfo,
|
fsInfo: fsInfo,
|
||||||
hasNetwork: hasNetwork,
|
hasNetwork: hasNetwork,
|
||||||
externalMounts: externalMounts,
|
|
||||||
rootFs: rootFs,
|
rootFs: rootFs,
|
||||||
isPod: isPod,
|
isPod: isPod,
|
||||||
aliases: aliases,
|
aliases: aliases,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
|
labels: labels,
|
||||||
rootfsStorageDir: rootfsStorageDir,
|
rootfsStorageDir: rootfsStorageDir,
|
||||||
ignoreMetrics: ignoreMetrics,
|
ignoreMetrics: ignoreMetrics,
|
||||||
|
apiPod: apiPod,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ignoreMetrics.Has(container.DiskUsageMetrics) {
|
if !ignoreMetrics.Has(container.DiskUsageMetrics) {
|
||||||
@ -185,50 +187,68 @@ func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPa
|
|||||||
return handler, nil
|
return handler, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) ContainerReference() (info.ContainerReference, error) {
|
func findAnnotations(apps []*rktapi.App, container string) ([]*rktapi.KeyValue, bool) {
|
||||||
|
for _, app := range apps {
|
||||||
|
if app.Name == container {
|
||||||
|
return app.Annotations, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func createLabels(annotations []*rktapi.KeyValue) map[string]string {
|
||||||
|
labels := make(map[string]string)
|
||||||
|
for _, kv := range annotations {
|
||||||
|
labels[kv.Key] = kv.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels
|
||||||
|
}
|
||||||
|
|
||||||
|
func (handler *rktContainerHandler) ContainerReference() (info.ContainerReference, error) {
|
||||||
return info.ContainerReference{
|
return info.ContainerReference{
|
||||||
Name: self.name,
|
Name: handler.name,
|
||||||
Aliases: self.aliases,
|
Aliases: handler.aliases,
|
||||||
Namespace: RktNamespace,
|
Namespace: RktNamespace,
|
||||||
|
Labels: handler.labels,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//SJP: Should a Rkt containe have have htis?
|
//Only the Raw handler will return something of value here
|
||||||
func (self *rktContainerHandler) GetRootNetworkDevices() ([]info.NetInfo, error) {
|
func (handler *rktContainerHandler) GetRootNetworkDevices() ([]info.NetInfo, error) {
|
||||||
nd := []info.NetInfo{}
|
nd := []info.NetInfo{}
|
||||||
return nd, nil
|
return nd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) Start() {
|
func (handler *rktContainerHandler) Start() {
|
||||||
self.fsHandler.Start()
|
handler.fsHandler.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) Cleanup() {
|
func (handler *rktContainerHandler) Cleanup() {
|
||||||
self.fsHandler.Stop()
|
handler.fsHandler.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
func (handler *rktContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
||||||
return common.GetSpec(self)
|
return common.GetSpec(handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
func (handler *rktContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||||
if self.ignoreMetrics.Has(container.DiskUsageMetrics) {
|
if handler.ignoreMetrics.Has(container.DiskUsageMetrics) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceInfo, err := self.fsInfo.GetDirFsDevice(self.rootfsStorageDir)
|
deviceInfo, err := handler.fsInfo.GetDirFsDevice(handler.rootfsStorageDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mi, err := self.machineInfoFactory.GetMachineInfo()
|
mi, err := handler.machineInfoFactory.GetMachineInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var limit uint64 = 0
|
var limit uint64 = 0
|
||||||
|
|
||||||
// SJP: Docker does not impose any filesystem limits for containers. So it uses capacity as limit.
|
// Use capacity as limit.
|
||||||
// Doing the same for Rkt. is this true?
|
|
||||||
for _, fs := range mi.Filesystems {
|
for _, fs := range mi.Filesystems {
|
||||||
if fs.Device == deviceInfo.Device {
|
if fs.Device == deviceInfo.Device {
|
||||||
limit = fs.Capacity
|
limit = fs.Capacity
|
||||||
@ -238,21 +258,21 @@ func (self *rktContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
|||||||
|
|
||||||
fsStat := info.FsStats{Device: deviceInfo.Device, Limit: limit}
|
fsStat := info.FsStats{Device: deviceInfo.Device, Limit: limit}
|
||||||
|
|
||||||
fsStat.BaseUsage, fsStat.Usage = self.fsHandler.Usage()
|
fsStat.BaseUsage, fsStat.Usage = handler.fsHandler.Usage()
|
||||||
|
|
||||||
stats.Filesystem = append(stats.Filesystem, fsStat)
|
stats.Filesystem = append(stats.Filesystem, fsStat)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
|
func (handler *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
|
||||||
stats, err := libcontainer.GetStats(self.cgroupManager, self.rootFs, self.pid, self.ignoreMetrics)
|
stats, err := libcontainer.GetStats(handler.cgroupManager, handler.rootFs, handler.pid, handler.ignoreMetrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stats, err
|
return stats, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get filesystem stats.
|
// Get filesystem stats.
|
||||||
err = self.getFsStats(stats)
|
err = handler.getFsStats(stats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stats, err
|
return stats, err
|
||||||
}
|
}
|
||||||
@ -260,38 +280,37 @@ func (self *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
|
|||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetCgroupPath(resource string) (string, error) {
|
func (handler *rktContainerHandler) GetCgroupPath(resource string) (string, error) {
|
||||||
path, ok := self.cgroupPaths[resource]
|
path, ok := handler.cgroupPaths[resource]
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("could not find path for resource %q for container %q\n", resource, self.name)
|
return "", fmt.Errorf("could not find path for resource %q for container %q\n", resource, handler.name)
|
||||||
}
|
}
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO{SJP} need to figure out what to put here
|
func (handler *rktContainerHandler) GetContainerLabels() map[string]string {
|
||||||
func (self *rktContainerHandler) GetContainerLabels() map[string]string {
|
return handler.labels
|
||||||
return map[string]string{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) ListContainers(listType container.ListType) ([]info.ContainerReference, error) {
|
func (handler *rktContainerHandler) ListContainers(listType container.ListType) ([]info.ContainerReference, error) {
|
||||||
containers := make(map[string]struct{})
|
containers := make(map[string]struct{})
|
||||||
|
|
||||||
// Rkt containers do not have subcontainers, only the "Pod" does.
|
// Rkt containers do not have subcontainers, only the "Pod" does.
|
||||||
if self.isPod == false {
|
if handler.isPod == false {
|
||||||
var ret []info.ContainerReference
|
var ret []info.ContainerReference
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn the system.slice cgroups into the Pod's subcontainers
|
// Turn the system.slice cgroups into the Pod's subcontainers
|
||||||
for _, cgroupPath := range self.cgroupPaths {
|
for _, cgroupPath := range handler.cgroupPaths {
|
||||||
err := common.ListDirectories(path.Join(cgroupPath, "system.slice"), path.Join(self.name, "system.slice"), listType == container.ListRecursive, containers)
|
err := common.ListDirectories(path.Join(cgroupPath, "system.slice"), path.Join(handler.name, "system.slice"), listType == container.ListRecursive, containers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the container references. for the Pod's subcontainers
|
// Create the container references. for the Pod's subcontainers
|
||||||
ret := make([]info.ContainerReference, 0, len(containers))
|
ret := make([]info.ContainerReference, 0, len(handler.apiPod.Apps))
|
||||||
for cont := range containers {
|
for cont := range containers {
|
||||||
aliases := make([]string, 1)
|
aliases := make([]string, 1)
|
||||||
parsed, err := parseName(cont)
|
parsed, err := parseName(cont)
|
||||||
@ -300,37 +319,45 @@ func (self *rktContainerHandler) ListContainers(listType container.ListType) ([]
|
|||||||
}
|
}
|
||||||
aliases = append(aliases, parsed.Pod+":"+parsed.Container)
|
aliases = append(aliases, parsed.Pod+":"+parsed.Container)
|
||||||
|
|
||||||
|
labels := make(map[string]string)
|
||||||
|
if annotations, ok := findAnnotations(handler.apiPod.Apps, parsed.Container); !ok {
|
||||||
|
glog.Warningf("couldn't find application in Pod matching %v", parsed.Container)
|
||||||
|
} else {
|
||||||
|
labels = createLabels(annotations)
|
||||||
|
}
|
||||||
|
|
||||||
ret = append(ret, info.ContainerReference{
|
ret = append(ret, info.ContainerReference{
|
||||||
Name: cont,
|
Name: cont,
|
||||||
Aliases: aliases,
|
Aliases: aliases,
|
||||||
Namespace: RktNamespace,
|
Namespace: RktNamespace,
|
||||||
|
Labels: labels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) ListThreads(listType container.ListType) ([]int, error) {
|
func (handler *rktContainerHandler) ListThreads(listType container.ListType) ([]int, error) {
|
||||||
// TODO(vmarmol): Implement
|
// TODO(sjpotter): Implement? Not implemented with docker yet
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
|
func (handler *rktContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
|
||||||
return libcontainer.GetProcesses(self.cgroupManager)
|
return libcontainer.GetProcesses(handler.cgroupManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
|
func (handler *rktContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
|
||||||
return fmt.Errorf("watch is unimplemented in the Rkt container driver")
|
return fmt.Errorf("watch is unimplemented in the Rkt container driver")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) StopWatchingSubcontainers() error {
|
func (handler *rktContainerHandler) StopWatchingSubcontainers() error {
|
||||||
// No-op for Rkt driver.
|
// No-op for Rkt driver.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *rktContainerHandler) Exists() bool {
|
func (handler *rktContainerHandler) Exists() bool {
|
||||||
// If any cgroup exists, the container is still alive.
|
// If any cgroup exists, the container is still alive.
|
||||||
for _, cgroupPath := range self.cgroupPaths {
|
for _, cgroupPath := range handler.cgroupPaths {
|
||||||
if utils.FileExists(cgroupPath) {
|
if utils.FileExists(cgroupPath) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ func verifyName(name string) (bool, error) {
|
|||||||
pod - /sys/fs/cgroup/cpu/machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/
|
pod - /sys/fs/cgroup/cpu/machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/
|
||||||
container under pod - /sys/fs/cgroup/cpu/machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/system.slice/alpine-sh.service
|
container under pod - /sys/fs/cgroup/cpu/machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/system.slice/alpine-sh.service
|
||||||
*/
|
*/
|
||||||
|
//TODO{sjpotter}: this currently only recognizes machined started pods, which actually doesn't help with k8s which uses them as systemd services, need a solution for both
|
||||||
func parseName(name string) (*parsedName, error) {
|
func parseName(name string) (*parsedName, error) {
|
||||||
splits := strings.Split(name, "/")
|
splits := strings.Split(name, "/")
|
||||||
if len(splits) == 3 || len(splits) == 5 {
|
if len(splits) == 3 || len(splits) == 5 {
|
||||||
@ -79,7 +80,7 @@ func getRootFs(root string, parsed *parsedName) string {
|
|||||||
|
|
||||||
bytes, err := ioutil.ReadFile(tree)
|
bytes, err := ioutil.ReadFile(tree)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Infof("ReadFile failed: %v", err)
|
glog.Infof("ReadFile failed, couldn't read %v to get upper dir: %v", tree, err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
fs/fs.go
4
fs/fs.go
@ -209,8 +209,8 @@ func getDockerImagePaths(context Context) map[string]struct{} {
|
|||||||
return dockerImagePaths
|
return dockerImagePaths
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method compares the mountpoints with possible docker image mount points. If a match is found,
|
// This method compares the mountpoints with possible container image mount points. If a match is found,
|
||||||
// docker images label is added to the partition.
|
// the label is added to the partition.
|
||||||
func (self *RealFsInfo) updateContainerImagesPath(label string, mounts []*mount.Info, containerImagePaths map[string]struct{}) {
|
func (self *RealFsInfo) updateContainerImagesPath(label string, mounts []*mount.Info, containerImagePaths map[string]struct{}) {
|
||||||
var useMount *mount.Info
|
var useMount *mount.Info
|
||||||
for _, m := range mounts {
|
for _, m := range mounts {
|
||||||
|
Loading…
Reference in New Issue
Block a user