scheduler

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Responsible for creating all resources for a lab. Pods, services, networks, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubeLab

type KubeLab struct {
	Namespace     *corev1.Namespace
	CreateRequest *LessonScheduleRequest // The request that originally resulted in this KubeLab
	Networks      map[string]*crd.NetworkAttachmentDefinition
	Pods          map[string]*corev1.Pod
	Services      map[string]*corev1.Service
	Ingresses     map[string]*v1beta1.Ingress
	Status        pb.Status
	CurrentStage  int32
	HealthyTests  int
	TotalTests    int
}

KubeLab is the collection of kubernetes resources that makes up a lab instance

func (*KubeLab) ToLiveLesson

func (kl *KubeLab) ToLiveLesson() *pb.LiveLesson

ToLiveLesson exports a KubeLab as a generic LiveLesson so the API can use it

func (*KubeLab) ToProtoKubeLab added in v0.3.0

func (kl *KubeLab) ToProtoKubeLab() *pb.KubeLab

ToProtoKubeLab is a converter function that transforms a native KubeLab struct instance into a protobuf-based KubeLab instance. Not all fields can be modeled in protobuf, so this function mostly just uses the name of Kubernetes objects in lieu of the actual object.

type LessonHealthCheck added in v0.3.1

type LessonHealthCheck struct{}

type LessonHealthChecker added in v0.3.1

type LessonHealthChecker interface {
	// contains filtered or unexported methods
}

LessonHealthChecker describes a struct which offers a variety of reachability tests for lesson endpoints.

type LessonScheduleRequest

type LessonScheduleRequest struct {
	Lesson    *pb.Lesson
	Operation OperationType
	Uuid      string
	Stage     int32
	Created   time.Time
}

type LessonScheduleResult

type LessonScheduleResult struct {
	Success          bool
	Stage            int32
	Lesson           *pb.Lesson
	Operation        OperationType
	Message          string
	ProvisioningTime int
	Uuid             string
}

type LessonScheduler

type LessonScheduler struct {
	KubeConfig    *rest.Config
	Requests      chan *LessonScheduleRequest
	Results       chan *LessonScheduleResult
	Curriculum    *pb.Curriculum
	SyringeConfig *config.SyringeConfig
	GcWhiteList   map[string]*pb.Session
	GcWhiteListMu *sync.Mutex
	KubeLabs      map[string]*KubeLab
	KubeLabsMu    *sync.Mutex
	HealthChecker LessonHealthChecker

	// Allows us to disable GC for testing. Production code should leave this at
	// false
	DisableGC bool

	// Client for interacting with normal Kubernetes resources
	Client kubernetes.Interface

	// Client for creating CRD defintions
	ClientExt kubernetesExt.Interface

	// Client for creating instances of our network CRD
	ClientCrd kubernetesCrd.Interface

	BuildInfo map[string]string
}

func (*LessonScheduler) PurgeOldLessons added in v0.3.2

func (ls *LessonScheduler) PurgeOldLessons() ([]string, error)

Lesson garbage-collector

func (*LessonScheduler) Start

func (ls *LessonScheduler) Start() error

Start is meant to be run as a goroutine. The "requests" channel will wait for new requests, attempt to schedule them, and put a results message on the "results" channel when finished (success or fail)

type NetworkCrdClient added in v0.3.1

NetworkCrdClient is an interface for the client for our custom network CRD. Allows for injection of mocks at test time.

type OperationType

type OperationType int32
var (
	OperationType_CREATE OperationType = 1
	OperationType_DELETE OperationType = 2
	OperationType_MODIFY OperationType = 3
	OperationType_BOOP   OperationType = 4
	OperationType_VERIFY OperationType = 5
)

Jump to

Keyboard shortcuts

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