types

package
v0.0.0-...-06bcc1c Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 13 Imported by: 25

Documentation

Index

Constants

View Source
const (
	// Etcd .
	Etcd = "etcd"
	// Redis .
	Redis = "redis"
)
View Source
const (
	// TriKeep .
	TriKeep = iota
	// TriTrue .
	TriTrue
	// TriFalse .
	TriFalse
)
View Source
const SendLargeFileChunkSize = 2 << 10

Variables

View Source
var (
	// Scheduler
	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 method not support yet")

	// Resources
	ErrNodeExists = errors.New("node already exists")

	// Node
	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")

	// Lock
	ErrLockKeyInvaild  = errors.New("lock key is invalid")
	ErrLockSessionDone = errors.New("lock session done")

	// Client
	ErrInvaildEruIPAddress = errors.New("invalid eru address")

	// SCM
	ErrInvaildSCMType          = errors.New("SCM type not support yet")
	ErrDownloadArtifactsFailed = errors.New("download artifacts failed")

	// General
	ErrInvaildIPAddress     = errors.New("invalid IP address")
	ErrInvaildIPWithPort    = errors.New("invalid IP with port")
	ErrICMPLost             = errors.New("icmp packets lost")
	ErrAllConnectionsFailed = errors.New("all connections failed")
	ErrUnexpectedRedirect   = errors.New("unexpected redirect")

	// Engine
	ErrInvaildMemory         = errors.New("invalid `Memory` value setting")
	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("not Support endpoint")
	ErrEngineNotImplemented  = errors.New("not implemented")
	ErrInvalidEngineArgs     = errors.New("invalid engine args")

	// Workload
	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")

	// Pod
	ErrPodHasNodes = errors.New("pod has nodes")
	ErrPodNoNodes  = errors.New("pod has no nodes")
	ErrPodNotFound = errors.New("pod not found")

	// GRPC
	ErrInvaildGRPCRequestMeta = errors.New("invalid grpc request meta")
	ErrInvaildGRPCPassword    = errors.New("invalid grpc password")
	ErrInvaildGRPCUsername    = errors.New("invalid grpc username")

	// Opts Validation
	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")

	// Store
	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") // store key-value count not same
	ErrStoreNotImplemented = errors.New("not implemented")

	// WAL
	ErrInvaildWALEventType = errors.New("invalid WAL event type")
	ErrInvaildWALEvent     = errors.New("invalid WAL event type")
	ErrInvalidWALBucket    = errors.New("invalid WAL bucket")
	ErrInvalidWALDataType  = errors.New("invalid WAL data type")

	// Create
	ErrInvaildDeployCount    = errors.New("invalid deploy count")
	ErrRollbackMapIsNotEmpty = errors.New("rollback map is not empty")
	ErrGetMostIdleNodeFailed = errors.New("get most idle node failed")

	// Selfmon
	ErrMessageChanClosed = errors.New("message chan closed")

	// File
	ErrNoFilesToSend = errors.New("no files to send")
	ErrNoFilesToCopy = errors.New("no files to copy")

	// Core
	ErrInvaildCoreEndpointType = errors.New("invalid Core endpoint type")

	// Test
	ErrMockError = errors.New("mock error")

	// Metrics
	ErrMetricsTypeNotSupport = errors.New("metrics type not support")

	// Plugin
	ErrConfigInvaild = errors.New("config invalid")
)

Functions

func ParseTriOption

func ParseTriOption(opt TriOptions, original bool) (res bool)

ParseTriOption .

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
}

AddNodeOptions for adding node

func (*AddNodeOptions) Validate

func (o *AddNodeOptions) Validate() error

Validate checks options

type AttachWorkloadMessage

type AttachWorkloadMessage struct {
	WorkloadID string
	Data       []byte
	StdStreamType
}

AttachWorkloadMessage for run and wait

type AuthConfig

type AuthConfig struct {
	Username string `yaml:"username,omitempty" json:"username,omitempty"`
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
}

AuthConfig contains authorization information for connecting to a Registry Basically copied from https://github.com/moby/moby/blob/16a1736b9b93e44c898f95d670bbaf20a558103d/api/types/auth.go#L4 But use yaml instead of json And we use it as grpc simple auth

