scheduler

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2015 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

copied from k8s: plugin/pkg/scheduler/factory/factory.go

Package framework includes a kubernetes framework. that implements the interfaces of:

1: The mesos scheduler.

2: The kubernetes scheduler.

3: The kubernetes pod registry.

It acts as the 'scheduler' and the 'registry' of the PodRegistryStorage to provide scheduling and Pod management on top of mesos.

Index

Constants

View Source
const PodPath = "/pods"

Variables

This section is empty.

Functions

func NewRanges

func NewRanges(ports []uint64) *mesos.Value_Ranges

func NewRange(begin uint64, end uint64) *mesos.Value_Ranges {

Types

type CloudRegistry

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

implements the minion.Registry interface

func NewCloudRegistry

func NewCloudRegistry(c cloudprovider.Interface) *CloudRegistry

func (*CloudRegistry) CreateMinion added in v0.2.2

func (r *CloudRegistry) CreateMinion(api.Context, *api.Minion) error

func (*CloudRegistry) DeleteMinion added in v0.2.2

func (r *CloudRegistry) DeleteMinion(api.Context, string) error

func (*CloudRegistry) GetMinion added in v0.2.2

func (r *CloudRegistry) GetMinion(ctx api.Context, minionId string) (*api.Minion, error)

func (*CloudRegistry) ListMinions added in v0.2.2

func (r *CloudRegistry) ListMinions(ctx api.Context) (*api.MinionList, error)

func (*CloudRegistry) UpdateMinion added in v0.3.0

func (r *CloudRegistry) UpdateMinion(api.Context, *api.Minion) error

type KubernetesScheduler

type KubernetesScheduler struct {
	// We use a lock here to avoid races
	// between invoking the mesos callback
	// and the invoking the pod registry interfaces.
	*sync.RWMutex

	// easy access to etcd ops
	tools.EtcdHelper
	// contains filtered or unexported fields
}

KubernetesScheduler implements: 1: The interfaces of the mesos scheduler. 2: The interface of a kubernetes scheduler. 3: The interfaces of a kubernetes pod registry.

func New

func New(executor *mesos.ExecutorInfo, scheduleFunc PodScheduleFunc, client *client.Client, helper tools.EtcdHelper) *KubernetesScheduler

New create a new KubernetesScheduler

func (*KubernetesScheduler) Bind

func (k *KubernetesScheduler) Bind(binding *api.Binding) error

implements binding.Registry, launches the pod-associated-task in mesos

func (*KubernetesScheduler) CreatePod

func (k *KubernetesScheduler) CreatePod(ctx api.Context, pod *api.Pod) error

Create a pod based on a specification; DOES NOT schedule it onto a specific machine, instead the pod is queued for scheduling.

func (*KubernetesScheduler) DeletePod

func (k *KubernetesScheduler) DeletePod(ctx api.Context, id string) error

Delete an existing pod.

func (*KubernetesScheduler) Disconnected

func (k *KubernetesScheduler) Disconnected(driver mesos.SchedulerDriver)

Disconnected is called when the scheduler loses connection to the master.

func (*KubernetesScheduler) Error

func (k *KubernetesScheduler) Error(driver mesos.SchedulerDriver, message string)

Error is called when there is some error.

func (*KubernetesScheduler) ExecutorLost

func (k *KubernetesScheduler) ExecutorLost(driver mesos.SchedulerDriver,
	executorId *mesos.ExecutorID, slaveId *mesos.SlaveID, status int)

ExecutorLost is called when some executor is lost.

func (*KubernetesScheduler) FrameworkMessage

func (k *KubernetesScheduler) FrameworkMessage(driver mesos.SchedulerDriver,
	executorId *mesos.ExecutorID, slaveId *mesos.SlaveID, message string)

FrameworkMessage is called when the scheduler receives a message from the executor.

func (*KubernetesScheduler) GetPod

func (k *KubernetesScheduler) GetPod(ctx api.Context, id string) (*api.Pod, error)

Get a specific pod. It's *very* important to return a clone of the Pod that we've saved because our caller will likely modify it.

func (*KubernetesScheduler) Init added in v0.2.1

func (*KubernetesScheduler) ListPods

func (k *KubernetesScheduler) ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error)

