Documentation
¶
Index ¶
- Constants
- Variables
- func CancelPorts(sps ...*StreamProc)
- func ConfigPortsManager(endpoint string)
- func GuardGotoSleep(store storage.Store) bool
- func GuardGotoWork(store storage.Store) bool
- func NewConstraintController() *constraintController
- func NewNotifyController(stop chan struct{}) *notifyController
- func OccupiedPorts(ports ...int) []int
- func RefreshPorts(pgCtrls map[string]*podGroupController)
- func RegisterPorts(sps ...*StreamProc) (bool, []int)
- func UpdatePorts(sps ...*StreamProc)
- type BaseRuntime
- type CloudVolumeSpec
- type ConstraintSpec
- type Container
- type ContainerLabel
- type ContainerSpec
- type Dependency
- type DependencyEvent
- type DependencyPolicy
- type Guard
- type HealthCnfOptions
- type HealthConfig
- type HealthState
- type ImRuntime
- type ImSpec
- type Listener
- type NamespacePodsWithSpec
- type NotifySpec
- type OrcEngine
- func (engine *OrcEngine) AddNotify(callback string) error
- func (engine *OrcEngine) DeleteConstraints(cstType string) error
- func (engine *OrcEngine) DeleteNotify(callback string) error
- func (engine *OrcEngine) DriftNode(fromNode, toNode string, pgName string, pgInstance int, force bool)
- func (engine *OrcEngine) GetConstraints(cstType string) (ConstraintSpec, bool)
- func (engine *OrcEngine) GetDependencyPod(name string) (NamespacePodsWithSpec, error)
- func (engine *OrcEngine) GetNodes() ([]cluster.Node, error)
- func (engine *OrcEngine) GetNotifies() []string
- func (engine *OrcEngine) GuardGotoSleep() bool
- func (engine *OrcEngine) GuardGotoWork() bool
- func (engine *OrcEngine) HandleEvent(payload interface{})
- func (engine *OrcEngine) InspectPodGroup(name string) (PodGroupWithSpec, bool)
- func (engine *OrcEngine) ListenerId() string
- func (engine *OrcEngine) LoadDependsPods() error
- func (engine *OrcEngine) LoadPodGroups() error
- func (engine *OrcEngine) NewDependencyPod(spec PodSpec) error
- func (engine *OrcEngine) NewPodGroup(spec PodGroupSpec) error
- func (engine *OrcEngine) RefreshPodGroup(name string, forceUpdate bool) error
- func (engine *OrcEngine) RemoveDependencyPod(name string, force bool) error
- func (engine *OrcEngine) RemovePodGroup(name string) error
- func (engine *OrcEngine) RescheduleInstance(name string, numInstances int, restartPolicy ...RestartPolicy) error
- func (engine *OrcEngine) RescheduleSpec(name string, podSpec PodSpec) error
- func (engine *OrcEngine) Start()
- func (engine *OrcEngine) Started() bool
- func (engine *OrcEngine) Stop()
- func (engine *OrcEngine) UpdateConstraints(spec ConstraintSpec) error
- func (engine *OrcEngine) UpdateDependencyPod(spec PodSpec) error
- type Pod
- type PodGroup
- type PodGroupPrevState
- type PodGroupSpec
- type PodGroupWithSpec
- type PodPrevState
- type PodSpec
- func (s PodSpec) Clone() PodSpec
- func (s PodSpec) Equals(o PodSpec) bool
- func (s PodSpec) GetKillTimeout() int
- func (s PodSpec) GetSetupTime() int
- func (s PodSpec) HasVolumes() bool
- func (s PodSpec) IsHardStateful() bool
- func (s PodSpec) IsStateful() bool
- func (s PodSpec) Merge(o PodSpec) PodSpec
- func (s PodSpec) String() string
- func (s PodSpec) VerifyParams() bool
- type PortsManager
- func (pm *PortsManager) CancelStreamPort(sp *StreamProc) bool
- func (pm PortsManager) CancelStreamPorts(spArr ...*StreamProc)
- func (pm PortsManager) FetchAllStreamPortsInfo() []StreamProc
- func (pm PortsManager) Refresh(pgCtrls map[string]*podGroupController)
- func (pm PortsManager) RegisterStreamPort(sp *StreamProc) bool
- func (pm PortsManager) RegisterStreamPorts(spArr ...*StreamProc) (bool, []int)
- func (pm *PortsManager) UpdateStreamPort(sp *StreamProc) bool
- func (pm PortsManager) UpdateStreamPorts(spArr ...*StreamProc)
- type Publisher
- type Resource
- type RestartPolicy
- type RunState
- type RuntimeEaglePod
- type RuntimeEagleView
- func (ev *RuntimeEagleView) Activate(c cluster.Cluster)
- func (ev *RuntimeEagleView) GetRuntimeEaglePods(name string) ([]RuntimeEaglePod, bool)
- func (ev *RuntimeEagleView) Refresh(c cluster.Cluster) error
- func (ev *RuntimeEagleView) RefreshPodGroup(c cluster.Cluster, pgName string) ([]RuntimeEaglePod, error)
- func (ev *RuntimeEagleView) RefreshPodsByNamespace(c cluster.Cluster, namespace string) ([]RuntimeEaglePod, error)
- type SharedPodWithSpec
- type StreamPort
- type StreamPorts
- type StreamProc
Constants ¶
View Source
const ( EtcdResourcesKey = "/lain/config/resources" EtcdGuardSwitchKey = "/lain/config/guardswitch" )
View Source
const ( DefaultHealthInterval = 10 DefaultHealthTimeout = 5 DefaultHealthRetries = 3 CPUQuota = int64(1000000) CPUMaxPctg = 50 // max percentage of total cpu CPUMaxLevel = 8 CPUDeafultLevel = 2 CURL_TMPLT = `echo $(curl -s -o /dev/null -w '%%{http_code}\n' %s) | grep -Eq "^[2-3]..$"` )
View Source
const ( RunStatePending = iota RunStateDrift RunStateSuccess RunStateExit RunStateFail RunStateInconsistent RunStateMissing RunStateRemoved )
View Source
const ( HealthStateNone = iota HealthStateStarting HealthStateHealthy HealthStateUnHealthy )
View Source
const ( MinPodSetupTime = 0 MaxPodSetupTime = 300 MinPodKillTimeout = 10 MaxPodKillTimeout = 120 )
View Source
const ( CloudVolumeSingleMode = "single" CloudVolumeMultiMode = "multi" )
View Source
const ( DependencyNamespaceLevel = iota DependencyNodeLevel )
View Source
const ( RestartPolicyNever = iota RestartPolicyAlways RestartPolicyOnFail )
View Source
const (
ClusterFailedThreadSold = 20
)
View Source
const (
KeyPrefixStreamPorts = "/lain/deployd/stream/ports"
)
Variables ¶
View Source
var ( ErrPodGroupExists = errors.New("PodGroup has already existed") ErrPodGroupNotExists = errors.New("PodGroup not existed") ErrPodGroupCleaning = errors.New("PodGroup is removing, need to wait for that") ErrNotEnoughResources = errors.New("Not enough CPUs and Memory to use") ErrDependencyPodExists = errors.New("DependencyPod has already existed") ErrDependencyPodNotExists = errors.New("DependencyPod not existed") ErrConstraintNotExists = errors.New("Constraint not existed") ErrNotifyNotExists = errors.New("Notify uri not existed") )
View Source
var ( NotifyPodMissing = "LAIN found pod missing, ready to redeployd it" NotifyPodDown = "LAIN found pod down, ready to restart it" NotifyPodDownOOM = "LAIN found pod down with OOM, ready to restart it" NotifyLetPodGo = "LAIN found pod restart too many times in a short period, will let it go" NotifyPodIPLost = "LAIN found pod lost IP, please inform the SA team" NotifyPodUnHealthy = "LAIN found pod Unhealthy, please check your service" NotifyClusterUnHealthy = "LAIN found Cluster Manager Unhealthy, please check your cluster" )
View Source
var DependsGarbageCollectTimeout time.Duration
set GarbageCollectTimeout long enough. sometimes, podgroup refresh goroutine may having some problem(such as swarm exception), and do not verify it's portal for a long time
View Source
var RefreshInterval int
View Source
var RestartInfoClearInterval time.Duration
some instances written with JAVA like language may suffer from OOM, if they are restarted before (now - RestartInfoClearInterval), clear the restart info
View Source
var RestartMaxCount int
Functions ¶
func CancelPorts ¶
func CancelPorts(sps ...*StreamProc)
func ConfigPortsManager ¶
func ConfigPortsManager(endpoint string)
func GuardGotoSleep ¶
func GuardGotoWork ¶
func NewConstraintController ¶
func NewConstraintController() *constraintController
func NewNotifyController ¶
func NewNotifyController(stop chan struct{}) *notifyController
func OccupiedPorts ¶
func RefreshPorts ¶
func RefreshPorts(pgCtrls map[string]*podGroupController)
func RegisterPorts ¶
func RegisterPorts(sps ...*StreamProc) (bool, []int)
func UpdatePorts ¶
func UpdatePorts(sps ...*StreamProc)
Types ¶
type BaseRuntime ¶
type CloudVolumeSpec ¶
func (CloudVolumeSpec) Clone ¶
func (s CloudVolumeSpec) Clone() CloudVolumeSpec
func (CloudVolumeSpec) Equals ¶
func (s CloudVolumeSpec) Equals(o CloudVolumeSpec) bool
func (CloudVolumeSpec) VerifyParams ¶
func (s CloudVolumeSpec) VerifyParams() bool
type Container ¶
type ContainerLabel ¶
type ContainerLabel struct {
Name string
Namespace string
InstanceNo int
Version int
DriftCount int
ContainerIndex int
Annotation string
}
func (ContainerLabel) Label2Maps ¶
func (label ContainerLabel) Label2Maps() map[string]string
func (ContainerLabel) NameAffinity ¶
func (label ContainerLabel) NameAffinity() string
type ContainerSpec ¶
type ContainerSpec struct {
ImSpec
Image string
Env []string
User string
WorkingDir string
DnsSearch []string
Volumes []string // a stateful flag
SystemVolumes []string // not a stateful flag, every node has system volumes
CloudVolumes []CloudVolumeSpec
Command []string
Entrypoint []string
CpuLimit int
MemoryLimit int64
Expose int
LogConfig adoc.LogConfig
}
func NewContainerSpec ¶
func NewContainerSpec(image string) ContainerSpec
func (ContainerSpec) Clone ¶
func (s ContainerSpec) Clone() ContainerSpec
func (ContainerSpec) Equals ¶
func (s ContainerSpec) Equals(o ContainerSpec) bool
func (ContainerSpec) VerifyParams ¶
func (s ContainerSpec) VerifyParams() bool
type Dependency ¶
type Dependency struct {
PodName string
Policy DependencyPolicy
}
func (Dependency) Clone ¶
func (d Dependency) Clone() Dependency
type DependencyEvent ¶
type DependencyPolicy ¶
type DependencyPolicy int
type Guard ¶
type Guard struct {
Working bool `json:"Working"`
}
func FetchGuard ¶
func FetchGuard() *Guard
type HealthCnfOptions ¶
type HealthCnfOptions struct {
Interval int `json:"interval"`
Timeout int `json:"timeout"`
Retries int `json:"retries"`
}
func (HealthCnfOptions) Equals ¶
func (hco HealthCnfOptions) Equals(cp HealthCnfOptions) bool
type HealthConfig ¶
type HealthConfig struct {
Cmd string `json:"cmd"`
Options HealthCnfOptions `json:"options"`
}
func (HealthConfig) Equals ¶
func (hc HealthConfig) Equals(cp HealthConfig) bool
type HealthState ¶
type HealthState int
func (HealthState) String ¶
func (hs HealthState) String() string
type ImRuntime ¶
type ImRuntime struct {
BaseRuntime
DriftCount int
RestartCount int
RestartAt time.Time
}
type NamespacePodsWithSpec ¶
type NotifySpec ¶
type NotifySpec struct {
Level string
Namespace string
PodName string
InstanceNo int
Timestamp time.Time
Message string
}
func NewNotifySpec ¶
type OrcEngine ¶
func (*OrcEngine) DeleteConstraints ¶
func (*OrcEngine) DeleteNotify ¶
func (*OrcEngine) GetConstraints ¶
func (engine *OrcEngine) GetConstraints(cstType string) (ConstraintSpec, bool)
func (*OrcEngine) GetDependencyPod ¶
func (engine *OrcEngine) GetDependencyPod(name string) (NamespacePodsWithSpec, error)
func (*OrcEngine) GetNotifies ¶
func (*OrcEngine) GuardGotoSleep ¶
func (*OrcEngine) GuardGotoWork ¶
func (*OrcEngine) HandleEvent ¶
func (engine *OrcEngine) HandleEvent(payload interface{})
func (*OrcEngine) InspectPodGroup ¶
func (engine *OrcEngine) InspectPodGroup(name string) (PodGroupWithSpec, bool)
func (*OrcEngine) ListenerId ¶
func (*OrcEngine) LoadDependsPods ¶
func (*OrcEngine) LoadPodGroups ¶
func (*OrcEngine) NewDependencyPod ¶
func (*OrcEngine) NewPodGroup ¶
func (engine *OrcEngine) NewPodGroup(spec PodGroupSpec) error
func (*OrcEngine) RefreshPodGroup ¶
func (*OrcEngine) RemoveDependencyPod ¶
func (*OrcEngine) RemovePodGroup ¶
func (*OrcEngine) RescheduleInstance ¶
func (engine *OrcEngine) RescheduleInstance(name string, numInstances int, restartPolicy ...RestartPolicy) error
func (*OrcEngine) RescheduleSpec ¶
func (*OrcEngine) UpdateConstraints ¶
func (engine *OrcEngine) UpdateConstraints(spec ConstraintSpec) error
func (*OrcEngine) UpdateDependencyPod ¶
type Pod ¶
func (Pod) ContainerIds ¶
func (Pod) NeedRestart ¶
func (pod Pod) NeedRestart(policy RestartPolicy) bool
func (Pod) RestartEnoughTimes ¶
type PodGroup ¶
type PodGroup struct {
Pods []Pod
BaseRuntime
}
type PodGroupPrevState ¶
type PodGroupPrevState struct {
Nodes []string
// we think a instance only have one ip, as now a instance only have one container.
IPs []string
}
func (PodGroupPrevState) Clone ¶
func (pgps PodGroupPrevState) Clone() PodGroupPrevState
func (PodGroupPrevState) Length ¶
func (pgps PodGroupPrevState) Length() int
func (PodGroupPrevState) Reset ¶
func (pgps PodGroupPrevState) Reset(instanceNo int) PodGroupPrevState
type PodGroupSpec ¶
type PodGroupSpec struct {
ImSpec
Pod PodSpec
NumInstances int
RestartPolicy RestartPolicy
}
func NewPodGroupSpec ¶
func NewPodGroupSpec(name string, namespace string, podSpec PodSpec, numInstances int) PodGroupSpec
func (PodGroupSpec) Clone ¶
func (spec PodGroupSpec) Clone() PodGroupSpec
func (PodGroupSpec) Equals ¶
func (spec PodGroupSpec) Equals(o PodGroupSpec) bool
func (PodGroupSpec) String ¶
func (spec PodGroupSpec) String() string
func (PodGroupSpec) VerifyParams ¶
func (spec PodGroupSpec) VerifyParams() bool
type PodGroupWithSpec ¶
type PodGroupWithSpec struct {
Spec PodGroupSpec
PrevState []PodPrevState
PodGroup
}
type PodPrevState ¶
func NewPodPrevState ¶
func NewPodPrevState(length int) PodPrevState
func (PodPrevState) Clone ¶
func (pps PodPrevState) Clone() PodPrevState
type PodSpec ¶
type PodSpec struct {
ImSpec
Network string
Containers []ContainerSpec
Filters []string // for cluster scheduling
Labels map[string]string
Dependencies []Dependency
Annotation string
Stateful bool
SetupTime int
KillTimeout int
PrevState PodPrevState
HealthConfig HealthConfig
}
func NewPodSpec ¶
func NewPodSpec(containerSpec ContainerSpec, otherSpecs ...ContainerSpec) PodSpec
func (PodSpec) GetKillTimeout ¶
func (PodSpec) GetSetupTime ¶
func (PodSpec) HasVolumes ¶
func (PodSpec) IsHardStateful ¶
func (PodSpec) IsStateful ¶
func (PodSpec) VerifyParams ¶
type PortsManager ¶
type PortsManager struct {
// contains filtered or unexported fields
}
func NewPortsManager ¶
func NewPortsManager(endpoint string) *PortsManager
func (*PortsManager) CancelStreamPort ¶
func (pm *PortsManager) CancelStreamPort(sp *StreamProc) bool
func (PortsManager) CancelStreamPorts ¶
func (pm PortsManager) CancelStreamPorts(spArr ...*StreamProc)
func (PortsManager) FetchAllStreamPortsInfo ¶
func (pm PortsManager) FetchAllStreamPortsInfo() []StreamProc
func (PortsManager) Refresh ¶
func (pm PortsManager) Refresh(pgCtrls map[string]*podGroupController)
func (PortsManager) RegisterStreamPort ¶
func (pm PortsManager) RegisterStreamPort(sp *StreamProc) bool
func (PortsManager) RegisterStreamPorts ¶
func (pm PortsManager) RegisterStreamPorts(spArr ...*StreamProc) (bool, []int)
func (*PortsManager) UpdateStreamPort ¶
func (pm *PortsManager) UpdateStreamPort(sp *StreamProc) bool
func (PortsManager) UpdateStreamPorts ¶
func (pm PortsManager) UpdateStreamPorts(spArr ...*StreamProc)
type Publisher ¶
type Publisher interface {
EmitEvent(payload interface{})
AddListener(subscriber Listener)
RemoveListener(subscriber Listener)
}
func NewPublisher ¶
type Resource ¶
func FetchResource ¶
func FetchResource() *Resource
type RestartPolicy ¶
type RestartPolicy int
func (RestartPolicy) String ¶
func (rp RestartPolicy) String() string
type RuntimeEaglePod ¶
type RuntimeEaglePod struct {
ContainerLabel
Container adoc.Container
ParseSource string
}
func (RuntimeEaglePod) String ¶
func (pod RuntimeEaglePod) String() string
type RuntimeEagleView ¶
func NewRuntimeEagleView ¶
func NewRuntimeEagleView() *RuntimeEagleView
func (*RuntimeEagleView) Activate ¶
func (ev *RuntimeEagleView) Activate(c cluster.Cluster)
func (*RuntimeEagleView) GetRuntimeEaglePods ¶
func (ev *RuntimeEagleView) GetRuntimeEaglePods(name string) ([]RuntimeEaglePod, bool)
func (*RuntimeEagleView) RefreshPodGroup ¶
func (ev *RuntimeEagleView) RefreshPodGroup(c cluster.Cluster, pgName string) ([]RuntimeEaglePod, error)
func (*RuntimeEagleView) RefreshPodsByNamespace ¶
func (ev *RuntimeEagleView) RefreshPodsByNamespace(c cluster.Cluster, namespace string) ([]RuntimeEaglePod, error)
type SharedPodWithSpec ¶
type SharedPodWithSpec struct {
}
type StreamPort ¶
type StreamPort struct {
SrcPort int `json:"srcport"`
DstPort int `json:"dstport"`
Proto string `json:"proto"`
}
func (StreamPort) Equals ¶
func (sp StreamPort) Equals(osp StreamPort) bool
type StreamPorts ¶
type StreamPorts struct {
Ports []StreamPort `json:"ports"`
}
func (StreamPorts) Equals ¶
func (sp StreamPorts) Equals(osp StreamPorts) bool
type StreamProc ¶
type StreamProc struct {
StreamPort
NameSpace string
ProcName string
}
func FetchAllPortsInfo ¶
func FetchAllPortsInfo() []StreamProc
Click to show internal directories.
Click to hide internal directories.