type Bind

type Bind struct {
	InWorkloadPath string `yaml:"bind,omitempty"`
	ReadOnly       bool   `yaml:"ro,omitempty"`
}

Bind define a single bind

type Build

type Build = enginetypes.Build

Build is identical to enginetype.Build

type BuildImageMessage

type BuildImageMessage struct {
	ID          string      `json:"id,omitempty"`
	Status      string      `json:"status,omitempty"`
	Progress    string      `json:"progress,omitempty"`
	Error       string      `json:"error,omitempty"`
	Stream      string      `json:"stream,omitempty"`
	ErrorDetail errorDetail `json:"errorDetail,omitempty"`
}

BuildImageMessage for build image ops message

type BuildMethod

type BuildMethod int

BuildMethod .

const (
	// BuildFromSCM must be default method to avoid breaking
	BuildFromSCM BuildMethod = iota
	// BuildFromUnknown .
	BuildFromUnknown
	// BuildFromRaw .
	BuildFromRaw
	// BuildFromExist .
	BuildFromExist
)

type BuildOptions

type BuildOptions struct {
	Name string
	User string
	UID  int
	Tags []string
	BuildMethod
	*Builds
	Tar      io.Reader
	ExistID  string
	Platform string
}

BuildOptions is options for building image

type Builds

type Builds = enginetypes.Builds

Builds is identical to enginetype.Builds

type CacheImageMessage

type CacheImageMessage struct {
	Image    string
	Success  bool
	Nodename string
	Message  string
}

CacheImageMessage for cache image on pod

type CapacityMessage

type CapacityMessage struct {
	Total          int
	NodeCapacities map[string]int
}

CapacityMessage for CalculateCapacity API output

type Config

type Config struct {
	Bind                string        `yaml:"bind" required:"true" default:"5001"`                 // HTTP API address
	LockTimeout         time.Duration `yaml:"lock_timeout" required:"true" default:"30s"`          // timeout for lock (ttl)
	GlobalTimeout       time.Duration `yaml:"global_timeout" required:"true" default:"300s"`       // timeout for remove, run_and_wait and build, in second
	ConnectionTimeout   time.Duration `yaml:"connection_timeout" required:"true" default:"10s"`    // timeout for connections
	HAKeepaliveInterval time.Duration `yaml:"ha_keepalive_interval" required:"true" default:"16s"` // interval for node status watcher
	Statsd              string        `yaml:"statsd"`                                              // statsd host and port
	Profile             string        `yaml:"profile"`                                             // profile ip:port
	CertPath            string        `yaml:"cert_path"`                                           // docker cert files path
	MaxConcurrency      int           `yaml:"max_concurrency" default:"100000"`                    // concurrently call single runtime in the same time
	Store               string        `yaml:"store" default:"etcd"`                                // store type
	SentryDSN           string        `yaml:"sentry_dsn"`                                          // 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"`   // WAL file path
	WALOpenTimeout time.Duration `yaml:"wal_open_timeout" required:"true" default:"8s"` // timeout for opening a WAL file

	Auth           AuthConfig           `yaml:"auth"` // grpc auth
	GRPCConfig     GRPCConfig           `yaml:"grpc"` // grpc config
	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"`
}

Config holds eru-core config

func (Config) Identifier

func (c Config) Identifier() (string, error)

Identifier returns the ID of this config we consider the same storage as the same config

type ContextValueKey

type ContextValueKey int

ContextValueKey .

const (
	// TracingID .
	TracingID ContextValueKey = iota
)

type ControlWorkloadMessage

type ControlWorkloadMessage struct {
	WorkloadID string
	Error      error
	Hook       []*bytes.Buffer
}

ControlWorkloadMessage for workload control message

type CopyMessage

type CopyMessage struct {
	ID        string `json:"id,omitempty"`
	Path      string `json:"path,omitempty"`
	Error     error  `json:"error,omitempty"`
	LinuxFile `json:"-"`
}

CopyMessage for copy message

type CopyOptions

type CopyOptions struct {
	Targets map[string][]string
}

CopyOptions for multiple workload files copy

func (*CopyOptions) Validate

func (o *CopyOptions) Validate() error

Validate checks options

type CreateWorkloadMessage

