launcher

package
v0.0.0-...-03d9887 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package launcher provides set of API to controls services lifecycle

Index

Constants

View Source
const OperationVersion = 9

OperationVersion defines current operation version IMPORTANT: if new functionality doesn't allow existing services to work properly, this value should be increased. It will force to remove all services and their storages before first start.

Variables

View Source
var (
	MountFunc   = fs.OverlayMount
	UnmountFunc = fs.Umount
)

Mount, unmount instance FS functions.

View Source
var (
	// RuntimeDir specifies directory where instance runtime spec is stored.
	RuntimeDir = "/run/aos/runtime"
	// CheckTTLsPeriod specifies period different TTL timers are checked with.
	CheckTTLsPeriod = 1 * time.Hour
)
View Source
var ErrNotExist = errors.New("instance not exist")

ErrNotExist not exist instance error.

Functions

This section is empty.

Types

type AlertSender

type AlertSender interface {
	SendAlert(alert interface{})
}

AlertSender provides interface to send alerts.

type InstanceInfo

type InstanceInfo struct {
	aostypes.InstanceInfo
	InstanceID string
}

InstanceInfo instance information.

type InstanceMonitor

type InstanceMonitor interface {
	StartInstanceMonitor(instanceID string, params resourcemonitor.ResourceMonitorParams) error
	StopInstanceMonitor(instanceID string) error
}

InstanceMonitor provides API to monitor instance parameters.

type InstanceRegistrar

type InstanceRegistrar interface {
	RegisterInstance(
		instance aostypes.InstanceIdent, permissions map[string]map[string]string,
	) (secret string, err error)
	UnregisterInstance(instance aostypes.InstanceIdent) error
}

InstanceRegistrar provides API to register/unregister instance.

type InstanceRunner

type InstanceRunner interface {
	StartInstance(instanceID, runtimeDir string, params runner.RunParameters) runner.InstanceStatus
	StopInstance(instanceID string) error
	InstanceStatusChannel() <-chan []runner.InstanceStatus
}

InstanceRunner interface to start/stop service instances.

type InstancesStatus

type InstancesStatus struct {
	Instances []cloudprotocol.InstanceStatus
}

InstancesStatus instances status.

type Launcher

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

Launcher launcher instance.

func New

func New(config *config.Config, nodeInfoProvider NodeInfoProvider, storage Storage, serviceProvider ServiceProvider,
	layerProvider LayerProvider, instanceRunner InstanceRunner, resourceManager ResourceManager,
	networkManager NetworkManager, instanceRegistrar InstanceRegistrar, instanceMonitor InstanceMonitor,
	alertSender AlertSender,
) (launcher *Launcher, err error)

New creates new launcher object.

func (*Launcher) Close

func (launcher *Launcher) Close() (err error)

Close closes launcher.

func (*Launcher) CloudConnection

func (launcher *Launcher) CloudConnection(connected bool) error

CloudConnection sets cloud connection status.

func (*Launcher) OverrideEnvVars

func (launcher *Launcher) OverrideEnvVars(
	envVarsInfo []cloudprotocol.EnvVarsInstanceInfo,
) ([]cloudprotocol.EnvVarsInstanceStatus, error)

OverrideEnvVars overrides service instance environment variables.

func (*Launcher) RunInstances

func (launcher *Launcher) RunInstances(instances []aostypes.InstanceInfo, forceRestart bool) error

RunInstances runs desired services instances.

func (*Launcher) RuntimeStatusChannel

func (launcher *Launcher) RuntimeStatusChannel() <-chan RuntimeStatus

RuntimeStatusChannel returns runtime status channel.

type LayerProvider

type LayerProvider interface {
	GetLayerInfoByDigest(digest string) (layermanager.LayerInfo, error)
}

LayerProvider layer provider.

type NetworkManager

type NetworkManager interface {
	GetNetnsPath(instanceID string) string
	AddInstanceToNetwork(instanceID, networkID string, params networkmanager.NetworkParams) error
	RemoveInstanceFromNetwork(instanceID, networkID string) error
}

NetworkManager provides network access.

type NodeInfoProvider

type NodeInfoProvider interface {
	GetCurrentNodeInfo() (cloudprotocol.NodeInfo, error)
}

NodeInfoProvider provides node information.

type ResourceManager

type ResourceManager interface {
	GetDeviceInfo(device string) (cloudprotocol.DeviceInfo, error)
	GetResourceInfo(resource string) (cloudprotocol.ResourceInfo, error)
	AllocateDevice(device, instanceID string) error
	ReleaseDevice(device, instanceID string) error
	ReleaseDevices(instanceID string) error
	GetDeviceInstances(name string) (instanceIDs []string, err error)
}

ResourceManager provides API to validate, request and release resources.

type RuntimeStatus

type RuntimeStatus struct {
	RunStatus    *InstancesStatus
	UpdateStatus *InstancesStatus
}

RuntimeStatus runtime status info.

type ServiceProvider

type ServiceProvider interface {
	GetServiceInfo(serviceID string) (servicemanager.ServiceInfo, error)
	GetImageParts(service servicemanager.ServiceInfo) (servicemanager.ImageParts, error)
	ValidateService(service servicemanager.ServiceInfo) error
}

ServiceProvider service provider.

type Storage

type Storage interface {
	AddInstance(instance InstanceInfo) error
	UpdateInstance(instance InstanceInfo) error
	RemoveInstance(instanceID string) error
	GetAllInstances() ([]InstanceInfo, error)
	GetOverrideEnvVars() ([]cloudprotocol.EnvVarsInstanceInfo, error)
	SetOverrideEnvVars(envVarsInfo []cloudprotocol.EnvVarsInstanceInfo) error
	GetOnlineTime() (time.Time, error)
	SetOnlineTime(t time.Time) error
}

Storage storage interface.

Jump to

Keyboard shortcuts

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