 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package container defines types for sub-container events and also defines an interface for container operation handlers.
Index ¶
- Variables
- func ClearContainerHandlerFactories()
- func DebugInfo() map[string][]string
- func HasFactories() bool
- func InitializeFSContext(context *fs.Context) error
- func InitializePlugins(factory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics MetricSet) []watcher.ContainerWatcher
- func RegisterContainerHandlerFactory(factory ContainerHandlerFactory, watchTypes []watcher.ContainerWatchSource)
- func RegisterPlugin(name string, plugin Plugin) error
- type ContainerHandler
- type ContainerHandlerFactory
- type ContainerType
- type ListType
- type MetricKind
- type MetricSet
- type Plugin
Constants ¶
This section is empty.
Variables ¶
var AllMetrics = MetricSet{ CpuUsageMetrics: struct{}{}, ProcessSchedulerMetrics: struct{}{}, PerCpuUsageMetrics: struct{}{}, MemoryUsageMetrics: struct{}{}, MemoryNumaMetrics: struct{}{}, CpuLoadMetrics: struct{}{}, DiskIOMetrics: struct{}{}, AcceleratorUsageMetrics: struct{}{}, DiskUsageMetrics: struct{}{}, NetworkUsageMetrics: struct{}{}, NetworkTcpUsageMetrics: struct{}{}, NetworkAdvancedTcpUsageMetrics: struct{}{}, NetworkUdpUsageMetrics: struct{}{}, ProcessMetrics: struct{}{}, AppMetrics: struct{}{}, HugetlbUsageMetrics: struct{}{}, PerfMetrics: struct{}{}, ReferencedMemoryMetrics: struct{}{}, CPUTopologyMetrics: struct{}{}, ResctrlMetrics: struct{}{}, CPUSetMetrics: struct{}{}, OOMMetrics: struct{}{}, }
AllMetrics represents all kinds of metrics that cAdvisor supported.
Functions ¶
func ClearContainerHandlerFactories ¶
func ClearContainerHandlerFactories()
Clear the known factories.
func HasFactories ¶
func HasFactories() bool
Returns whether there are any container handler factories registered.
func InitializeFSContext ¶ added in v0.34.0
func InitializePlugins ¶ added in v0.34.0
func InitializePlugins(factory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics MetricSet) []watcher.ContainerWatcher
func RegisterContainerHandlerFactory ¶
func RegisterContainerHandlerFactory(factory ContainerHandlerFactory, watchTypes []watcher.ContainerWatchSource)
Register a ContainerHandlerFactory. These should be registered from least general to most general as they will be asked in order whether they can handle a particular container.
func RegisterPlugin ¶ added in v0.34.0
Types ¶
type ContainerHandler ¶
type ContainerHandler interface {
	// Returns the ContainerReference
	ContainerReference() (info.ContainerReference, error)
	// Returns container's isolation spec.
	GetSpec() (info.ContainerSpec, error)
	// Returns the current stats values of the container.
	GetStats() (*info.ContainerStats, error)
	// Returns the subcontainers of this container.
	ListContainers(listType ListType) ([]info.ContainerReference, error)
	// Returns the processes inside this container.
	ListProcesses(listType ListType) ([]int, error)
	// Returns absolute cgroup path for the requested resource.
	GetCgroupPath(resource string) (string, error)
	// Returns container labels, if available.
	GetContainerLabels() map[string]string
	// Returns the container's ip address, if available
	GetContainerIPAddress() string
	// Returns whether the container still exists.
	Exists() bool
	// Cleanup frees up any resources being held like fds or go routines, etc.
	Cleanup()
	// Start starts any necessary background goroutines - must be cleaned up in Cleanup().
	// It is expected that most implementations will be a no-op.
	Start()
	// Type of handler
	Type() ContainerType
}
    Interface for container operation handlers.
func NewContainerHandler ¶
func NewContainerHandler(name string, watchType watcher.ContainerWatchSource, metadataEnvAllowList []string, inHostNamespace bool) (ContainerHandler, bool, error)
Create a new ContainerHandler for the specified container.
type ContainerHandlerFactory ¶
type ContainerHandlerFactory interface {
	// Create a new ContainerHandler using this factory. CanHandleAndAccept() must have returned true.
	NewContainerHandler(name string, metadataEnvAllowList []string, inHostNamespace bool) (c ContainerHandler, err error)
	// Returns whether this factory can handle and accept the specified container.
	CanHandleAndAccept(name string) (handle bool, accept bool, err error)
	// Name of the factory.
	String() string
	// Returns debugging information. Map of lines per category.
	DebugInfo() map[string][]string
}
    func GetReorderedFactoryList ¶ added in v0.43.0