type CreateWorkloadMessage struct {
	EngineParams resourcetypes.Resources
	Resources    resourcetypes.Resources
	Podname      string
	Nodename     string
	WorkloadID   string
	WorkloadName string
	Error        error
	Publish      map[string][]string
	Hook         []*bytes.Buffer
}

CreateWorkloadMessage for create message

type DeployOptions

type DeployOptions struct {
	Resources      resourcetypes.Resources
	Name           string            // Name of application
	Entrypoint     *Entrypoint       // entrypoint
	Podname        string            // Name of pod to deploy
	NodeFilter     *NodeFilter       // filter of nodenames, using includes or not using excludes
	Image          string            // Name of image to deploy
	ExtraArgs      string            // Extra arguments to append to command
	Count          int               // How many workloads needed, e.g. 4
	Env            []string          // Env for workload
	DNS            []string          // DNS for workload
	ExtraHosts     []string          // Extra hosts for workload
	Networks       map[string]string // Network names and specified IPs
	User           string            // User for workload
	Debug          bool              // debug mode, use syslog as log driver
	OpenStdin      bool              // OpenStdin for workload
	Labels         map[string]string // Labels for workloads
	DeployStrategy string            // Deploy strategy
	Files          []LinuxFile       // For additional file data
	NodesLimit     int               // Limit nodes count
	ProcessIdent   string            // ProcessIdent ident this deploy
	IgnoreHook     bool              // IgnoreHook ignore hook process
	AfterCreate    []string          // AfterCreate support run cmds after create
	RawArgs        RawArgs           // RawArgs for raw args processing
	Lambda         bool              // indicate is lambda workload or not
	IgnorePull     bool              // ignore pull image
}

DeployOptions is options for deploying

func (DeployOptions) GetProcessing

func (o DeployOptions) GetProcessing(nodename string) *Processing

GetProcessing .

func (*DeployOptions) Validate

func (o *DeployOptions) Validate() error

Validate checks options

type DissociateWorkloadMessage

type DissociateWorkloadMessage struct {
	WorkloadID string
	Error      error
}

DissociateWorkloadMessage for dissociate workload message

type DockerConfig

type DockerConfig struct {
	APIVersion  string    `yaml:"version" required:"true" default:"1.32"`      // docker API version
	NetworkMode string    `yaml:"network_mode" required:"true" default:"host"` // docker network mode
	UseLocalDNS bool      `yaml:"use_local_dns"`                               // use node IP as dns
	Log         LogConfig `yaml:"log"`                                         // docker log driver

	Hub         string                `yaml:"hub"`       // docker hub address
	Namespace   string                `yaml:"namespace"` // docker hub prefix, will be set to $Hub/$HubPrefix/$appname
	BuildPod    string                `yaml:"build_pod"` // podname used to build
	AuthConfigs map[string]AuthConfig `yaml:"auths"`     // docker registry credentials
}

DockerConfig holds eru-core docker config

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"`
}

Entrypoint is a single entrypoint

func (*Entrypoint) Validate

func (e *Entrypoint) Validate() error

Validate checks entrypoint's name

type EtcdConfig

type EtcdConfig struct {
	Machines   []string   `yaml:"machines" required:"true"`                           // etcd cluster addresses
	Prefix     string     `yaml:"prefix" required:"true" default:"/eru"`              // etcd lock prefix, all locks will be created under this dir
	LockPrefix string     `yaml:"lock_prefix" required:"true" default:"__lock__/eru"` // etcd lock prefix, all locks will be created under this dir
	Ca         string     `yaml:"ca"`                                                 // etcd ca
	Key        string     `yaml:"key"`                                                // etcd key
	Cert       string     `yaml:"cert"`                                               // etcd trusted_ca
	Auth       AuthConfig `yaml:"auth"`                                               // etcd auth
}

EtcdConfig holds eru-core etcd config

type ExecuteWorkloadOptions

type ExecuteWorkloadOptions struct {
	WorkloadID string
	Commands   []string
	Envs       []string
	Workdir    string
	OpenStdin  bool
	ReplCmd    []byte
}

ExecuteWorkloadOptions for executing commands in running workload

type GRPCConfig

type GRPCConfig struct {
	MaxConcurrentStreams         int           `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"`
}

