handlers

package
v0.0.0-...-2ebf54f Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CNIBinDir describes the directory where the CNI binaries are stored
	CNIBinDir = "/opt/cni/bin"
	// CNIConfDir describes the directory where the CNI plugin's configuration is stored
	CNIConfDir = "/etc/cni/net.d"
	// NetNSPathFmt gives the path to the a process network namespace, given the pid
	NetNSPathFmt = "/proc/%d/ns/net"
)
View Source
const (
	//OrchestrationIdentifier identifier string for provider orchestration
	OrchestrationIdentifier = "containerd"
	//ProviderName name of the provider
	ProviderName = "faas-containerd"
)
View Source
const (
	// FunctionNamespace is the containerd namespace functions are created
	FunctionNamespace = "openfaas-fn"
)

Variables

View Source
var ErrLinkNotFound = errors.New("Link not found")

Functions

func ConnectedToBridgeVethPeerIds

func ConnectedToBridgeVethPeerIds(bridgeName string) ([]int, error)

ConnectedToBridgeVethPeerIds returns peer indexes of veth links connected to the given bridge. The peer index is used to query from a container netns whether the container is connected to the bridge.

func CreateCNINetwork

func CreateCNINetwork(ctx context.Context, cni gocni.CNI, task containerd.Task, labels map[string]string) (*gocni.CNIResult, error)

CreateCNINetwork creates a CNI network interface and attaches it to the context

func DeleteCNINetwork

func DeleteCNINetwork(ctx context.Context, cni gocni.CNI, client *containerd.Client, name string) error

DeleteCNINetwork deletes a CNI network based on task ID and Pid

func GetIPAddress

func GetIPAddress(result *gocni.CNIResult, task containerd.Task) (net.IP, error)

GetIPAddress returns the IP address of the created container

func GetIPfromPID

func GetIPfromPID(pid int) (*net.IP, error)

func InitNetwork

func InitNetwork() (gocni.CNI, error)

InitNetwork writes configlist file and initializes CNI network

func ListFunctions

func ListFunctions(client *containerd.Client) (map[string]Function, error)

ListFunctions returns a map of all functions with running tasks on namespace

func MakeDeleteHandler

func MakeDeleteHandler(client *containerd.Client, cni gocni.CNI) func(w http.ResponseWriter, r *http.Request)

func MakeDeployHandler

func MakeDeployHandler(client *containerd.Client, cni gocni.CNI) func(w http.ResponseWriter, r *http.Request)

func MakeInfoHandler

func MakeInfoHandler(version, sha string) http.HandlerFunc

MakeInfoHandler creates handler for /system/info endpoint

func MakeReadHandler

func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *http.Request)

func MakeReplicaReaderHandler

func MakeReplicaReaderHandler(client *containerd.Client) func(w http.ResponseWriter, r *http.Request)

func MakeReplicaUpdateHandler

func MakeReplicaUpdateHandler(client *containerd.Client, cni gocni.CNI) func(w http.ResponseWriter, r *http.Request)

func MakeUpdateHandler

func MakeUpdateHandler(client *containerd.Client, cni gocni.CNI) func(w http.ResponseWriter, r *http.Request)

func NSPathByPid

func NSPathByPid(pid int) string

func NSPathByPidWithRoot

func NSPathByPidWithRoot(root string, pid int) string

func NetID

func NetID(task containerd.Task) string

NetID generates the network IF based on task name and task PID

func NetNamespace

func NetNamespace(task containerd.Task) string

NetNamespace generates the namespace path based on task PID.

func WithNetNS

func WithNetNS(ns netns.NsHandle, work func() error) error

func WithNetNSByPath

func WithNetNSByPath(path string, work func() error) error
func WithNetNSLink(ns netns.NsHandle, ifName string, work func(link netlink.Link) error) error

Types

type Dev

type Dev struct {
	Name  string           `json:"Name,omitempty"`
	MAC   net.HardwareAddr `json:"MAC,omitempty"`
	CIDRs []*net.IPNet     `json:"CIDRs,omitempty"`
}

func GetBridgeNetDev

func GetBridgeNetDev(bridgeName string) (Dev, error)

Get the weave bridge interface. NB: Should be called from the root network namespace.

func GetNetDevsByVethPeerIds

func GetNetDevsByVethPeerIds(processID int, peerIDs []int) ([]Dev, error)

func GetWeaveNetDevs

func GetWeaveNetDevs(processID int) ([]Dev, error)

Lookup the weave interface of a container

type Function

type Function struct {
	IP string
	// contains filtered or unexported fields
}

func GetFunction

func GetFunction(client *containerd.Client, name string) (Function, error)

GetFunction returns a function that matches name

type InvokeResolver

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

func NewInvokeResolver

func NewInvokeResolver(client *containerd.Client) *InvokeResolver

func (*InvokeResolver) Resolve

func (i *InvokeResolver) Resolve(functionName string) (url.URL, error)

Jump to

Keyboard shortcuts

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