ListPods obtains a list of pods that match selector.

func (*KubernetesScheduler) ListPodsPredicate added in v0.2.2

func (k *KubernetesScheduler) ListPodsPredicate(ctx api.Context, filter func(*api.Pod) bool) (*api.PodList, error)

ListPods obtains a list of pods that match selector.

func (*KubernetesScheduler) NewPluginConfig

func (k *KubernetesScheduler) NewPluginConfig() *plugin.Config

Create creates a scheduler and all support functions.

func (*KubernetesScheduler) OfferRescinded

func (k *KubernetesScheduler) OfferRescinded(driver mesos.SchedulerDriver, offerId *mesos.OfferID)

OfferRescinded is called when the resources are recinded from the scheduler.

func (*KubernetesScheduler) Registered

func (k *KubernetesScheduler) Registered(driver mesos.SchedulerDriver,
	frameworkId *mesos.FrameworkID, masterInfo *mesos.MasterInfo)

Registered is called when the scheduler registered with the master successfully.

func (*KubernetesScheduler) Reregistered

func (k *KubernetesScheduler) Reregistered(driver mesos.SchedulerDriver, masterInfo *mesos.MasterInfo)

Reregistered is called when the scheduler re-registered with the master successfully. This happends when the master fails over.

func (*KubernetesScheduler) ResourceOffers

func (k *KubernetesScheduler) ResourceOffers(driver mesos.SchedulerDriver, offers []*mesos.Offer)

ResourceOffers is called when the scheduler receives some offers from the master.

func (*KubernetesScheduler) Schedule

func (k *KubernetesScheduler) Schedule(pod api.Pod, unused algorithm.MinionLister) (string, error)

Schedule implements the Scheduler interface of the Kubernetes. It returns the selectedMachine's name and error (if there's any).

func (*KubernetesScheduler) SlaveLost

func (k *KubernetesScheduler) SlaveLost(driver mesos.SchedulerDriver, slaveId *mesos.SlaveID)

SlaveLost is called when some slave is lost.

func (*KubernetesScheduler) StatusUpdate

func (k *KubernetesScheduler) StatusUpdate(driver mesos.SchedulerDriver, taskStatus *mesos.TaskStatus)

StatusUpdate is called when a status update message is sent to the scheduler.

func (*KubernetesScheduler) UpdatePod

func (k *KubernetesScheduler) UpdatePod(ctx api.Context, pod *api.Pod) error

Update an existing pod.

func (*KubernetesScheduler) WatchPods

func (k *KubernetesScheduler) WatchPods(ctx api.Context, resourceVersion string, filter func(*api.Pod) bool) (watch.Interface, error)

type MesosCloud

type MesosCloud struct {
	*KubernetesScheduler
}

func (*MesosCloud) Clusters added in v0.3.0

func (c *MesosCloud) Clusters() (cloud.Clusters, bool)

implementation of cloud.Interface; Mesos does not provide support for multiple clusters

func (*MesosCloud) GetNodeResources added in v0.2.2

func (c *MesosCloud) GetNodeResources(name string) (*api.NodeResources, error)

implementation of cloud.Instances; always returns nil,nil. GetNodeResources gets the resources for a particular node

func (*MesosCloud) IPAddress

func (c *MesosCloud) IPAddress(name string) (net.IP, error)

implementation of cloud.Instances. IPAddress returns an IP address of the specified instance.

func (*MesosCloud) Instances

func (c *MesosCloud) Instances() (cloud.Instances, bool)

implementation of cloud.Interface; Mesos natively provides minimal cloud-type resources. More robust cloud support requires a combination of Mesos and cloud-specific knowledge, which will likely never be present in this vanilla implementation.

func (*MesosCloud) List

func (c *MesosCloud) List(filter string) ([]string, error)