GRPCConfig indicate grpc config

type GitConfig

type GitConfig struct {
	SCMType      string        `yaml:"scm_type"`                     // source code manager type [gitlab/github]
	PrivateKey   string        `yaml:"private_key"`                  // private key to clone code
	Token        string        `yaml:"token"`                        // token to call SCM API
	CloneTimeout time.Duration `yaml:"clone_timeout" default:"300s"` // clone timeout
}

GitConfig holds eru-core git config

type HealthCheck

type HealthCheck struct {
	TCPPorts []string `yaml:"tcp_ports,omitempty,flow"`
	HTTPPort string   `yaml:"http_port"`
	HTTPURL  string   `yaml:"url,omitempty"`
	HTTPCode int      `yaml:"code,omitempty"`
}

HealthCheck define healthcheck

type Hook

type Hook struct {
	AfterStart    []string `yaml:"after_start,omitempty"`
	BeforeStop    []string `yaml:"before_stop,omitempty"`
	AfterResume   []string `yaml:"after_resume,omitempty"`
	BeforeSuspend []string `yaml:"before_suspend,omitempty"`
	Force         bool     `yaml:"force,omitempty"`
}

Hook define hooks

type Image

type Image struct {
	ID   string
	Tags []string
}

Image .

type ImageOptions

type ImageOptions struct {
	Podname   string
	Nodenames []string
	Images    []string
	Prune     bool
	Filter    string
}

ImageOptions wraps options for images Prune is only used when remove image

func (*ImageOptions) Validate

func (o *ImageOptions) Validate() error

Validate checks the options

type LabelMeta

type LabelMeta struct {
	Publish     []string
	HealthCheck *HealthCheck
}

LabelMeta bind meta info store in labels

type LinuxFile

type LinuxFile struct {
	Content  []byte
	Filename string
	UID      int
	GID      int
	Mode     int64
}

LinuxFile is used for copy file

func (LinuxFile) Clone

func (f LinuxFile) Clone() LinuxFile

Clone returns a copy of content bytes

func (LinuxFile) LitterDump

func (f LinuxFile) LitterDump(w io.Writer)

LitterDump for litter.Sdump

func (LinuxFile) String

func (f LinuxFile) String() string

String for %+v

type ListImageMessage

type ListImageMessage struct {
	Images   []*Image
	Nodename string
	Error    error
}

ListImageMessage for list image

type ListNodesOptions

type ListNodesOptions struct {
	Podname  string
	Labels   map[string]string
	All      bool
	CallInfo bool
}

ListNodesOptions for list nodes

type ListWorkloadsOptions

type ListWorkloadsOptions struct {
	Appname    string
	Entrypoint string
	Nodename   string
	Limit      int64
	Labels     map[string]string
}

ListWorkloadsOptions for list workloads

type LogConfig

type LogConfig struct {
	Type   string            `yaml:"type" required:"true" default:"journald"` // Log type, can be "journald", "json-file", "none"
	Config map[string]string `yaml:"config"`                                  // Log configs
}

LogConfig define log type

type LogStreamMessage

type LogStreamMessage struct {
	ID    string
	Error error
	Data  []byte
	StdStreamType
}

LogStreamMessage for log stream

type LogStreamOptions

type LogStreamOptions struct {
	ID     string
	Tail   string
	Since  string
	Until  string
	Follow bool
}

LogStreamOptions log stream options

type Node

type Node struct {
	NodeMeta
	// Bypass if bypass is true, it will not participate in future scheduling
	Bypass bool `json:"bypass,omitempty"`
	// Test mean can ignore node health check
	Test bool `json:"test,omitempty"`

	ResourceInfo NodeResourceInfo `json:"-"`
	NodeInfo     string           `json:"-"`
	Available    bool             `json:"-"`
	Engine       engine.API       `json:"-"`
}

Node store node info

func (*Node) Info

func (n *Node) Info(ctx context.Context) (err error)

Info show node info

func (*Node) IsDown

func (n *Node) IsDown() bool

IsDown returns if the node is marked as down.

type NodeFilter

type NodeFilter struct {
	Podname  string
	Includes []string
	Excludes []string
	Labels   map[string]string
	All      bool
}

