Documentation
¶
Index ¶
- Constants
- Variables
- type AddNodeOptions
- type AttachWorkloadMessage
- type AuthConfig
- type Build
- type BuildImageMessage
- type BuildMethod
- type BuildOptions
- type Builds
- type CacheImageMessage
- type CapacityMessage
- type Config
- type ContextValueKey
- type ControlWorkloadMessage
- type CopyMessage
- type CopyOptions
- type CreateWorkloadMessage
- type DeployOptions
- type DissociateWorkloadMessage
- type DockerConfig
- 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 LogConfig
- type LogStreamMessage
- type LogStreamOptions
- type Node
- type NodeFilter
- type NodeMeta
- type NodeResourceInfo
- type NodeStatus
- type Pod
- type Processing
- type PullImageMessage
- type RawArgs
- type RawEngineMessage
- type RawEngineOptions
- type ReallocOptions
- type ReallocResourceMessage
- type RedisConfig
- type RemoveImageMessage
- type RemoveWorkloadMessage
- type ReplaceOptions
- type ReplaceWorkloadMessage
- type ResourcePluginConfig
- type SchedulerConfig
- type SendLargeFileOptions
- type SendMessage
- type SendOptions
- type ServerLogConfig
- type ServiceStatus
- type SetNodeOptions
- type StatusMeta
- type StdStreamMessage
- type StdStreamType
- type SystemdConfig
- type TriOptions
- type VirtConfig
- 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") 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") ErrInvaildIPAddress = errors.New("invalid IP address") ErrInvaildIPWithPort = errors.New("invalid IP with port") ErrAllConnectionsFailed = errors.New("all connections failed") ErrUnexpectedRedirect = errors.New("unexpected redirect") ErrInvaildMemory = errors.New("invalid memory value") ErrNilEngine = errors.New("engine is nil") ErrInvaildRefs = errors.New("invalid image refs") ErrNoImage = errors.New("no image") ErrNoImageUser = errors.New("no image user") ErrInvaildRemoteDigest = errors.New("got invalid digest") 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") ErrNoBuildPod = errors.New("no build pod set in config") 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") ErrTxnConditionFailed = errors.New("etcd txn condition failed") ErrInvaildCount = errors.New("bad `Count` value, entity count invalid") ErrInvaildWALEventType = errors.New("invalid WAL event type") ErrInvaildWALEvent = errors.New("encode WAL event failed") ErrInvalidWALBucket = errors.New("invalid WAL bucket") 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") 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
Ca string
Cert string
Key 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 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 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"` // interval for node status watcher
Statsd string `yaml:"statsd"` // statsd host:port
Profile string `yaml:"profile"` // profile ip:port
CertPath string `yaml:"cert_path"` // docker cert files path
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
WALFile string `yaml:"wal_file" required:"true" default:"core.wal"`
WALOpenTimeout time.Duration `yaml:"wal_open_timeout" required:"true" default:"8s"`
Auth AuthConfig `yaml:"auth"` // grpc auth
GRPCConfig GRPCConfig `yaml:"grpc"`
Git GitConfig `yaml:"git"`
Etcd EtcdConfig `yaml:"etcd"`
Redis RedisConfig `yaml:"redis"`
Docker DockerConfig `yaml:"docker"`
Virt VirtConfig `yaml:"virt"`
Systemd SystemdConfig `yaml:"systemd"`
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 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
ExtraArgs string // appended to the entrypoint command
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 DockerConfig ¶
type DockerConfig struct {
APIVersion string `yaml:"version" required:"true" default:"1.40"`
NetworkMode string `yaml:"network_mode" required:"true" default:"host"`
UseLocalDNS bool `yaml:"use_local_dns"` // use node IP as dns
Log LogConfig `yaml:"log"` // docker log driver
Hub string `yaml:"hub"`
Namespace string `yaml:"namespace"` // image path becomes $Hub/$Namespace/$appname
BuildPod string `yaml:"build_pod"` // podname used to build
AuthConfigs map[string]AuthConfig `yaml:"auths"` // docker registry credentials
}
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"`
Log *LogConfig `yaml:"log,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"` // key prefix for core data
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
Includes []string
Excludes []string
Labels map[string]string
All bool
}
NodeFilter selects nodes in a pod by Includes, then drops Excludes.
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 Processing ¶
Processing tracks the unfinished workload count for one deploy.
type PullImageMessage ¶
type PullImageMessage struct {
BuildImageMessage
}
PullImageMessage carries CacheImage progress.
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 ReallocResourceMessage ¶
type ReallocResourceMessage struct {
WorkloadID string
}
type RedisConfig ¶
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 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
Ca string
Cert string
Key string
}
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 SystemdConfig ¶
type SystemdConfig struct {
Runtime string `yaml:"runtime" default:"io.containerd.eru.v2"`
}
type TriOptions ¶
type TriOptions int
const ( TriKeep TriOptions = iota TriTrue TriFalse SendLargeFileChunkSize = 2 << 10 )
type VirtConfig ¶
type VirtConfig struct {
APIVersion string `yaml:"version" default:"v1"` // Yavirtd API version
}
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)