Documentation ¶
Overview ¶
Package devicemanager is responsible for allocation & connection of special devices that may need to be connected to pods in case they are defined in resources section of a pod definition.
The only supported device as of now is contivpp.io/memif - e.g.:
spec:
containers: - name: test-container resources: requests: contivpp.io/memif: 1 limits: contivpp.io/memif: 1
Index ¶
- Variables
- type API
- type AllocateDevice
- func (ev *AllocateDevice) Direction() controller.UpdateDirectionType
- func (ev *AllocateDevice) Done(err error)
- func (ev *AllocateDevice) GetName() string
- func (ev *AllocateDevice) IsBlocking() bool
- func (ev *AllocateDevice) Method() controller.EventMethodType
- func (ev *AllocateDevice) String() string
- func (ev *AllocateDevice) TransactionType() controller.UpdateTransactionType
- func (ev *AllocateDevice) Wait() error
- type Deps
- type DeviceManager
- func (d *DeviceManager) Allocate(ctx context.Context, rqt *devicepluginapi.AllocateRequest) (*devicepluginapi.AllocateResponse, error)
- func (d *DeviceManager) Close() error
- func (d *DeviceManager) GetDevicePluginOptions(ctx context.Context, empty *devicepluginapi.Empty) (*devicepluginapi.DevicePluginOptions, error)
- func (d *DeviceManager) GetPodMemifInfo(pod podmodel.ID) (info *MemifInfo, err error)
- func (d *DeviceManager) HandlesEvent(event controller.Event) bool
- func (d *DeviceManager) Init() (err error)
- func (d *DeviceManager) ListAndWatch(empty *devicepluginapi.Empty, ...) error
- func (d *DeviceManager) PreStartContainer(ctx context.Context, psRqt *devicepluginapi.PreStartContainerRequest) (*devicepluginapi.PreStartContainerResponse, error)
- func (d *DeviceManager) Resync(event controller.Event, kubeStateData controller.KubeStateData, ...) (err error)
- func (d *DeviceManager) Revert(event controller.Event) error
- func (d *DeviceManager) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
- type DockerClient
- type MemifInfo
- type Mount
- type Option
Constants ¶
This section is empty.
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of DeviceManager manager plugin.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // GetPodMemifInfo returns info related to memif devices connected to the specified pod. GetPodMemifInfo(pod podmodel.ID) (info *MemifInfo, err error) }
API defines methods provided by the DeviceManager plugin for use by other plugins to query pod memif allocation info and release pod memif allocations.
type AllocateDevice ¶
type AllocateDevice struct { // input arguments (read by event handlers) DevicesIDs []string // output arguments (edited by event handlers) Envs map[string]string Annotations map[string]string Mounts []Mount // contains filtered or unexported fields }
AllocateDevice event is triggered when a container is requesting a device supported by contiv on this node.
func NewAllocateDeviceEvent ¶
func NewAllocateDeviceEvent(devicesIDs []string) *AllocateDevice
NewAllocateDeviceEvent is constructor for AllocateDevice event.
func (*AllocateDevice) Direction ¶
func (ev *AllocateDevice) Direction() controller.UpdateDirectionType
Direction is forward.
func (*AllocateDevice) Done ¶
func (ev *AllocateDevice) Done(err error)
Done propagates error to the event producer.
func (*AllocateDevice) GetName ¶
func (ev *AllocateDevice) GetName() string
GetName returns name of the AllocateDevice event.
func (*AllocateDevice) IsBlocking ¶
func (ev *AllocateDevice) IsBlocking() bool
IsBlocking returns true.
func (*AllocateDevice) Method ¶
func (ev *AllocateDevice) Method() controller.EventMethodType
Method is Update.
func (*AllocateDevice) String ¶
func (ev *AllocateDevice) String() string
String describes AllocateDevice event.
func (*AllocateDevice) TransactionType ¶
func (ev *AllocateDevice) TransactionType() controller.UpdateTransactionType
TransactionType is RevertOnFailure.
func (*AllocateDevice) Wait ¶
func (ev *AllocateDevice) Wait() error
Wait waits for the result of the AllocateDevice event.
type Deps ¶
type Deps struct { infra.PluginDeps ContivConf contivconf.API EventLoop controller.EventLoop }
Deps lists dependencies of the DeviceManager plugin.
type DeviceManager ¶
type DeviceManager struct { Deps // contains filtered or unexported fields }
DeviceManager plugin implements allocation & connection of special devices that may need to be connected to pods in case they are defined in resources section of a pod definition.
func NewPlugin ¶
func NewPlugin(opts ...Option) *DeviceManager
NewPlugin creates a new Plugin with the provides Options
func (*DeviceManager) Allocate ¶
func (d *DeviceManager) Allocate(ctx context.Context, rqt *devicepluginapi.AllocateRequest) (*devicepluginapi.AllocateResponse, error)
Allocate is called during container creation when a container requests supported device. It is supposed to allocate requested devices and return container runtime details consumed by Kubelet. (implementation of the DevicePluginServer interface)
func (*DeviceManager) GetDevicePluginOptions ¶
func (d *DeviceManager) GetDevicePluginOptions(ctx context.Context, empty *devicepluginapi.Empty) (*devicepluginapi.DevicePluginOptions, error)
GetDevicePluginOptions returns options to be communicated with DeviceManager. (implementation of the DevicePluginServer interface)
func (*DeviceManager) GetPodMemifInfo ¶
func (d *DeviceManager) GetPodMemifInfo(pod podmodel.ID) (info *MemifInfo, err error)
GetPodMemifInfo returns info related to memif devices connected to the specified pod.
func (*DeviceManager) HandlesEvent ¶
func (d *DeviceManager) HandlesEvent(event controller.Event) bool
HandlesEvent selects:
- any Resync event
- Allocate Device
- Delete Pod
func (*DeviceManager) Init ¶
func (d *DeviceManager) Init() (err error)
Init initializes plugin internals.
func (*DeviceManager) ListAndWatch ¶
func (d *DeviceManager) ListAndWatch(empty *devicepluginapi.Empty, stream devicepluginapi.DevicePlugin_ListAndWatchServer) error
ListAndWatch returns a stream of list of available Devices. (implementation of the DevicePluginServer interface)
func (*DeviceManager) PreStartContainer ¶
func (d *DeviceManager) PreStartContainer(ctx context.Context, psRqt *devicepluginapi.PreStartContainerRequest) (*devicepluginapi.PreStartContainerResponse, error)
PreStartContainer is called, if indicated by DeviceManager Plugin during registration phase, before each container start. DeviceManager plugin can run device specific operations such as resetting the device before making devices available to the container. (implementation of the DevicePluginServer interface)
func (*DeviceManager) Resync ¶
func (d *DeviceManager) Resync(event controller.Event, kubeStateData controller.KubeStateData, resyncCount int, txn controller.ResyncOperations) (err error)
Resync resynchronizes Device Manager. The first resync starts the device plugin server.
func (*DeviceManager) Revert ¶
func (d *DeviceManager) Revert(event controller.Event) error
Revert is NOOP - never called.
func (*DeviceManager) Update ¶
func (d *DeviceManager) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
Update handles AllocateDevice events.
type DockerClient ¶
type DockerClient interface { // Ping pings the docker server. Ping() error // ListContainers returns a slice of containers matching the given criteria. ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error) // InspectContainer returns information about a container by its ID. InspectContainer(id string) (*docker.Container, error) }
DockerClient defines API of a Docker client needed by PodManager. The interface allows to inject mock Docker client in the unit tests.