Documentation ¶
Overview ¶
Package podtask maps Kubernetes pods to Mesos tasks.
Index ¶
- Constants
- func InstallDebugHandlers(reg Registry, mux *http.ServeMux)
- func MakePodKey(ctx api.Context, id string) (string, error)
- func ParsePodStatusResult(taskStatus *mesos.TaskStatus) (result api.PodStatusResult, err error)
- type AllOrNothingProcurement
- type Config
- type FlagType
- type ProcureState
- type Procurement
- func NewDefaultProcurement(prototype *mesos.ExecutorInfo, eir executorinfo.Registry) Procurement
- func NewExecutorResourceProcurer(rs []*mesos.Resource, registry executorinfo.Registry) Procurement
- func NewNodeProcurement() Procurement
- func NewPodResourcesProcurement() Procurement
- func NewPortsProcurement() Procurement
- type ProcurementFunc
- type Registry
- type Spec
- type StateType
- type T
- func (t *T) BuildTaskInfo() (*mesos.TaskInfo, error)
- func (t *T) Clone() *T
- func (t *T) GetOfferId() string
- func (t *T) Has(f FlagType) (exists bool)
- func (t *T) HasAcceptedOffer() bool
- func (t *T) Reset()
- func (t *T) Roles() (result []string)
- func (t *T) SaveRecoveryInfo(dict map[string]string)
- func (t *T) Set(f FlagType)
Constants ¶
const ( Launched = FlagType("launched") Bound = FlagType("bound") Deleted = FlagType("deleted") )
const (
//TODO(jdef) move this somewhere else
PodPath = "/pods"
)
Variables ¶
This section is empty.
Functions ¶
func InstallDebugHandlers ¶
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 ¶
makePodKey constructs etcd paths to pod items enforcing namespace rules.
func ParsePodStatusResult ¶
func ParsePodStatusResult(taskStatus *mesos.TaskStatus) (result api.PodStatusResult, err error)
Types ¶
type AllOrNothingProcurement ¶ added in v1.2.3
type AllOrNothingProcurement []Procurement
AllOrNothingProcurement provides a convenient wrapper around multiple Procurement objectives: the failure of any Procurement in the set results in Procure failing. see AllOrNothingProcurement.Procure
func (AllOrNothingProcurement) Procure ¶ added in v1.2.3
func (a AllOrNothingProcurement) Procure(t *T, n *api.Node, ps *ProcureState) error
Procure runs each Procurement in the receiver list. The first Procurement func that fails triggers T.Reset() and the error is returned, otherwise returns nil.
type Config ¶ added in v1.2.3
type Config struct { ID string // ID is an optional, unique task ID; auto-generated if not specified DefaultPodRoles []string // DefaultPodRoles lists preferred resource groups, prioritized in order FrameworkRoles []string // FrameworkRoles identify resource groups from which the framework may consume Prototype *mesos.ExecutorInfo // Prototype is required HostPortStrategy hostport.Strategy // HostPortStrategy is used as the port mapping strategy, unless overridden by the pod GenerateTaskDiscoveryEnabled bool // contains filtered or unexported fields }
Config represents elements that are used or required in order to create a pod task that may be scheduled.
type ProcureState ¶ added in v1.2.3
type ProcureState struct {
// contains filtered or unexported fields
}
ProcureState holds the current state of the procurement pipeline. It contains the pod launch specification and the Mesos offer from which resources are being procured.
func NewProcureState ¶ added in v1.2.3
func NewProcureState(offer *mesos.Offer) *ProcureState
NewProcureState returns an ProcureState containing an empty Spec and a deep copy of the given offer.
type Procurement ¶ added in v1.2.3
type Procurement interface {
Procure(*T, *api.Node, *ProcureState) error
}
Procurement is the interface that implements resource procurement.
Procure procurs offered resources for a given pod task T on a given node and stores the procurement result.
Initially the procurement pipe contains an initial empty Spec and the the complete Mesos offer. As the procurement pipeline progresses the specified resources go up as they are being procured while the remaining Mesos offer resources go down until they are depleted.
It returns an error if the procurement failed.
Note that the T struct also includes a Spec field. This differs from the procured Spec which is meant to be filled by a chain of Procure invocations (procurement pipeline).
In contrast T.Spec is meant not to be filled by the procurement chain but rather by a final scheduler instance.
api.Node is an optional (possibly nil) param.
func NewDefaultProcurement ¶ added in v1.2.3
func NewDefaultProcurement(prototype *mesos.ExecutorInfo, eir executorinfo.Registry) Procurement
NewDefaultProcurement returns the default procurement strategy that combines validation and responsible Mesos resource procurement. c and m are resource quantities written into k8s api.Pod.Spec's that don't declare resources (all containers in k8s-mesos require cpu and memory limits).
func NewExecutorResourceProcurer ¶ added in v1.2.3
func NewExecutorResourceProcurer(rs []*mesos.Resource, registry executorinfo.Registry) Procurement
NewExecutorResourceProcurer returns a Procurement procuring executor resources If a given offer has no executor IDs set, the given prototype executor resources are considered for procurement. If a given offer has one executor ID set, only pod resources are being procured. An offer with more than one executor ID implies an invariant violation and the first executor ID is being considered.
func NewNodeProcurement ¶ added in v1.2.3
func NewNodeProcurement() Procurement
NewNodeProcurement returns a Procurement that checks whether the given pod task and offer have valid node informations available and wehther the pod spec node selector matches the pod labels. If the check is successfull the slave ID and assigned slave is set in the given Spec.
func NewPodResourcesProcurement ¶ added in v1.2.3
func NewPodResourcesProcurement() Procurement
NewPodResourcesProcurement converts k8s pod cpu and memory resource requirements into mesos resource allocations.
func NewPortsProcurement ¶ added in v1.2.3
func NewPortsProcurement() Procurement
NewPortsProcurement returns a Procurement procuring ports
type ProcurementFunc ¶ added in v1.2.3
type ProcurementFunc func(*T, *api.Node, *ProcureState) error
The ProcurementFunc type is an adapter to use ordinary functions as Procurement implementations.
func (ProcurementFunc) Procure ¶ added in v1.2.3
func (p ProcurementFunc) Procure(t *T, n *api.Node, ps *ProcureState) error
type Registry ¶
type Registry interface { // register the specified task with this registry, as long as the current error // condition is nil. if no errors occur then return a copy of the registered task. Register(*T) (*T, error) // unregister the specified task from this registry Unregister(*T) // update state for the registered task identified by task.ID, returning a copy of // the updated task, if any. Update(task *T) error // return the task registered for the specified task ID and its current state. // if there is no such task then StateUnknown is returned. Get(taskId string) (task *T, currentState StateType) // return the non-terminal task corresponding to the specified pod ID ForPod(podID string) (task *T, currentState StateType) // update the task status given the specified mesos task status update, returning a // copy of the updated task (if any) and its state. 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(filter func(*T) bool) []*T }
state store for pod tasks
func NewInMemoryRegistry ¶
func NewInMemoryRegistry() Registry
type T ¶
type T struct { Config Pod api.Pod // Stores the final procurement result, once set read-only. // Meant to be set by algorith.SchedulerAlgorithm only. Spec *Spec Offer offers.Perishable // thread-safe State StateType 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 RecoverFrom ¶
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) Clone ¶
mostly-clone this pod task. the clone will actually share the some fields:
- executor // OK because it's read only
- Offer // OK because it's guarantees safe concurrent access
func (*T) GetOfferId ¶
func (*T) HasAcceptedOffer ¶
func (*T) Reset ¶
func (t *T) Reset()
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) Roles ¶ added in v1.2.3
Roles returns the valid roles under which this pod task can be scheduled. If the pod has roles annotations defined they are being used else default pod roles are being returned.