NodeFilter is used to filter nodes in a pod names in includes will be used names in excludes will not be used

type NodeMeta

type NodeMeta struct {
	Name     string            `json:"name" mapstructure:"name"`
	Endpoint string            `json:"endpoint" mapstructure:"endpoint"`
	Podname  string            `json:"podname" mapstructure:"podname"`
	Labels   map[string]string `json:"labels" mapstructure:"labels"`

	Ca   string `json:"-" mapstructure:"-"`
	Cert string `json:"-" mapstructure:"-"`
	Key  string `json:"-" mapstructure:"-"`
}

NodeMeta .

func (NodeMeta) DeepCopy

func (n NodeMeta) DeepCopy() (nn NodeMeta, err error)

DeepCopy returns a deepcopy of nodemeta

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:"-"`
}

NodeResourceInfo for node resource info

type NodeStatus

type NodeStatus struct {
	Nodename string
	Podname  string
	Alive    bool
	Error    error
}

NodeStatus wraps node status only used for node status stream

type Pod

type Pod struct {
	Name string `json:"name"`
	Desc string `json:"desc"`
}

Pod define pod

type Processing

type Processing struct {
	Appname   string
	Entryname string
	Nodename  string
	Ident     string
}

Processing tracks workloads count yet finished

type PullImageMessage

type PullImageMessage struct {
	BuildImageMessage
}

PullImageMessage for cache image

type RawArgs

type RawArgs []byte

RawArgs .

func (RawArgs) LitterDump

func (r RawArgs) LitterDump(w io.Writer)

LitterDump from litter.Dumper

func (RawArgs) String

func (r RawArgs) String() string

String for %+v

type RawEngineMessage

type RawEngineMessage struct {
	ID   string `json:"id,omitempty"`
	Data []byte `json:"data,omitempty"`
}

type RawEngineOptions

type RawEngineOptions struct {
	ID         string
	Op         string
	Params     []byte
	IgnoreLock bool // whether lock the workload
}

func (*RawEngineOptions) Validate

func (o *RawEngineOptions) Validate() error

type ReallocOptions

type ReallocOptions struct {
	ID        string
	Resources resourcetypes.Resources
}

ReallocOptions .

type ReallocResourceMessage

type ReallocResourceMessage struct {
	WorkloadID string
}

ReallocResourceMessage for realloc resource

type RedisConfig

type RedisConfig struct {
	Addr       string `yaml:"addr" default:"localhost:6379"` // redis address
	LockPrefix string `yaml:"lock_prefix" default:"/lock"`   // redis lock prefix
	DB         int    `yaml:"db" default:"0"`                // redis db
}

RedisConfig holds redis config LockPrefix is used for lock

type RemoveImageMessage

type RemoveImageMessage struct {
	Image    string
	Success  bool
	Messages []string
}

RemoveImageMessage for remove image message

type RemoveWorkloadMessage

type RemoveWorkloadMessage struct {
	WorkloadID string
	Success    bool
	Hook       []*bytes.Buffer
}

RemoveWorkloadMessage for remove message

type ReplaceOptions

type ReplaceOptions struct {
	DeployOptions
	NetworkInherit bool
	FilterLabels   map[string]string
	Copy           map[string]string
	IDs            []string
}

ReplaceOptions for replace workload

func (*ReplaceOptions) Normalize

func (o *ReplaceOptions) Normalize()

Normalize checks count

func (*ReplaceOptions) Validate

func (o *ReplaceOptions) Validate() error

Validate doesn't check image here because in cluster/calcium//helper.go, pullImage will check this to keep the original behavior, no check here.

type ReplaceWorkloadMessage

type ReplaceWorkloadMessage struct {
	Create *CreateWorkloadMessage
	Remove *RemoveWorkloadMessage
	Error  error
}

ReplaceWorkloadMessage for replace method

type ResourcePluginConfig

type ResourcePluginConfig struct {
	Dir         string        `yaml:"dir" default:""`             // resource plugins path
	CallTimeout time.Duration `yaml:"call_timeout" default:"30s"` // timeout for calling resource plugins
	Whitelist   []string      `yaml:"whitelist"`                  // plugin whitelist
}

ResourcePluginConfig define Plugin config

type SchedulerConfig

type SchedulerConfig struct {
	MaxShare       int `yaml:"maxshare" required:"true" default:"-1"`   // comlpex scheduler use maxshare
	ShareBase      int `yaml:"sharebase" required:"true" default:"100"` // how many pieces for one core
	MaxDeployCount int `yaml:"max_deploy_count" default:"10000"`        // max deploy count of each node
}

SchedulerConfig holds scheduler config

type SendLargeFileOptions

type SendLargeFileOptions struct {
	IDs   []string
	Dst   string
	Size  int64
	Mode  int64
	UID   int
	GID   int
	Chunk []byte
}

SendLargeFileOptions for LargeFileTransfer

func (*SendLargeFileOptions) Validate

func (o *SendLargeFileOptions) Validate() error

Validate checks options

type SendMessage

type SendMessage struct {
	ID    string `json:"id,omitempty"`
	Path  string `json:"path,omitempty"`
	Error error  `json:"error,omitempty"`
}

SendMessage for send message

type SendOptions

type SendOptions struct {
	IDs   []string
	Files []LinuxFile
}

SendOptions for send files to multiple workload

func (*SendOptions) Validate

func (o *SendOptions) Validate() error

Validate checks options

type ServerLogConfig

type ServerLogConfig struct {
	Level   string `yaml:"level" default:"info"`
	UseJSON bool   `yaml:"use_json"`
	// for file log
	Filename   string `yaml:"filename"`
	MaxSize    int    `yaml:"maxsize" default:"500"`
	MaxAge     int    `yaml:"max_age" default:"28"`
	MaxBackups int    `yaml:"max_backups" default:"3"`
}

type ServiceStatus

type ServiceStatus struct {
	Addresses []string
	Interval  time.Duration
}

ServiceStatus Interval indicates when the expected next push shall reach before

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
}

SetNodeOptions for node set

func (*SetNodeOptions) Validate

func (o *SetNodeOptions) Validate() error

Validate checks options

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"`

	// These attributes are only used when setting workload status.
	Appname    string `json:"-"`
	Nodename   string `json:"-"`
	Entrypoint string `json:"-"`
}

