mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-23 17:24:18 +01:00
virtcontainers: Rename the cgroups package
To resourcecontrol, and make it consistent with the fact that cgroups are a Linux implementation of the ResourceController interface. Fixes: #3601 Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
0d1a7da682
commit
823faee83a
82
src/runtime/virtcontainers/pkg/resourcecontrol/controller.go
Normal file
82
src/runtime/virtcontainers/pkg/resourcecontrol/controller.go
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright (c) 2021 Apple Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package resourcecontrol
|
||||
|
||||
import (
|
||||
v1 "github.com/containerd/cgroups/stats/v1"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
controllerLogger = logrus.WithField("source", "virtcontainers/pkg/resourcecontrol")
|
||||
)
|
||||
|
||||
// SetLogger sets up a logger for this pkg
|
||||
func SetLogger(logger *logrus.Entry) {
|
||||
fields := controllerLogger.Data
|
||||
|
||||
controllerLogger = logger.WithFields(fields)
|
||||
}
|
||||
|
||||
// HypervisorType describes an hypervisor type.
|
||||
type ResourceControllerType string
|
||||
|
||||
const (
|
||||
LinuxCgroups ResourceControllerType = "cgroups"
|
||||
)
|
||||
|
||||
// String converts an hypervisor type to a string.
|
||||
func (rType *ResourceControllerType) String() string {
|
||||
switch *rType {
|
||||
case LinuxCgroups:
|
||||
return string(LinuxCgroups)
|
||||
default:
|
||||
return "Unknown controller type"
|
||||
}
|
||||
}
|
||||
|
||||
// ResourceController represents a system resources controller.
|
||||
// On Linux this interface is implemented through the cgroups API.
|
||||
type ResourceController interface {
|
||||
// Type returns the resource controller implementation type.
|
||||
Type() ResourceControllerType
|
||||
|
||||
// The controller identifier, e.g. a Linux cgroups path.
|
||||
ID() string
|
||||
|
||||
// Parent returns the parent controller, on hierarchically
|
||||
// defined resource (e.g. Linux cgroups).
|
||||
Parent() string
|
||||
|
||||
// Delete the controller.
|
||||
Delete() error
|
||||
|
||||
// Stat returns the statistics for the controller.
|
||||
Stat() (*v1.Metrics, error)
|
||||
|
||||
// AddProcess adds a process to a set of controllers.
|
||||
AddProcess(int, ...string) error
|
||||
|
||||
// AddThread adds a process thread to a set of controllers.
|
||||
AddThread(int, ...string) error
|
||||
|
||||
// Update updates the set of resources controlled, based on
|
||||
// an OCI resources description.
|
||||
Update(*specs.LinuxResources) error
|
||||
|
||||
// MoveTo moves a controller to another one.
|
||||
MoveTo(string) error
|
||||
|
||||
// AddDevice adds a device resource to the controller.
|
||||
AddDevice(string) error
|
||||
|
||||
// RemoveDevice removes a device resource to the controller.
|
||||
RemoveDevice(string) error
|
||||
|
||||
// UpdateCpuSet updates the set of controlled CPUs and memory nodes.
|
||||
UpdateCpuSet(string, string) error
|
||||
}
|
||||
Reference in New Issue
Block a user