controller

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const MongoURIForTesting string = "mongodb://foo:123"

MongoURIForTesting enables test cases.

Variables

View Source
var Client httpClient

Client represents a http client.

Functions

func MockResponse

func MockResponse(messageBody string, statusCode int)

MockResponse sets up the mock function.

func PodSetAvailability

func PodSetAvailability(pods map[string]common.PodState) float64

PodSetAvailability calculates the availability for a set of PODs.

Types

type IntentController

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

IntentController defines the overall intent controller.

func NewController

func NewController(cfg common.Config, clientSet *kubernetes.Clientset, informer v1.PodInformer) *IntentController

NewController initializes a new IntentController.

func (*IntentController) Run

func (c *IntentController) Run(nWorkers int, stopper <-chan struct{})

Run the overall IntentController logic.

func (*IntentController) SetPlanner

func (c *IntentController) SetPlanner(planner planner.Planner)

SetPlanner sets planner used by all workers. This function is thread-safe, it blocks until the planner is set. All jobs run before SetPlanner call will finish their computations using previous planner.

func (*IntentController) UpdateIntent

func (c *IntentController) UpdateIntent() chan<- common.Intent

UpdateIntent channel function used by the intent monitor so send updates.

func (*IntentController) UpdatePodError

func (c *IntentController) UpdatePodError() chan<- common.PodError

UpdatePodError channel function used by the pod monitor to send updates.

func (*IntentController) UpdateProfile

func (c *IntentController) UpdateProfile() chan<- common.Profile

UpdateProfile channel function used by the profile monitor to send updates.

type IntentMonitor

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

IntentMonitor is the part implementing the monitoring of Intents.

func NewIntentMonitor

func NewIntentMonitor(intentClient clientSet.Interface, intentInformer informers.IntentInformer, ch chan<- common.Intent) *IntentMonitor

NewIntentMonitor returns a new monitor instance.

func (*IntentMonitor) Run

func (mon *IntentMonitor) Run(nWorkers int, stopper <-chan struct{})

Run the basic monitor.

type KPIProfileMonitor

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

KPIProfileMonitor is the part implementing the monitoring the KPIProfiles.

func NewKPIProfileMonitor

func NewKPIProfileMonitor(cfg common.MonitorConfig, profileClient clientSet.Interface, profileInformer informers.KPIProfileInformer, ch chan<- common.Profile) *KPIProfileMonitor

NewKPIProfileMonitor returns a new monitor instance.

func (*KPIProfileMonitor) Run

func (mon *KPIProfileMonitor) Run(nWorkers int, stopper <-chan struct{})

Run the basic monitors.

type MockClient

type MockClient struct{}

MockClient enables us to mock the http requests.

func (*MockClient) Do

func (m *MockClient) Do(req *http.Request) (*http.Response, error)

Do represent the mock the http request.

type MongoTracer

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

MongoTracer wraps around a MongoDB client.

func NewMongoTracer

func NewMongoTracer(mongoURI string) *MongoTracer

NewMongoTracer initializes a new tracer.

func (MongoTracer) GetEffect

func (t MongoTracer) GetEffect(name string, group string, profileName string, lookBackMinutes int, createType func() interface{}) (interface{}, error)

func (MongoTracer) TraceEvent

func (t MongoTracer) TraceEvent(current common.State, desired common.State, plan []planner.Action)

type PodMonitor

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

PodMonitor struct.

func NewPodMonitor

func NewPodMonitor(podClient kubernetes.Interface, informer coreInformer.PodInformer, ch chan<- common.PodError) *PodMonitor

NewPodMonitor initialize a new monitor for PODs - the foundation of a lot of what is going on in K8s/K3s.

func (*PodMonitor) Run

func (mon *PodMonitor) Run(nWorkers int, stopper <-chan struct{})

Run the basic monitors. Note that it is crucial to have enough workers, so you do not miss any errors as they are stuck in the queue.

type Tracer

type Tracer interface {
	// TraceEvent adds an event to the e.g. a database.
	TraceEvent(current common.State, desired common.State, plan []planner.Action)
	// GetEffect returns the data describing the effect of an action.
	GetEffect(name string, group string, profileName string, lookBackMinutes int, constructor func() interface{}) (interface{}, error)
}

Tracer allows us to trace events & hence keep a record of what the planner did.

Jump to

Keyboard shortcuts

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