devicemanager

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

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

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

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) Close

func (d *DeviceManager) Close() error

Close cleans up the resources.

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

ListAndWatch returns a stream of list of available Devices. (implementation of the DevicePluginServer interface)

func (*DeviceManager) PreStartContainer

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.

type MemifInfo

type MemifInfo struct {
	HostSocket      string
	ContainerSocket string
	Secret          string
}

MemifInfo holds memif-related information of a pod.

func (*MemifInfo) String

func (m *MemifInfo) String() string

String describes MemifInfo structure with obfuscated secret content.

type Mount

type Mount struct {
	HostPath      string
	ContainerPath string
}

Mount represents a host-to-container mount.

type Option

type Option func(*DeviceManager)

Option is a function that acts on a Plugin to inject Dependencies or configuration

func UseDeps

func UseDeps(cb func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

Jump to

Keyboard shortcuts

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