StatusMeta indicate contaienr runtime

type StdStreamMessage

type StdStreamMessage struct {
	Data []byte
	StdStreamType
}

StdStreamMessage embodies bytes and std type

type StdStreamType

type StdStreamType int

StdStreamType shows stdout / stderr

const (
	// EruError means this message is carrying some error from eru
	// not from user program
	EruError StdStreamType = -1
	// Stdout means this message is carrying stdout from user program
	Stdout StdStreamType = 0
	// Stderr means this message is carrying stderr from user program
	Stderr StdStreamType = 1
	// TypeWorkloadID means this is the workload id
	TypeWorkloadID StdStreamType = 6
)

type SystemdConfig

type SystemdConfig struct {
	Runtime string `yaml:"runtime" default:"io.containerd.eru.v2"`
}

SystemdConfig is systemd config

type TriOptions

type TriOptions int

TriOptions .

type VirtConfig

type VirtConfig struct {
	APIVersion string `yaml:"version" default:"v1"` // Yavirtd API version
}

VirtConfig holds yavirtd config

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 store workload info only relationship with pod and node is stored if you wanna get realtime information, use Inspect method

func (*Workload) Inspect

Inspect a workload

func (*Workload) RawEngine

func (c *Workload) RawEngine(ctx context.Context, opts *RawEngineOptions) (ans *RawEngineMessage, err error)

func (*Workload) Remove

func (c *Workload) Remove(ctx context.Context, force bool) (err error)

Remove a workload

func (*Workload) Resume

func (c *Workload) Resume(ctx context.Context) error

Resume a workload

func (*Workload) Start

func (c *Workload) Start(ctx context.Context) error

Start a workload

func (*Workload) Stop

func (c *Workload) Stop(ctx context.Context, force bool) error

Stop a workload

func (*Workload) Suspend

func (c *Workload) Suspend(ctx context.Context) error

Suspend a workload

type WorkloadStatus

type WorkloadStatus struct {
	ID       string
	Workload *Workload
	Error    error
	Delete   bool
}

WorkloadStatus store deploy status

Jump to

Keyboard shortcuts

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