Bump cAdvisor to v0.49.0

Signed-off-by: David Porter <david@porter.me>
This commit is contained in:
David Porter
2024-02-29 14:21:49 -08:00
parent 0d50a398df
commit c05e541793
10 changed files with 52 additions and 17 deletions

View File

@@ -44,6 +44,7 @@ var (
type Info struct {
StorageDriver string `json:"storage_driver"`
StorageRoot string `json:"storage_root"`
StorageImage string `json:"storage_image"`
}
// ContainerInfo represents a given container information

View File

@@ -32,6 +32,9 @@ import (
// The namespace under which crio aliases are unique.
const CrioNamespace = "crio"
// The namespace suffix under which crio aliases are unique.
const CrioNamespaceSuffix = ".scope"
// The namespace systemd runs components under.
const SystemdNamespace = "system-systemd"
@@ -114,16 +117,21 @@ func (f *crioFactory) CanHandleAndAccept(name string) (bool, bool, error) {
// TODO(runcom): should we include crio-conmon cgroups?
return false, false, nil
}
if !strings.HasPrefix(path.Base(name), CrioNamespace) {
return false, false, nil
}
if strings.HasPrefix(path.Base(name), SystemdNamespace) {
return true, false, nil
}
if !strings.HasPrefix(path.Base(name), CrioNamespace) {
return false, false, nil
}
// if the container is not associated with CRI-O, we can't handle it or accept it.
if !isContainerName(name) {
return false, false, nil
}
if !strings.HasSuffix(path.Base(name), CrioNamespaceSuffix) {
// this mean it's a sandbox container
return true, false, nil
}
return true, true, nil
}

View File

@@ -40,7 +40,7 @@ func (p *plugin) InitializeFSContext(context *fs.Context) error {
if err != nil {
klog.V(5).Infof("CRI-O not connected: %v", err)
} else {
context.Crio = fs.CrioContext{Root: crioInfo.StorageRoot}
context.Crio = fs.CrioContext{Root: crioInfo.StorageRoot, ImageStore: crioInfo.StorageImage, Driver: crioInfo.StorageDriver}
}
return nil
}

View File

@@ -43,6 +43,7 @@ const (
LabelSystemRoot = "root"
LabelDockerImages = "docker-images"
LabelCrioImages = "crio-images"
LabelCrioContainers = "crio-containers"
DriverStatusPoolName = "Pool Name"
DriverStatusDataLoopFile = "Data loop file"
)
@@ -295,14 +296,37 @@ func (i *RealFsInfo) addDockerImagesLabel(context Context, mounts []*mount.Info)
}
func (i *RealFsInfo) addCrioImagesLabel(context Context, mounts []*mount.Info) {
labelCrioImageOrContainers := LabelCrioContainers
// If imagestore is not specified, let's fall back to the original case.
// Everything will be stored in crio-images
if context.Crio.ImageStore == "" {
labelCrioImageOrContainers = LabelCrioImages
}
if context.Crio.Root != "" {
crioPath := context.Crio.Root
crioImagePaths := map[string]struct{}{
"/": {},
}
for _, dir := range []string{"devicemapper", "btrfs", "aufs", "overlay", "zfs"} {
crioImagePaths[path.Join(crioPath, dir+"-images")] = struct{}{}
imageOrContainerPath := context.Crio.Driver + "-containers"
if context.Crio.ImageStore == "" {
// If ImageStore is not specified then we will assume ImageFs is complete separate.
// No need to split the image store.
imageOrContainerPath = context.Crio.Driver + "-images"
}
crioImagePaths[path.Join(crioPath, imageOrContainerPath)] = struct{}{}
for crioPath != "/" && crioPath != "." {
crioImagePaths[crioPath] = struct{}{}
crioPath = filepath.Dir(crioPath)
}
i.updateContainerImagesPath(labelCrioImageOrContainers, mounts, crioImagePaths)
}
if context.Crio.ImageStore != "" {
crioPath := context.Crio.ImageStore
crioImagePaths := map[string]struct{}{
"/": {},
}
crioImagePaths[path.Join(crioPath, context.Crio.Driver+"-images")] = struct{}{}
for crioPath != "/" && crioPath != "." {
crioImagePaths[crioPath] = struct{}{}
crioPath = filepath.Dir(crioPath)

View File

@@ -38,7 +38,9 @@ type PodmanContext struct {
}
type CrioContext struct {
Root string
Root string
ImageStore string
Driver string
}
type DeviceInfo struct {

View File

@@ -253,9 +253,9 @@ func (c *collector) createLeaderFileDescriptors(events []Event, cgroupFd int, gr
}
func readPerfEventAttr(name string, pfmGetOsEventEncoding func(string, unsafe.Pointer) error) (*unix.PerfEventAttr, error) {
perfEventAttrMemory := C.malloc(C.ulong(unsafe.Sizeof(unix.PerfEventAttr{})))
perfEventAttrMemory := C.malloc(C.size_t(unsafe.Sizeof(unix.PerfEventAttr{})))
// Fill memory with 0 values.
C.memset(perfEventAttrMemory, 0, C.ulong(unsafe.Sizeof(unix.PerfEventAttr{})))
C.memset(perfEventAttrMemory, 0, C.size_t(unsafe.Sizeof(unix.PerfEventAttr{})))
err := pfmGetOsEventEncoding(name, unsafe.Pointer(perfEventAttrMemory))
if err != nil {
return nil, err
@@ -269,7 +269,7 @@ func pfmGetOsEventEncoding(name string, perfEventAttrMemory unsafe.Pointer) erro
defer C.free(unsafe.Pointer(fstr))
event.fstr = unsafe.Pointer(fstr)
event.attr = perfEventAttrMemory
event.size = C.ulong(unsafe.Sizeof(event))
event.size = C.size_t(unsafe.Sizeof(event))
cSafeName := C.CString(name)
defer C.free(unsafe.Pointer(cSafeName))
pErr := C.pfm_get_os_event_encoding(cSafeName, C.PFM_PLM0|C.PFM_PLM3, C.PFM_OS_PERF_EVENT, unsafe.Pointer(&event))

View File

@@ -22,7 +22,7 @@ import info "github.com/google/cadvisor/info/v1"
// For each container detected by the cAdvisor manager, it will call
// GetCollector() with the devices cgroup path for that container.
// GetCollector() is supposed to return an object that can update
// accelerator stats for that container.
// external stats for that container.
type Manager interface {
Destroy()
GetCollector(deviceCgroup string) (Collector, error)