tapmanager

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 21 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FDClient

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

FDClient can be used to connect to an FDServer listening on a Unix domain socket

func NewFDClient

func NewFDClient(socketPath string) *FDClient

NewFDClient returns an FDClient for specified socket path

func (*FDClient) AddFDs added in v0.9.4

func (c *FDClient) AddFDs(key string, data interface{}) ([]byte, error)

AddFDs requests the FDServer to add a new file descriptor using its FDSource. It returns the data which are returned by FDSource's GetFDs() call

func (*FDClient) GetFDs added in v0.9.4

func (c *FDClient) GetFDs(key string) ([]int, []byte, error)

GetFDs requests file descriptors from the FDServer. It returns a list of file descriptors which is valid for current process and any associated data that was returned from FDSource's GetInfo() call.

func (*FDClient) IsRunning added in v1.3.0

func (c *FDClient) IsRunning() error

IsRunning check if the fdserver is running. It will return nil when it is running.

func (*FDClient) Recover added in v0.9.4

func (c *FDClient) Recover(key string, data interface{}) error

Recover requests FDServer to recover the state regarding the specified key. It's intended to be called after Virtlet restart.

func (*FDClient) ReleaseFDs added in v0.9.4

func (c *FDClient) ReleaseFDs(key string) error

ReleaseFDs makes FDServer close the file descriptor and destroy any associated resources

type FDManager

type FDManager interface {
	// AddFDs adds new file descriptor to the FDManager and returns
	// the associated data
	AddFDs(key string, data interface{}) ([]byte, error)
	// ReleaseFDs makes FDManager close the file descriptor and destroy
	// any associated resources
	ReleaseFDs(key string) error
	// Recover recovers the state regarding the
	// specified key. It's intended to be called after
	// Virtlet restart.
	Recover(key string, data interface{}) error
}

FDManager denotes an object that provides 'master'-side functionality of FDClient

type FDServer

type FDServer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FDServer listens on a Unix domain socket, serving requests to create, destroy and obtain file descriptors. It serves the purpose of sending the file descriptors across mount namespace boundaries, as well as making it easier to work around the Go namespace problem (to be fixed in Go 1.10): https://www.weave.works/blog/linux-namespaces-and-go-don-t-mix When the Go namespace problem is resolved, it should be possible to dumb down FDServer by making it only serve GetFDs() requests, performing other actions within the process boundary.

func NewFDServer

func NewFDServer(socketPath string, source FDSource) *FDServer

NewFDServer returns an FDServer for the specified socket path and an FDSource

func (*FDServer) Serve

func (s *FDServer) Serve() error

Serve makes FDServer listen on its socket in a new goroutine. It returns immediately. Use Stop() to stop listening.

func (*FDServer) Stop

func (s *FDServer) Stop() error

Stop makes FDServer stop listening and close its socket

type FDSource

type FDSource interface {
	// GetFDs sets up a file descriptors based on key
	// and extra data. It should return the file descriptor list,
	// any data that should be passed back to the client
	// invoking AddFDs() and an error, if any.
	GetFDs(key string, data []byte) ([]int, []byte, error)
	// Release destroys (closes) the file descriptor and
	// any associated resources
	Release(key string) error
	// GetInfo returns the information which needs to be
	// propagated back the FDClient upon GetFDs() call
	GetInfo(key string) ([]byte, error)
	// Recover recovers FDSource's state regarding the
	// specified key. It's intended to be called after
	// Virtlet restart.
	Recover(key string, data []byte) error
	// RetrieveFDs retrieves FDs in case the FD is null
	RetrieveFDs(key string) ([]int, error)
	// Stop stops any goroutines associated with FDSource
	// but doesn't release the namespaces
	Stop() error
}

FDSource denotes an 'executive' part for FDServer which creates and destroys (closes) the file descriptors and associated resources

type GetFDPayload

type GetFDPayload struct {
	// Description contains the pod information and DNS settings for the pod
	Description *PodNetworkDesc `json:"podNetworkDesc"`
}

GetFDPayload contains the data that are required by TapFDSource to prepare container side network configuration

type InterfaceDescription added in v0.9.4

type InterfaceDescription struct {
	Type         network.InterfaceType `json:"type"`
	HardwareAddr net.HardwareAddr      `json:"mac"`
	FdIndex      int                   `json:"fdIndex"`
	PCIAddress   string                `json:"pciAddress"`
}

InterfaceDescription contains interface type with additional data needed to identify it

type PodNetworkDesc

type PodNetworkDesc struct {
	// PodID specifies the id of the pod
	PodID string `json:"podId"`
	// PodNs specifies the namespace of the pod
	PodNs string `json:"podNs"`
	// PodName specifies the name of the pod
	PodName string `json:"podName"`
	// DNS specifies DNS settings for the pod
	DNS *cnitypes.DNS
}

PodNetworkDesc contains the data that are required by TapFDSource to set up a tap device for a VM

type RecoverPayload added in v1.1.2

type RecoverPayload struct {
	// Description contains the pod information and DNS settings for the pod
	Description *PodNetworkDesc `json:"podNetworkDesc"`
	// ContainerSideNetwork specifies configuration used to configure retaken
	// environment
	ContainerSideNetwork *network.ContainerSideNetwork `json:"csn"`
	// HaveRunningContainers is true if any domains are currently running
	// for this pod. VF reconfiguration is to be skipped if that's the case.
	HaveRunningContainers bool
}

RecoverPayload contains the data that are required by TapFDSource to recover a network configuration in a pod

type TapFDSource

type TapFDSource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TapFDSource sets up and tears down Virtlet VM network. It implements FDSource interface

func NewTapFDSource

func NewTapFDSource(cniClient cni.Client, enableSriov bool, calicoSubnetSize int) (*TapFDSource, error)

NewTapFDSource returns a TapFDSource for the specified CNI plugin & config dir

func (*TapFDSource) GetFDs added in v0.9.4

func (s *TapFDSource) GetFDs(key string, data []byte) ([]int, []byte, error)

GetFDs implements GetFDs method of FDSource interface

func (*TapFDSource) GetInfo

func (s *TapFDSource) GetInfo(key string) ([]byte, error)

GetInfo implements GetInfo method of FDSource interface

func (*TapFDSource) Recover added in v0.9.4

func (s *TapFDSource) Recover(key string, data []byte) error

Recover recovers the state for the netns after Virtlet restart

func (*TapFDSource) Release

func (s *TapFDSource) Release(key string) error

Release implements Release method of FDSource interface

func (*TapFDSource) RetrieveFDs added in v1.5.0

func (s *TapFDSource) RetrieveFDs(key string) ([]int, error)

RetrieveFDs retrieves the FDs. It's only used in case if VM exited but Recover() didn't populate the FDs

func (*TapFDSource) Stop added in v0.9.4

func (s *TapFDSource) Stop() error

Stop stops any running DHCP servers associated with TapFDSource and closes tap fds without releasing any other resources.

Jump to

Keyboard shortcuts

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