task

package
v0.24.80 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: GPL-3.0 Imports: 51 Imported by: 0

Documentation

Overview

Package task defines the Task type and its Manager, with the purpose of handling the lifetime of O² Task objects. Each Task generally matches a running Mesos Task. All Tasks are kept in a roster in Manager, and the latter also takes care of resource acquisition and deployment.

Index

Constants

View Source
const (
	CONFIGURE = Event("CONFIGURE")
	RESET     = Event("RESET")
	START     = Event("START")
	STOP      = Event("STOP")
	EXIT      = Event("EXIT")
	GO_ERROR  = Event("GO_ERROR")
	RECOVER   = Event("RECOVER")
)
View Source
const (
	TARGET_SEPARATOR_RUNE = ':'
	TARGET_SEPARATOR      = ":"
)
View Source
const (
	UNDEFINED = iota
	INACTIVE
	PARTIAL
	ACTIVE
)
View Source
const TaskMan_QUEUE = 1024

Variables

View Source
var (
	RegistrationMinBackoff = 1 * time.Second
	RegistrationMaxBackoff = 15 * time.Second
)

Functions

func NewScheduler added in v0.17.80

func NewScheduler(taskman *Manager, fidStore store.Singleton, shutdown func()) (*schedulerState, error)

Types

type AgentCache

type AgentCache struct {
	// contains filtered or unexported fields
}

func (*AgentCache) Count

func (ac *AgentCache) Count() (count int)

func (*AgentCache) Get

func (ac *AgentCache) Get(id mesos.AgentID) (agent *AgentCacheInfo)

func (*AgentCache) Update

func (ac *AgentCache) Update(agents ...AgentCacheInfo)

type AgentCacheInfo

type AgentCacheInfo struct {
	AgentId    mesos.AgentID
	Attributes constraint.Attributes
	Hostname   string
}

type Class added in v0.12.90

type Class struct {
	Identifier TaskClassIdentifier `yaml:"name"`
	Defaults   gera.StringMap      `yaml:"defaults"`
	Control    struct {
		Mode controlmode.ControlMode `yaml:"mode"`
	} `yaml:"control"`
	Command     *common.CommandInfo     `yaml:"command"`
	Wants       ResourceWants           `yaml:"wants"`
	Bind        []channel.Inbound       `yaml:"bind"`
	Properties  gera.StringMap          `yaml:"properties"`
	Constraints []constraint.Constraint `yaml:"constraints"`
	Connect     []channel.Outbound      `yaml:"connect"`
}

↓ We need the roles tree to know *where* to run it and how to *configure* it, but

the following information is enough to run the task even with no environment or
role Class.

func (*Class) Equals added in v0.12.90

func (c *Class) Equals(other *Class) (response bool)

func (*Class) MarshalYAML added in v0.17.0

func (c *Class) MarshalYAML() (interface{}, error)

func (*Class) UnmarshalYAML added in v0.12.90

func (c *Class) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type DeploymentMap

type DeploymentMap map[*Task]*Descriptor

type Descriptor

type Descriptor struct {
	TaskRole        parentRole
	TaskClassName   string
	RoleConstraints constraint.Constraints
	RoleConnect     []channel.Outbound
	RoleBind        []channel.Inbound
}

type Descriptors

type Descriptors []*Descriptor

type Event

type Event string

func (Event) String

func (e Event) String() string

type EventArgs

type EventArgs map[string]string

type Filter

type Filter func(*Task) bool
var Filter_NIL Filter = func(*Task) bool {
	return true
}

type GenericTaskError

type GenericTaskError struct {
	// contains filtered or unexported fields
}

func (GenericTaskError) Error

func (r GenericTaskError) Error() string

func (GenericTaskError) GetTaskId

func (r GenericTaskError) GetTaskId() string

type GenericTasksError

type GenericTasksError struct {
	// contains filtered or unexported fields
}

func (GenericTasksError) Error

func (r GenericTasksError) Error() string