func GetReorderedFactoryList(watchType watcher.ContainerWatchSource) []ContainerHandlerFactory
GetReorderedFactoryList returns the list of ContainerHandlerFactory where the RawContainerHandler is always the last element.
type ContainerType ¶ added in v0.23.2
type ContainerType int
const ( ContainerTypeRaw ContainerType = iota ContainerTypeDocker ContainerTypeCrio ContainerTypeContainerd ContainerTypeMesos )
type ListType ¶
type ListType int
ListType describes whether listing should be just for a specific container or performed recursively.
type MetricKind ¶ added in v0.22.0
type MetricKind string
MetricKind represents the kind of metrics that cAdvisor exposes.
const ( CpuUsageMetrics MetricKind = "cpu" ProcessSchedulerMetrics MetricKind = "sched" PerCpuUsageMetrics MetricKind = "percpu" MemoryUsageMetrics MetricKind = "memory" MemoryNumaMetrics MetricKind = "memory_numa" CpuLoadMetrics MetricKind = "cpuLoad" DiskIOMetrics MetricKind = "diskIO" DiskUsageMetrics MetricKind = "disk" NetworkUsageMetrics MetricKind = "network" NetworkTcpUsageMetrics MetricKind = "tcp" NetworkAdvancedTcpUsageMetrics MetricKind = "advtcp" NetworkUdpUsageMetrics MetricKind = "udp" AcceleratorUsageMetrics MetricKind = "accelerator" AppMetrics MetricKind = "app" ProcessMetrics MetricKind = "process" HugetlbUsageMetrics MetricKind = "hugetlb" PerfMetrics MetricKind = "perf_event" ReferencedMemoryMetrics MetricKind = "referenced_memory" CPUTopologyMetrics MetricKind = "cpu_topology" ResctrlMetrics MetricKind = "resctrl" CPUSetMetrics MetricKind = "cpuset" OOMMetrics MetricKind = "oom_event" )
func (MetricKind) String ¶ added in v0.22.0
func (mk MetricKind) String() string
type MetricSet ¶ added in v0.22.0
type MetricSet map[MetricKind]struct{}
func (MetricSet) Difference ¶ added in v0.37.0
func (MetricSet) Has ¶ added in v0.22.0
func (ms MetricSet) Has(mk MetricKind) bool
func (*MetricSet) Set ¶ added in v0.41.0
Not thread-safe, exported only for https://pkg.go.dev/flag#Value
type Plugin ¶ added in v0.34.0
type Plugin interface {
	// InitializeFSContext is invoked when populating an fs.Context object for a new manager.
	// A returned error here is fatal.
	InitializeFSContext(context *fs.Context) error
	// Register is invoked when starting a manager. It can optionally return a container watcher.
	// A returned error is logged, but is not fatal.
	Register(factory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics MetricSet) (watcher.ContainerWatcher, error)
}
    
       Directories
      ¶
      Directories
      ¶
    
    | Path | Synopsis | 
|---|---|
| Unmarshal's a Containers description json file. | Unmarshal's a Containers description json file. | 
| This code has been taken from containerd repo to avoid large library import | This code has been taken from containerd repo to avoid large library import | 
| 
          
            errdefs
            
            
          
           Package errdefs defines the common errors used throughout containerd packages. | Package errdefs defines the common errors used throughout containerd packages. | 
| 
          
            identifiers
            
            
          
           Package identifiers provides common validation for identifiers and keys across containerd. | Package identifiers provides common validation for identifiers and keys across containerd. | 
| 
          
            install
            
            
          
           The install package registers containerd.NewPlugin() as the "containerd" container provider when imported | The install package registers containerd.NewPlugin() as the "containerd" container provider when imported | 
| Handler for CRI-O containers. | Handler for CRI-O containers. | 
| 
          
            install
            
            
          
           The install package registers crio.NewPlugin() as the "crio" container provider when imported | The install package registers crio.NewPlugin() as the "crio" container provider when imported | 
| Provides global docker information. | Provides global docker information. | 
| 
          
            install
            
            
          
           The install package registers docker.NewPlugin() as the "docker" container provider when imported | The install package registers docker.NewPlugin() as the "docker" container provider when imported | 
| Handler for "raw" containers. | Handler for "raw" containers. | 
| 
          
            install
            
            
          
           The install package registers systemd.NewPlugin() as the "systemd" container provider when imported | The install package registers systemd.NewPlugin() as the "systemd" container provider when imported |