podtask

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Launched = FlagType("launched")
	Bound    = FlagType("bound")
	Deleted  = FlagType("deleted")
)
View Source
const (
	PodPath = "/pods"
)

Variables

This section is empty.

Functions

func InstallDebugHandlers

func InstallDebugHandlers(l sync.Locker, reg Registry)

TODO(jdef) we use a Locker to guard against concurrent task state changes, but it would be really, really nice to avoid doing this. Maybe someday the registry won't return data ptrs but plain structs instead.

func MakePodKey

func MakePodKey(ctx api.Context, id string) (string, error)

makePodKey constructs etcd paths to pod items enforcing namespace rules.

func ParsePodStatusResult

func ParsePodStatusResult(taskStatus *mesos.TaskStatus) (result api.PodStatusResult, err error)

Types

type DuplicateHostPortError

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

func (*DuplicateHostPortError) Error

func (err *DuplicateHostPortError) Error() string

type FlagType

type FlagType string

type HostPortMapping

type HostPortMapping struct {
	ContainerIdx int // index of the container in the pod spec
	PortIdx      int // index of the port in a container's port spec
	OfferPort    uint64
}

type HostPortMappingFunc

type HostPortMappingFunc func(t *T, offer *mesos.Offer) ([]HostPortMapping, error)

abstracts the way that host ports are mapped to pod container ports

type PortAllocationError

type PortAllocationError struct {
	PodId string
	Ports []uint64
}

func (*PortAllocationError) Error

func (err *PortAllocationError) Error() string

type Registry

type Registry interface {
	Register(*T, error) (*T, error)
	Unregister(*T)
	Get(taskId string) (task *T, currentState StateType)
	TaskForPod(podID string) (taskID string, ok bool)
	UpdateStatus(status *mesos.TaskStatus) (*T, StateType)
	// return a list of task ID's that match the given filter, or all task ID's if filter == nil
	List(func(*T) bool) []string
}

func NewInMemoryRegistry

func NewInMemoryRegistry() Registry

type StateType

type StateType int
const (
	StatePending StateType = iota
	StateRunning
	StateFinished
	StateUnknown
)

type T

type T struct {
	ID       string
	Pod      *api.Pod
	TaskInfo *mesos.TaskInfo
	Offer    offers.Perishable
	State    StateType
	Ports    []HostPortMapping
	Flags    map[FlagType]struct{}

	CreateTime  time.Time
	UpdatedTime time.Time // time of the most recent StatusUpdate we've seen from the mesos master
	// contains filtered or unexported fields
}

A struct that describes a pod task.

func New

func New(ctx api.Context, pod *api.Pod, executor *mesos.ExecutorInfo) (*T, error)

func RecoverFrom

func RecoverFrom(pod api.Pod) (*T, bool, error)

reconstruct a task from metadata stashed in a pod entry. there are limited pod states that support reconstruction. if we expect to be able to reconstruct state but encounter errors in the process then those errors are returned. if the pod is in a seemingly valid state but otherwise does not support task reconstruction return false. if we're able to reconstruct state then return a reconstructed task and true.

at this time task reconstruction is only supported for pods that have been annotated with binding metadata, which implies that they've previously been associated with a task and that mesos knows about it.

assumes that the pod data comes from the k8s registry and reflects the desired state.

func (*T) AcceptOffer

func (t *T) AcceptOffer(offer *mesos.Offer) bool

func (*T) ClearTaskInfo

func (t *T) ClearTaskInfo()

Clear offer-related details from the task, should be called if/when an offer has already been assigned to a task but for some reason is no longer valid.

func (*T) FillFromDetails

func (t *T) FillFromDetails(details *mesos.Offer) error

Fill the TaskInfo in the T, should be called during k8s scheduling, before binding.

func (*T) GetOfferId

func (t *T) GetOfferId() string

func (*T) Has

func (t *T) Has(f FlagType) (exists bool)

func (*T) HasAcceptedOffer

func (t *T) HasAcceptedOffer() bool

func (*T) SaveRecoveryInfo

func (t *T) SaveRecoveryInfo(dict map[string]string)

func (*T) Set

func (t *T) Set(f FlagType)

Jump to

Keyboard shortcuts

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