controller

package
v0.0.0-...-c951766 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTestTTL   = 2 * time.Hour
	DefaultTestAge   = 1 * time.Hour
	OldTestAge       = 3 * time.Hour
	TestTolerance    = 1 * time.Minute
	DefaultTestVCPUs = 1
	DefaultTestRAM   = 2048
	DefaultTestDisk  = 10
)

Test constants to reduce magic numbers

View Source
const (
	DefaultTTLAfterDecisionSeconds = 24 * 60 * 60 // 24 hours in seconds
)
View Source
const (
	MinScoreValue = -999999
)

Variables

This section is empty.

Functions

func AssertDecisionCount

func AssertDecisionCount(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedCount int)

AssertDecisionCount checks the decision count in a SchedulingDecision

func AssertDeletedHosts

func AssertDeletedHosts(t *testing.T, result decisionsv1alpha1.SchedulingDecisionResult, expectedDeletedHosts map[string][]string)

AssertDeletedHosts checks the deleted hosts in a result

func AssertDescriptionContains

func AssertDescriptionContains(t *testing.T, description string, expectedContents ...string)

AssertDescriptionContains checks that a description contains expected text

func AssertFinalScores

func AssertFinalScores(t *testing.T, result decisionsv1alpha1.SchedulingDecisionResult, expectedScores map[string]float64)

AssertFinalScores checks the final scores in a result

func AssertNoError

func AssertNoError(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision)

AssertNoError checks that there's no error in the resource status

func AssertResourceDeleted

func AssertResourceDeleted(t *testing.T, c client.Client, name string, namespace ...string)

AssertResourceDeleted checks that a resource has been deleted

func AssertResourceError

func AssertResourceError(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedError string)

AssertResourceError checks the error message of a SchedulingDecision

func AssertResourceExists

func AssertResourceExists(t *testing.T, c client.Client, name string, namespace ...string) *decisionsv1alpha1.SchedulingDecision

AssertResourceExists checks that a resource exists and returns it

func AssertResourceState

func AssertResourceState(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedState decisionsv1alpha1.SchedulingDecisionState)

AssertResourceState checks the state of a SchedulingDecision

func AssertResultCount

func AssertResultCount(t *testing.T, resource *decisionsv1alpha1.SchedulingDecision, expectedCount int)

AssertResultCount checks the number of results in a SchedulingDecision

func CreateTestRequest

func CreateTestRequest(name string, namespace ...string) ctrl.Request

CreateTestRequest creates a controller request for testing

func NewTestPipelineOutput

func NewTestPipelineOutput(step string, activations map[string]float64) decisionsv1alpha1.SchedulingDecisionPipelineOutputSpec

NewTestPipelineOutput creates a pipeline output spec for testing

func SetupTestEnvironment

func SetupTestEnvironment(t *testing.T, resources ...client.Object) (client.Client, *runtime.Scheme)

SetupTestEnvironment creates a fake client and scheme for testing

Types

type Config

type Config struct {
	// TTL for scheduling decisions after the last decision's RequestedAt timestamp (in seconds)
	TTLAfterDecisionSeconds int `json:"ttlAfterDecisionSeconds,omitempty"`
}

Configuration for the decisions operator.

type SchedulingDecisionReconciler

type SchedulingDecisionReconciler struct {
	// Client for the kubernetes API.
	client.Client
	// Kubernetes scheme to use for the decisions.
	Scheme *runtime.Scheme
	// Configuration for the controller.
	Conf Config
}

SchedulingDecisionReconciler reconciles a SchedulingDecision object

func CreateSchedulingReconciler

func CreateSchedulingReconciler(fakeClient client.Client, conf ...Config) *SchedulingDecisionReconciler

CreateSchedulingReconciler creates a scheduling decision reconciler If conf is empty, uses default empty config

func (*SchedulingDecisionReconciler) Reconcile

func (*SchedulingDecisionReconciler) SetupWithManager

func (r *SchedulingDecisionReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type SchedulingDecisionTTLController

type SchedulingDecisionTTLController struct {
	// Client for the kubernetes API.
	client.Client
	// Kubernetes scheme to use for the decisions.
	Scheme *runtime.Scheme
	// Configuration for the TTL controller.
	Conf Config
}

SchedulingDecisionTTLController handles automatic cleanup of resolved SchedulingDecision resources after a configurable TTL period.

func CreateTTLReconciler

func CreateTTLReconciler(fakeClient client.Client, scheme *runtime.Scheme, ttl time.Duration) *SchedulingDecisionTTLController

CreateTTLReconciler creates a TTL reconciler with the given TTL duration If ttlSeconds is 0, the reconciler will use its internal default

func (*SchedulingDecisionTTLController) Reconcile

func (*SchedulingDecisionTTLController) SetupWithManager

func (r *SchedulingDecisionTTLController) SetupWithManager(mgr ctrl.Manager) error

type StepImpact

type StepImpact struct {
	Step               string
	ScoreBefore        float64
	ScoreAfter         float64
	ScoreDelta         float64
	CompetitorsRemoved int
	PromotedToFirst    bool
}

StepImpact represents the impact of a single pipeline step on the winning host

type TTLStartupReconciler

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

TTLStartupReconciler handles startup reconciliation for existing resources

func (*TTLStartupReconciler) Start

func (s *TTLStartupReconciler) Start(ctx context.Context) error

Start implements the Runnable interface and runs startup reconciliation

type TestDecisionBuilder

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

TestDecisionBuilder helps build SchedulingDecisionRequest objects for tests

func NewTestDecision

func NewTestDecision(id string) *TestDecisionBuilder

func (*TestDecisionBuilder) Build

Build returns the built SchedulingDecisionRequest

func (*TestDecisionBuilder) WithEventType

WithEventType sets the event type

func (*TestDecisionBuilder) WithInput

func (b *TestDecisionBuilder) WithInput(input map[string]float64) *TestDecisionBuilder

WithInput sets the input hosts and scores

func (*TestDecisionBuilder) WithPipelineOutputs

WithPipelineOutputs sets the pipeline outputs

func (*TestDecisionBuilder) WithRequestedAt

func (b *TestDecisionBuilder) WithRequestedAt(t time.Time) *TestDecisionBuilder

WithRequestedAt sets the RequestedAt timestamp

type TestSchedulingDecisionBuilder

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

TestSchedulingDecisionBuilder helps build SchedulingDecision objects for tests

func NewTestSchedulingDecision

func NewTestSchedulingDecision(name string) *TestSchedulingDecisionBuilder

NewTestSchedulingDecision creates a new test SchedulingDecision builder

func (*TestSchedulingDecisionBuilder) Build

Build returns the built SchedulingDecision

func (*TestSchedulingDecisionBuilder) WithCreationTimestamp

WithCreationTimestamp sets the creation timestamp

func (*TestSchedulingDecisionBuilder) WithDecisions

WithDecisions adds decisions to the SchedulingDecision

func (*TestSchedulingDecisionBuilder) WithNamespace

WithNamespace sets the namespace

Jump to

Keyboard shortcuts

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