runcfanotify

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Supported

func Supported() bool

Supported detects if RuncNotifier is supported in the current environment

Types

type ContainerEvent

type ContainerEvent struct {
	// Type is whether the container was added or removed
	Type EventType

	// ContainerID is the container id, typically a 64 hexadecimal string
	ContainerID string

	// ContainerPID is the process id of the container
	ContainerPID uint32

	// Container's configuration is the config.json from the OCI runtime
	// spec
	ContainerConfig *ocispec.Spec

	// Bundle is the directory containing the config.json from the OCI
	// runtime spec
	// See https://github.com/opencontainers/runtime-spec/blob/main/bundle.md
	Bundle string
}

ContainerEvent is the notification for container creation or termination

type EventType

type EventType int
const (
	EventTypeAddContainer EventType = iota
	EventTypeRemoveContainer
)

type RuncNotifier

type RuncNotifier struct {
	// contains filtered or unexported fields
}

func NewRuncNotifier

func NewRuncNotifier(callback RuncNotifyFunc) (*RuncNotifier, error)

NewRuncNotifier uses fanotify to detect when runc containers are created or terminated, and call the callback on such event.

Limitations: - runc must be installed in one of the paths listed by runcPaths

func (*RuncNotifier) AddWatchContainerTermination

func (n *RuncNotifier) AddWatchContainerTermination(containerID string, containerPID int) error

AddWatchContainerTermination watches a container for termination and generates an event on the notifier. This is automatically called for new containers detected by RuncNotifier, but it can also be called for containers detected externally such as initial containers.

func (*RuncNotifier) Close

func (n *RuncNotifier) Close()

type RuncNotifyFunc

type RuncNotifyFunc func(notif ContainerEvent)

Jump to

Keyboard shortcuts

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