implementation of cloud.Instances; does not implement any filtering. List lists instances that match 'filter' which is a regular expression which must match the entire instance name (fqdn).

func (*MesosCloud) TCPLoadBalancer

func (c *MesosCloud) TCPLoadBalancer() (cloud.TCPLoadBalancer, bool)

implementation of cloud.Interface; Mesos does not provide any type of native load balancing by default, so this implementation always returns (nil,false).

func (*MesosCloud) Zones

func (c *MesosCloud) Zones() (cloud.Zones, bool)

implementation of cloud.Interface; Mesos does not provide any type of native region or zone awareness, so this implementation always returns (nil,false).

type NoSuchTaskForPod added in v0.3.0

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

func (*NoSuchTaskForPod) Error added in v0.3.0

func (err *NoSuchTaskForPod) Error() string

type OfferFilter added in v0.2.1

type OfferFilter func(*mesos.Offer) bool

type OfferRegistry added in v0.2.1

type OfferRegistry interface {
	// Initialize the instance, spawning necessary housekeeping go routines.
	Init()
	Add([]*mesos.Offer)

	// Listen for arriving offers that are acceptable to the filter, sending
	// a signal on (by closing) the returned channel. A listener will only
	// ever be notified once, if at all.
	Listen(id string, f OfferFilter) <-chan empty

	// invoked when offers are rescinded or expired
	Delete(string)

	Get(offerId string) (PerishableOffer, bool)

	Walk(Walker) error

	// invalidate one or all (when offerId="") offers; offers are not declined,
	// but are simply flagged as expired in the offer history
	Invalidate(offerId string)
}

func CreateOfferRegistry added in v0.2.1

func CreateOfferRegistry(c OfferRegistryConfig) OfferRegistry

type OfferRegistryConfig added in v0.2.1

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

type PerishableOffer added in v0.2.1

type PerishableOffer interface {
	queue.Delayed
	// returns true if this offer has expired
	HasExpired() bool
	// if not yet expired, return mesos offer details; otherwise nil
	Details() *mesos.Offer
	// mark this offer as acquired, returning true if it was previously unacquired. thread-safe.
	Acquire() bool
	// mark this offer as un-acquired. thread-safe.
	Release()
	// contains filtered or unexported methods
}

func FCFSScheduleFunc

func FCFSScheduleFunc(r OfferRegistry, slaves map[string]*Slave, task *PodTask) (PerishableOffer, error)

A FCFS scheduler.

type PodScheduleFunc

type PodScheduleFunc func(r OfferRegistry, slaves map[string]*Slave, task *PodTask) (PerishableOffer, error)

PodScheduleFunc implements how to schedule pods among slaves. We can have different implementation for different scheduling policy.

The Schedule function accepts a group of slaves (each contains offers from that slave) and a single pod, which aligns well with the k8s scheduling algorithm. It returns an offerId that is acceptable for the pod, otherwise nil. The caller is responsible for filling in task state w/ relevant offer details.

See the FIFOScheduleFunc for example.

type PodTask

type PodTask struct {
	ID       string
	Pod      *api.Pod
	TaskInfo *mesos.TaskInfo
	Launched bool
	Offer    PerishableOffer
	// contains filtered or unexported fields
}

A struct that describes a pod task.

func (*PodTask) AcceptOffer

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

func (*PodTask) ClearTaskInfo

func (t *PodTask) 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 (*PodTask) FillTaskInfo

func (t *PodTask) FillTaskInfo(offer PerishableOffer) error

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

func (*PodTask) GetOfferId added in v0.2.1

func (t *PodTask) GetOfferId() string

func (*PodTask) Ports

func (t *PodTask) Ports() []uint64

type Slave

type Slave struct {
	HostName string
	Offers   map[string]empty
}

type Walker added in v0.2.1

type Walker func(offer PerishableOffer) (stop bool, err error)

callback that is invoked during a walk through a series of live offers, returning with stop=true (or err != nil) if the walk should stop permaturely.

Jump to

Keyboard shortcuts

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