func (GenericTasksError) GetTaskIds

func (r GenericTasksError) GetTaskIds() []string

type KillTaskFunc added in v0.9.0

type KillTaskFunc func(*Task) error

type Manager

type Manager struct {
	AgentCache     AgentCache
	MessageChannel chan *TaskmanMessage
	// contains filtered or unexported fields
}

func NewManager

func NewManager(shutdown func(),
	internalEventCh chan<- event.Event) (taskman *Manager, err error)

func (*Manager) BuildDescriptorConstraints

func (m *Manager) BuildDescriptorConstraints(descriptors Descriptors) (cm map[*Descriptor]constraint.Constraints)

func (*Manager) Cleanup

func (m *Manager) Cleanup() (killed Tasks, running Tasks, err error)

Kill all tasks outside an environment (all unlocked tasks)

func (*Manager) EmergencyKillTasks added in v0.17.80

func (m *Manager) EmergencyKillTasks(tasks Tasks)

This function should only be called from the SIGINT/SIGTERM handler

func (*Manager) GetFrameworkID added in v0.17.80

func (m *Manager) GetFrameworkID() string

func (*Manager) GetState added in v0.17.80

func (m *Manager) GetState() string

func (*Manager) GetTask

func (m *Manager) GetTask(id string) *Task

func (*Manager) GetTaskClass

func (m *Manager) GetTaskClass(name string) (b *Class)

func (*Manager) GetTasks

func (m *Manager) GetTasks() Tasks

func (*Manager) GetWantsForDescriptor

func (m *Manager) GetWantsForDescriptor(descriptor *Descriptor) (r *Wants)

func (*Manager) KillTasks

func (m *Manager) KillTasks(taskIds []string) (killed Tasks, running Tasks, err error)

Kill a specific list of tasks. If the task list includes locked tasks, TaskNotFoundError is returned.

func (*Manager) RefreshClasses

func (m *Manager) RefreshClasses(taskClassesRequired []string) (err error)

func (*Manager) RemoveReposClasses added in v0.10.0

func (m *Manager) RemoveReposClasses(repoPath string)

func (*Manager) Start added in v0.17.80

func (m *Manager) Start(ctx context.Context)

func (*Manager) TaskCount

func (m *Manager) TaskCount() int

func (*Manager) TriggerHooks added in v0.16.0

func (m *Manager) TriggerHooks(tasks Tasks) error

type Range

type Range struct {
	Begin uint64 `json:"begin" yaml:"begin"`
	End   uint64 `json:"end"   yaml:"end"`
}

type Ranges

type Ranges []Range

func (Ranges) Equals

func (this Ranges) Equals(other Ranges) (response bool)

type ResourceWants

type ResourceWants struct {
	Cpu    *float64 `yaml:"cpu"`
	Memory *float64 `yaml:"memory"`
	Ports  Ranges   `yaml:"ports,omitempty"`
}

func (*ResourceWants) UnmarshalYAML

func (rw *ResourceWants) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type Resources

type Resources mesos.Resources

func (Resources) Satisfy

func (r Resources) Satisfy(wants *Wants) bool

type State

type State int
const (
	UNKNOWN State = iota
	STANDBY
	CONFIGURED
	RUNNING
	ERROR
	DONE
	MIXED
	INVARIANT
)

func StateFromString

func StateFromString(s string) State

func (State) String

func (s State) String() string

func (State) X

func (s State) X(other State) State

type StateError added in v0.17.80

type StateError string

StateError is returned when the system encounters an unresolvable state transition error and should likely exit.

func (StateError) Error added in v0.17.80

func (err StateError) Error() string

type Status

type Status uint8

func (Status) String

func (s Status) String() string

func (Status) X

func (s Status) X(other Status) Status

type Task

type Task struct {
	GetTaskClass func() *Class
	// contains filtered or unexported fields
}

func ClassToTask added in v0.17.0

func ClassToTask(input *Class, parent parentRole) *Task

func (*Task) BuildPropertyMap

