cgroup

package
v0.0.0-...-701ea4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cgroup holds cgroup related files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event int

Event defines the cgroup event type

const (
	// CGroupDeleted is used to notify that a cgroup was deleted
	CGroupDeleted Event = iota + 1
	// CGroupCreated new croup created
	CGroupCreated
	// CGroupMaxEvent is used cap the event ID
	CGroupMaxEvent
)

type Resolver

type Resolver struct {
	*utils.Notifier[Event, *cgroupModel.CacheEntry]
	sync.Mutex
	// contains filtered or unexported fields
}

Resolver defines a cgroup monitor

func NewResolver

func NewResolver() (*Resolver, error)

NewResolver returns a new cgroups monitor

func (*Resolver) AddPID

func (cr *Resolver) AddPID(process *model.ProcessCacheEntry)

AddPID associates a container id and a pid which is expected to be the pid 1

func (*Resolver) DelPID

func (cr *Resolver) DelPID(pid uint32)

DelPID removes a PID from the cgroup resolver

func (*Resolver) DelPIDWithID

func (cr *Resolver) DelPIDWithID(id containerutils.ContainerID, pid uint32)

DelPIDWithID removes a PID from the cgroup cache entry referenced by the provided ID

func (*Resolver) GetCGroupContext

func (cr *Resolver) GetCGroupContext(cgroupPath model.PathKey) (*model.CGroupContext, bool)

GetCGroupContext returns the cgroup context with the specified path key

func (*Resolver) GetWorkload

GetWorkload returns the workload referenced by the provided ID

func (*Resolver) Len

func (cr *Resolver) Len() int

Len return the number of entries

func (*Resolver) Start

func (cr *Resolver) Start(_ context.Context)

Start starts the goroutine of the SBOM resolver

type ResolverInterface

type ResolverInterface interface {
	Start(context.Context)
	AddPID(*model.ProcessCacheEntry)
	GetWorkload(containerutils.ContainerID) (*cgroupModel.CacheEntry, bool)
	DelPID(uint32)
	DelPIDWithID(containerutils.ContainerID, uint32)
	Len() int
	RegisterListener(Event, utils.Listener[*cgroupModel.CacheEntry]) error
}

ResolverInterface defines the interface implemented by a cgroup resolver

Directories

Path Synopsis
Package model holds model related files
Package model holds model related files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL