Documentation
¶
Index ¶
- Constants
- Variables
- type AddNodeOptions
- type AttachWorkloadMessage
- type AuthConfig
- type Build
- type BuildConfig
- type BuildImageMessage
- type BuildMethod
- type BuildOptions
- type Builds
- type CacheImageMessage
- type CapacityMessage
- type CocoonConfig
- type Config
- type ContainerdConfig
- type ContextValueKey
- type ControlWorkloadMessage
- type CopyMessage
- type CopyOptions
- type CreateWorkloadMessage
- type DeployOptions
- type DissociateWorkloadMessage
- type Entrypoint
- type EtcdConfig
- type ExecuteWorkloadOptions
- type GRPCConfig
- type GitConfig
- type HealthCheck
- type Hook
- type Image
- type ImageOptions
- type LabelMeta
- type LinuxFile
- type ListImageMessage
- type ListNodesOptions
- type ListWorkloadsOptions
- type LogStreamMessage
- type LogStreamOptions
- type Node
- type NodeFilter
- type NodeMeta
- type NodeResourceInfo
- type NodeStatus
- type Pod
- type ProcessConfig
- type Processing
- type RawArgs
- type RawEngineMessage
- type RawEngineOptions
- type ReallocOptions
- type RedisConfig
- type RegistryConfig
- type RemoveImageMessage
- type RemoveWorkloadMessage
- type ReplaceOptions
- type ReplaceWorkloadMessage
- type ResourcePluginConfig
- type SSHConfig
- type SchedulerConfig
- type SendLargeFileOptions
- type SendMessage
- type SendOptions
- type ServerLogConfig
- type ServiceStatus
- type SetNodeOptions
- type StatusMeta
- type StdStreamMessage
- type StdStreamType
- type TriOptions
- type Workload
- func (w *Workload) Inspect(ctx context.Context) (*enginetypes.VirtualizationInfo, error)
- func (w *Workload) RawEngine(ctx context.Context, opts *RawEngineOptions) (ans *RawEngineMessage, err error)
- func (w *Workload) Remove(ctx context.Context, force bool) (err error)
- func (w *Workload) Resume(ctx context.Context) error
- func (w *Workload) Start(ctx context.Context) error
- func (w *Workload) Stop(ctx context.Context, force bool) error
- func (w *Workload) Suspend(ctx context.Context) error
- type WorkloadStatus
Constants ¶
const ( Etcd = "etcd" Redis = "redis" )
Variables ¶
var ( ErrInsufficientCapacity = errors.New("cannot alloc a plan, not enough nodes capacity") ErrInsufficientResource = errors.New("cannot alloc a plan, not enough resource") ErrAlreadyFilled = errors.New("cannot alloc a fill node plan, each node has enough workloads") ErrInvaildDeployStrategy = errors.New("deploy strategy not supported yet") ErrNodeExists = errors.New("node already exists") ErrInvaildNodeEndpoint = errors.New("invalid node endpoint") ErrNodeNotEmpty = errors.New("node not empty, still has workloads associated") ErrNodeNotExists = errors.New("node not exists") ErrInvaildNodeStatusTTL = errors.New("invalid TTL for node status, should be > 0") ErrInvaildWorkloadStatusTTL = errors.New("invalid TTL for workload status, should be >= 0") ErrInvaildNodeFilter = errors.New("node filter widens the configured selection") ErrLockKeyInvaild = errors.New("lock key is invalid") ErrLockSessionDone = errors.New("lock session done") ErrInvaildEruIPAddress = errors.New("invalid eru address") ErrInvaildSCMType = errors.New("scm type not supported yet") ErrDownloadArtifactsFailed = errors.New("download artifacts failed") ErrInvaildIPWithPort = errors.New("invalid IP with port") ErrAllConnectionsFailed = errors.New("all connections failed") ErrInvaildMemory = errors.New("invalid memory value") ErrNilEngine = errors.New("engine is nil") ErrNoImage = errors.New("no image") ErrInvaildEngineEndpoint = errors.New("unsupported engine endpoint") ErrEngineNotImplemented = errors.New("not implemented") ErrInvalidEngineArgs = errors.New("invalid engine args") ErrInvaildWorkloadStatus = errors.New("status has no appname / entrypoint / nodename") ErrInvaildWorkloadMeta = errors.New("invalid workload meta") ErrInvaildWorkloadOps = errors.New("invalid workload ops") ErrInvalidWorkloadName = errors.New("invalid workload name") ErrWorkloadIgnored = errors.New("ignore this workload") ErrWorkloadNotExists = errors.New("workload not exists") ErrPodHasNodes = errors.New("pod has nodes") ErrPodNoNodes = errors.New("pod has no nodes") ErrPodNotFound = errors.New("pod not found") ErrInvaildGRPCRequestMeta = errors.New("invalid grpc request meta") ErrInvaildGRPCPassword = errors.New("invalid grpc password") ErrInvaildGRPCUsername = errors.New("invalid grpc username") ErrNoBuildsInSpec = errors.New("no builds in spec") ErrNoBuildSpec = errors.New("no build spec") ErrNoEntryInSpec = errors.New("no entry in spec") ErrNoDeployOpts = errors.New("no deploy options") ErrNoWorkloadIDs = errors.New("no workload IDs given") ErrNoSCMSetting = errors.New("scm not set") ErrRunAndWaitCountOneWithStdin = errors.New("count must be 1 if OpenStdin is true") ErrInvaildControlType = errors.New("unknown control type") ErrInvaildBuildType = errors.New("unknown build type") ErrInvalidGitURL = errors.New("invalid git url format") ErrInvalidVolumeBind = errors.New("invalid volume bind value") ErrEmptyNodeName = errors.New("node name is empty") ErrEmptyNodeMap = errors.New("node map is empty") ErrEmptyAppName = errors.New("app name is empty") ErrEmptyPodName = errors.New("pod name is empty") ErrEmptyImage = errors.New("image is empty") ErrEmptyCount = errors.New("count is 0") ErrEmptyWorkloadID = errors.New("workload ID is empty") ErrEmptyEntrypointName = errors.New("entrypoint name is empty") ErrUnderlineInEntrypointName = errors.New("entrypoint name has '_' character") ErrEmptyRawEngineOp = errors.New("raw engine op is empty") ErrKeyNotExists = errors.New("key not exists") ErrKeyExists = errors.New("key exists") ErrNoOps = errors.New("no txn ops") ErrInvaildCount = errors.New("bad `Count` value, entity count invalid") ErrInvaildWALEventType = errors.New("invalid WAL event type") ErrInvalidWALDataType = errors.New("invalid WAL data type") ErrInvaildDeployCount = errors.New("invalid deploy count") ErrRollbackMapIsNotEmpty = errors.New("rollback map is not empty") ErrGetMostIdleNodeFailed = errors.New("get most idle node failed") ErrMessageChanClosed = errors.New("message chan closed") ErrNoFilesToSend = errors.New("no files to send") ErrNoFilesToCopy = errors.New("no files to copy") ErrEmptyFileDst = errors.New("empty file destination") ErrMockError = errors.New("mock error") ErrMetricsTypeNotSupport = errors.New("metrics type not support") ErrConfigInvaild = errors.New("config invalid") )
Functions ¶
This section is empty.
Types ¶
type AddNodeOptions ¶
type AddNodeOptions struct {
Nodename string
Endpoint string
Podname string
Labels map[string]string
Resources resourcetypes.Resources
Test bool
}
func (*AddNodeOptions) Validate ¶
func (o *AddNodeOptions) Validate() error
type AttachWorkloadMessage ¶
type AttachWorkloadMessage struct {
WorkloadID string
Data []byte
StdStreamType
}
AttachWorkloadMessage carries RunAndWait output.
type AuthConfig ¶
type AuthConfig struct {
Username string `yaml:"username,omitempty" json:"username,omitempty"`
Password string `yaml:"password,omitempty" json:"password,omitempty"`
}
AuthConfig holds registry credentials, also reused for grpc basic auth.
type Build ¶
type Build = enginetypes.Build
type BuildConfig ¶ added in v0.1.1
type BuildConfig struct {
NodeFilter NodeFilter `yaml:"node_filter"`
}
BuildConfig selects the nodes allowed to run in-cluster image builds.
type BuildImageMessage ¶
type BuildMethod ¶
type BuildMethod int
const ( // BuildFromSCM stays the zero value for wire compatibility. BuildFromSCM BuildMethod = iota BuildFromUnknown BuildFromRaw BuildFromExist )
type BuildOptions ¶
type Builds ¶
type Builds = enginetypes.Builds
type CacheImageMessage ¶
type CapacityMessage ¶
CapacityMessage carries CalculateCapacity output.
type CocoonConfig ¶ added in v0.1.1
type CocoonConfig struct {
Binary string `yaml:"binary" default:"cocoon"` // the cocoon command on the node; a sudo wrapper works
Root string `yaml:"root" default:"/var/lib/eru/cocoon"` // durable copies of the workload records
RunDir string `yaml:"run_dir" default:"/var/lib/cocoon/run"` // cocoon's run_dir, where the guest consoles live
CgroupParent string `yaml:"cgroup_parent" default:"cocoon.slice"`
}
CocoonConfig is the node-side layout the cocoon engine drives over SSH.
type Config ¶
type Config struct {
Bind string `yaml:"bind" required:"true" default:"5001"`
LockTimeout time.Duration `yaml:"lock_timeout" required:"true" default:"30s"`
GlobalTimeout time.Duration `yaml:"global_timeout" required:"true" default:"300s"` // timeout for remove, run_and_wait and build
ConnectionTimeout time.Duration `yaml:"connection_timeout" required:"true" default:"10s"`
HAKeepaliveInterval time.Duration `yaml:"ha_keepalive_interval" required:"true" default:"16s"`
Statsd string `yaml:"statsd"` // statsd host:port
Profile string `yaml:"profile"` // profile ip:port
MaxConcurrency int `yaml:"max_concurrency" default:"100000"` // max concurrent calls to one runtime
Store string `yaml:"store" default:"etcd"`
SentryDSN string `yaml:"sentry_dsn"`
ProbeTarget string `yaml:"probe_target" required:"false" default:"8.8.8.8:80"` // for getting outbound address
Auth AuthConfig `yaml:"auth"` // grpc auth
GRPCConfig GRPCConfig `yaml:"grpc"`
Git GitConfig `yaml:"git"`
SSH SSHConfig `yaml:"ssh"`
Etcd EtcdConfig `yaml:"etcd"`
Redis RedisConfig `yaml:"redis"`
Registry RegistryConfig `yaml:"registry"`
Build BuildConfig `yaml:"build"`
Containerd ContainerdConfig `yaml:"containerd"`
Process ProcessConfig `yaml:"process"`
Cocoon CocoonConfig `yaml:"cocoon"`
Scheduler SchedulerConfig `yaml:"scheduler"`
ResourcePlugin ResourcePluginConfig `yaml:"resource_plugin"`
Log ServerLogConfig `yaml:"log"`
}
func (Config) Identifier ¶
Identifier returns a sha256 over the fields that identify the backing store.
type ContainerdConfig ¶ added in v0.1.1
type ContainerdConfig struct {
Socket string `yaml:"socket" default:"/run/containerd/containerd.sock"`
Namespace string `yaml:"namespace" default:"eru"`
BuildKit string `yaml:"buildkit" default:"/run/buildkit/buildkitd.sock"` // a tcp:// address is dialed directly
StopTimeout time.Duration `yaml:"stop_timeout" default:"10s"`
}
ContainerdConfig is the node-side layout the containerd engine reaches over SSH.
type ControlWorkloadMessage ¶
type CopyMessage ¶
type CopyOptions ¶
func (*CopyOptions) Validate ¶
func (o *CopyOptions) Validate() error
type CreateWorkloadMessage ¶
type DeployOptions ¶
type DeployOptions struct {
Resources resourcetypes.Resources
Name string
Entrypoint *Entrypoint
Podname string
NodeFilter *NodeFilter
Image string
Count int
Env []string
DNS []string
ExtraHosts []string
Networks map[string]string // network name to specified IP
User string
Debug bool // use syslog as log driver
OpenStdin bool
Labels map[string]string
DeployStrategy string
Files []LinuxFile
NodesLimit int
ProcessIdent string
IgnoreHook bool
AfterCreate []string
RawArgs RawArgs
Lambda bool
IgnorePull bool
}
func (DeployOptions) GetProcessing ¶
func (o DeployOptions) GetProcessing(nodename string) *Processing
func (*DeployOptions) Validate ¶
func (o *DeployOptions) Validate() error
type Entrypoint ¶
type Entrypoint struct {
Name string `yaml:"name,omitempty"`
Commands []string `yaml:"commands,omitempty"`
Privileged bool `yaml:"privileged,omitempty"`
Dir string `yaml:"dir,omitempty"`
Publish []string `yaml:"publish,omitempty,flow"`
HealthCheck *HealthCheck `yaml:"healthcheck,omitempty,flow"`
Hook *Hook `yaml:"hook,omitempty,flow"`
Restart string `yaml:"restart,omitempty"`
Sysctls map[string]string `yaml:"sysctls,omitempty,flow"`
}
func (*Entrypoint) Validate ¶
func (e *Entrypoint) Validate() error
type EtcdConfig ¶
type EtcdConfig struct {
Machines []string `yaml:"machines" required:"true"`
Prefix string `yaml:"prefix" required:"true" default:"/eru"`
LockPrefix string `yaml:"lock_prefix" required:"true" default:"__lock__/eru"`
Ca string `yaml:"ca"`
Key string `yaml:"key"`
Cert string `yaml:"cert"`
Auth AuthConfig `yaml:"auth"`
}
type ExecuteWorkloadOptions ¶
type GRPCConfig ¶
type GRPCConfig struct {
MaxConcurrentStreams uint32 `yaml:"max_concurrent_streams,omitempty" json:"max_concurrent_streams,omitempty" required:"true" default:"100"`
MaxRecvMsgSize int `yaml:"max_recv_msg_size,omitempty" json:"max_recv_msg_size,omitempty" required:"true" default:"20971520"`
ServiceDiscoveryPushInterval time.Duration `yaml:"service_discovery_interval" required:"true" default:"15s"`
ServiceHeartbeatInterval time.Duration `yaml:"service_heartbeat_interval" required:"true" default:"15s"`
}
type HealthCheck ¶
type ImageOptions ¶
type ImageOptions struct {
Podname string
Nodenames []string
Images []string
Prune bool
Filter string
}
ImageOptions carries image op options; Prune applies to remove only.
func (*ImageOptions) Validate ¶
func (o *ImageOptions) Validate() error
type LabelMeta ¶
type LabelMeta struct {
Publish []string
HealthCheck *HealthCheck
}
type LinuxFile ¶
func (LinuxFile) LitterDump ¶
LitterDump renders the file for litter.Sdump.
type ListImageMessage ¶
type ListNodesOptions ¶
type ListWorkloadsOptions ¶
type LogStreamMessage ¶
type LogStreamMessage struct {
ID string
Error error
Data []byte
StdStreamType
}
type LogStreamOptions ¶
type Node ¶
type Node struct {
NodeMeta
// Bypass excludes the node from future scheduling.
Bypass bool `json:"bypass,omitempty"`
// Test skips the node health check.
Test bool `json:"test,omitempty"`
ResourceInfo NodeResourceInfo `json:"-"`
NodeInfo string `json:"-"`
Available bool `json:"-"`
Engine engine.API `json:"-"`
}
type NodeFilter ¶
type NodeFilter struct {
Podname string `yaml:"podname"`
Includes []string `yaml:"includes"`
Excludes []string `yaml:"excludes"`
Labels map[string]string `yaml:"labels"`
All bool `yaml:"all"`
}
NodeFilter selects nodes in a pod by Includes, then drops Excludes.
func (NodeFilter) Narrow ¶ added in v0.1.1
func (f NodeFilter) Narrow(other *NodeFilter) (*NodeFilter, error)
Narrow intersects other into f on pod, names and labels; other may only shrink the selection.
type NodeResourceInfo ¶
type NodeResourceInfo struct {
Name string `json:"-"`
Capacity resourcetypes.Resources `json:"capacity,omitempty"`
Usage resourcetypes.Resources `json:"usage,omitempty"`
Diffs []string `json:"diffs,omitempty"`
Workloads []*Workload `json:"-"`
}
type NodeStatus ¶
NodeStatus carries one node status stream event.
type ProcessConfig ¶ added in v0.1.1
type ProcessConfig struct {
Root string `yaml:"root" default:"/var/lib/eru/process"`
StopTimeout time.Duration `yaml:"stop_timeout" default:"10s"` // grace period before systemd kills the unit
}
ProcessConfig is the node-side layout the process engine writes into.
type Processing ¶
Processing tracks the unfinished workload count for one deploy.
type RawArgs ¶
type RawArgs []byte
func (RawArgs) LitterDump ¶
LitterDump renders the raw args for litter.Sdump.
type RawEngineMessage ¶
type RawEngineOptions ¶
func (*RawEngineOptions) Validate ¶
func (o *RawEngineOptions) Validate() error
type ReallocOptions ¶
type ReallocOptions struct {
ID string
Resources resourcetypes.Resources
}
type RedisConfig ¶
type RegistryConfig ¶ added in v0.1.1
type RegistryConfig struct {
Hub string `yaml:"hub"`
Namespace string `yaml:"namespace"` // image path becomes $Hub/$Namespace/$appname
Auths map[string]AuthConfig `yaml:"auths"` // keyed by registry host
PlainHTTP []string `yaml:"plain_http"` // registry hosts served without TLS
}
RegistryConfig is the registry every engine pulls from and pushes built images to.
func (RegistryConfig) BuildRefs ¶ added in v0.1.1
func (c RegistryConfig) BuildRefs(appname string, tags []string) []string
func (RegistryConfig) ImageTag ¶ added in v0.1.1
func (c RegistryConfig) ImageTag(appname, tag string) string
ImageTag renders the registry reference an app's built image is pushed under.
type RemoveImageMessage ¶
type RemoveWorkloadMessage ¶
type ReplaceOptions ¶
type ReplaceOptions struct {
DeployOptions
NetworkInherit bool
FilterLabels map[string]string
Copy map[string]string
IDs []string
}
func (*ReplaceOptions) Normalize ¶
func (o *ReplaceOptions) Normalize()
Normalize defaults Count to 1.
func (*ReplaceOptions) Validate ¶
func (o *ReplaceOptions) Validate() error
Validate skips Image; pullImage in cluster/calcium checks it.
type ReplaceWorkloadMessage ¶
type ReplaceWorkloadMessage struct {
Create *CreateWorkloadMessage
Remove *RemoveWorkloadMessage
Error error
}
type ResourcePluginConfig ¶
type SSHConfig ¶ added in v0.1.1
type SSHConfig struct {
PrivateKey string `yaml:"private_key"` // file path
User string `yaml:"user" default:"root"`
KnownHosts string `yaml:"known_hosts"` // file path; empty accepts any host key
}
SSHConfig is core's key pair for the nodes it drives over SSH.
type SchedulerConfig ¶
type SchedulerConfig struct {
MaxDeployCount int `yaml:"max_deploy_count" default:"10000"`
}
type SendLargeFileOptions ¶
type SendLargeFileOptions struct {
IDs []string
Dst string
Size int64
Mode int64
UID int
GID int
Chunk []byte
}
SendLargeFileOptions carries one chunk of a SendLargeFile stream.
func (*SendLargeFileOptions) Validate ¶
func (o *SendLargeFileOptions) Validate() error
type SendMessage ¶
type SendOptions ¶
func (*SendOptions) Validate ¶
func (o *SendOptions) Validate() error
type ServerLogConfig ¶
type ServiceStatus ¶
type SetNodeOptions ¶
type SetNodeOptions struct {
Nodename string
Endpoint string
WorkloadsDown bool
Resources resourcetypes.Resources
Delta bool
Labels map[string]string
Bypass TriOptions
}
func (*SetNodeOptions) Validate ¶
func (o *SetNodeOptions) Validate() error
type StatusMeta ¶
type StatusMeta struct {
ID string `json:"id"`
Networks map[string]string `json:"networks,omitempty"`
Running bool `json:"running,omitempty"`
Healthy bool `json:"healthy,omitempty"`
Extension []byte `json:"extension,omitempty"`
// set only when writing workload status
Appname string `json:"-"`
Nodename string `json:"-"`
Entrypoint string `json:"-"`
}
type StdStreamMessage ¶
type StdStreamMessage struct {
Data []byte
StdStreamType
}
type StdStreamType ¶
type StdStreamType int
const ( // EruError carries an eru error, not user program output. EruError StdStreamType = -1 Stdout StdStreamType = 0 Stderr StdStreamType = 1 // TypeWorkloadID carries the workload ID, not stream data. TypeWorkloadID StdStreamType = 6 )
type TriOptions ¶
type TriOptions int
const ( TriKeep TriOptions = iota TriTrue TriFalse SendLargeFileChunkSize = 256 << 10 )
type Workload ¶
type Workload struct {
Resources resourcetypes.Resources `json:"resources"`
EngineParams resourcetypes.Resources `json:"engine_params"`
ID string `json:"id"`
Name string `json:"name"`
Podname string `json:"podname"`
Nodename string `json:"nodename"`
Hook *Hook `json:"hook"`
Privileged bool `json:"privileged"`
User string `json:"user"`
Env []string `json:"env"`
Image string `json:"image"`
Labels map[string]string `json:"labels"`
CreateTime int64 `json:"create_time"`
StatusMeta *StatusMeta `json:"-"`
Engine engine.API `json:"-"`
}
Workload is the stored pod/node relation; use Inspect for live state.
func (*Workload) Inspect ¶
func (w *Workload) Inspect(ctx context.Context) (*enginetypes.VirtualizationInfo, error)
func (*Workload) RawEngine ¶
func (w *Workload) RawEngine(ctx context.Context, opts *RawEngineOptions) (ans *RawEngineMessage, err error)