func (t *Task) BuildPropertyMap(bindMap channel.BindMap) (propMap controlcommands.PropertyMap, err error)

func (*Task) BuildTaskCommand

func (t *Task) BuildTaskCommand(role parentRole) (err error)

Returns a consolidated CommandInfo for this Task, based on Roles tree and Class.

func (*Task) GetAgentId

func (t *Task) GetAgentId() string

func (*Task) GetClassName

func (t *Task) GetClassName() string

func (*Task) GetControlMode added in v0.16.0

func (t *Task) GetControlMode() controlmode.ControlMode

func (*Task) GetEnvironmentId

func (t *Task) GetEnvironmentId() uid.ID

func (*Task) GetExecutorId

func (t *Task) GetExecutorId() string

func (*Task) GetHostname

func (t *Task) GetHostname() string

func (*Task) GetLocalBindMap added in v0.13.0

func (t *Task) GetLocalBindMap() channel.BindMap

func (*Task) GetMesosCommandTarget

func (t *Task) GetMesosCommandTarget() controlcommands.MesosCommandTarget

func (*Task) GetName

func (t *Task) GetName() string

func (*Task) GetOfferId

func (t *Task) GetOfferId() string

func (*Task) GetParent added in v0.17.80

func (t *Task) GetParent() parentRole

func (*Task) GetParentRole

func (t *Task) GetParentRole() interface{}

func (*Task) GetParentRolePath

func (t *Task) GetParentRolePath() string

func (*Task) GetProperties added in v0.12.90

func (t *Task) GetProperties() map[string]string

func (*Task) GetTask added in v0.17.80

func (t *Task) GetTask() *Task

func (*Task) GetTaskCommandInfo added in v0.12.90

func (t *Task) GetTaskCommandInfo() *common.TaskCommandInfo

func (*Task) GetTaskId

func (t *Task) GetTaskId() string

func (*Task) GetTaskPID added in v0.14.91

func (t *Task) GetTaskPID() string

func (*Task) GetTraits added in v0.16.0

func (t *Task) GetTraits() Traits

func (*Task) GetWantsCPU

func (t *Task) GetWantsCPU() float64

func (*Task) GetWantsMemory

func (t *Task) GetWantsMemory() float64

func (*Task) GetWantsPorts

func (t *Task) GetWantsPorts() Ranges

func (*Task) IsLocked

func (t *Task) IsLocked() bool

func (*Task) IsSafeToStop added in v0.12.0

func (t *Task) IsSafeToStop() bool

func (*Task) SendEvent added in v0.19.80

func (t *Task) SendEvent(ev event.Event)

func (*Task) SetParent added in v0.17.80

func (t *Task) SetParent(parent parentRole)

func (*Task) SetSafeToStop added in v0.12.0

func (t *Task) SetSafeToStop(done bool)

type TaskAlreadyReleasedError

type TaskAlreadyReleasedError taskErrorBase

func (TaskAlreadyReleasedError) Error

func (r TaskAlreadyReleasedError) Error() string

type TaskClassIdentifier added in v0.17.0

type TaskClassIdentifier struct {
	Name string
	// contains filtered or unexported fields
}

func (TaskClassIdentifier) String added in v0.17.0

func (tcID TaskClassIdentifier) String() string

func (*TaskClassIdentifier) UnmarshalYAML added in v0.17.0

func (tcID *TaskClassIdentifier) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type TaskError

type TaskError interface {
	error
	GetTaskId() string
}

type TaskLockedError

type TaskLockedError struct {
	// contains filtered or unexported fields
}

func (TaskLockedError) EnvironmentId

func (r TaskLockedError) EnvironmentId() uid.ID

func (TaskLockedError) Error

func (r TaskLockedError) Error() string

func (TaskLockedError) GetTaskId

func (r TaskLockedError) GetTaskId() string

type TaskNotFoundError

type TaskNotFoundError taskErrorBase

func (TaskNotFoundError) Error

func (r TaskNotFoundError) Error() string

type TaskmanMessage added in v0.17.80

type TaskmanMessage struct {
	MessageType taskop.MessageType `json:"_messageType"`
	// contains filtered or unexported fields
}

func NewEnvironmentMessage added in v0.17.80

func NewEnvironmentMessage(mt taskop.MessageType, envId uid.ID, tasks Tasks, desc Descriptors) (t *TaskmanMessage)

func NewTaskStateMessage added in v0.17.80

func NewTaskStateMessage(taskid, state string) (t *TaskmanMessage)

func NewTaskStatusMessage added in v0.17.80

func NewTaskStatusMessage(mesosStatus mesos.TaskStatus) (t *TaskmanMessage)

func NewTransitionTaskMessage added in v0.17.80

func NewTransitionTaskMessage(tasks Tasks, src, transitionEvent, dest string, cargs controlcommands.PropertyMap, envID uid.ID) (t *TaskmanMessage)

func (*TaskmanMessage) GetArguments added in v0.17.80

func (trm *TaskmanMessage) GetArguments() controlcommands.PropertyMap

func (*TaskmanMessage) GetDescriptors added in v0.17.80

func (em *TaskmanMessage) GetDescriptors() Descriptors

func (*TaskmanMessage) GetDestination added in v0.17.80

func (trm *TaskmanMessage) GetDestination() string

func (*TaskmanMessage) GetEnvironmentId added in v0.17.80

func (em *TaskmanMessage) GetEnvironmentId() (envid uid.ID)

func (*TaskmanMessage) GetError added in v0.19.80

func (em *TaskmanMessage) GetError() string

func (*TaskmanMessage) GetEvent added in v0.17.80

func (trm *TaskmanMessage) GetEvent() string

func (*TaskmanMessage) GetMessageType added in v0.17.80

func (tm *TaskmanMessage) GetMessageType() taskop.MessageType

func (*TaskmanMessage) GetRunNumber added in v0.19.80

func (em *TaskmanMessage) GetRunNumber() string

func (*TaskmanMessage) GetSource added in v0.17.80

func (trm *TaskmanMessage) GetSource() string

func (*TaskmanMessage) GetTasks added in v0.17.80

func (em *TaskmanMessage) GetTasks() Tasks

type Tasks

type Tasks []*Task

func (Tasks) BuildPropertyMaps

func (m Tasks) BuildPropertyMaps(bindMap channel.BindMap) (propMapMap controlcommands.PropertyMapsMap, err error)

func (Tasks) Contains

func (m Tasks) Contains(filter Filter) (has bool)

func (Tasks) Filtered

func (m Tasks) Filtered(filter Filter) (tasks Tasks)

func (Tasks) FilteredForClass

func (m Tasks) FilteredForClass(className string) (tasks Tasks)

func (Tasks) GetByTaskId

func (m Tasks) GetByTaskId(id string) *Task

func (Tasks) GetMesosCommandTargets

func (m Tasks) GetMesosCommandTargets() (receivers []controlcommands.MesosCommandTarget, err error)

func (Tasks) GetTaskIds added in v0.9.1

func (m Tasks) GetTaskIds() []string

type TasksDeploymentError

type TasksDeploymentError tasksErrorBase

func (TasksDeploymentError) Error

func (r TasksDeploymentError) Error() string

type TasksError

type TasksError interface {
	error
	GetTaskIds() []string
}

type Traits added in v0.16.0

type Traits struct {
	Trigger  string
	Await    string
	Timeout  string
	Critical bool
}

type Transition

type Transition struct {
	Evt  Event
	Src  State
	Dst  State
	Args EventArgs
}

type Wants

type Wants struct {
	Cpu             float64
	Memory          float64
	StaticPorts     Ranges
	InboundChannels []channel.Inbound
}

Directories

Path Synopsis
Package constraint implements support for predicates on agent attributes.
Package constraint implements support for predicates on agent attributes.

Jump to

Keyboard shortcuts

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