explanation

package
v0.0.0-...-07bbd18 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainData

type ChainData struct {
	Segments []ChainSegment `json:"segments"`
	HasLoop  bool           `json:"hasLoop"`
}

ChainData contains information about the decision chain over time.

type ChainSegment

type ChainSegment struct {
	Host     string        `json:"host"`
	Duration time.Duration `json:"duration"`
	// number of decisions with this as the target host
	Decisions int `json:"decisions"`
}

ChainSegment represents a period where the resource was on a specific host.

type ContextData

type ContextData struct {
	ResourceType   string `json:"resourceType"`
	DecisionNumber int    `json:"decisionNumber"`
	IsInitial      bool   `json:"isInitial"`
}

type Controller

type Controller struct {
	// The kubernetes client to use for processing decisions.
	client.Client
	// The controller will scope to objects using this operator name.
	// This allows multiple operators to coexist in the same cluster without
	// interfering with each other's decisions.
	OperatorName string
	// If the field indexing should be skipped (useful for testing).
	SkipIndexFields bool
}

The explanation controller populates two fields of the decision status.

First, it reconstructs the history of each decision. It will look for previous decisions for the same resource (based on ResourceID) and provide them through the decision history field.

Second, it will use the available context for a decision to generate a human-readable explanation of why the decision was made the way it was. This explanation is intended to help operators understand the reasoning behind scheduling decisions.

func (*Controller) Reconcile

func (c *Controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

This loop will be called by the controller-runtime for each decision resource that needs to be reconciled.

func (*Controller) SetupWithManager

func (c *Controller) SetupWithManager(mgr manager.Manager) error

This function sets up the controller with the provided manager.

func (*Controller) StartupCallback

func (c *Controller) StartupCallback(ctx context.Context) error

This function will be called when the manager starts up. Must block.

type CriticalStepsData

type CriticalStepsData struct {
	Steps       []string `json:"steps"`
	TotalSteps  int      `json:"totalSteps"`
	IsInputOnly bool     `json:"isInputOnly"`
	RequiresAll bool     `json:"requiresAll"`
}

CriticalStepsData contains information about which pipeline steps were critical.

type DeletedHostInfo

type DeletedHostInfo struct {
	Name          string   `json:"name"`
	Steps         []string `json:"steps"`
	IsInputWinner bool     `json:"isInputWinner"`
}

DeletedHostInfo contains details about a single deleted host.

type DeletedHostsData

type DeletedHostsData struct {
	DeletedHosts []DeletedHostInfo `json:"deletedHosts"`
}

DeletedHostsData contains information about hosts that were filtered out.

type Explainer

type Explainer struct {
	// The kubernetes client to use for fetching related data.
	client.Client
	// contains filtered or unexported fields
}

The explainer gets a scheduling decision and produces a human-readable explanation of why the decision was made the way it was.

func NewExplainer

func NewExplainer(client client.Client) (*Explainer, error)

NewExplainer creates a new explainer with template support.

func (*Explainer) Explain

func (e *Explainer) Explain(ctx context.Context, decision *v1alpha1.Decision) (string, error)

Explain the given decision and return a human-readable explanation.

func (*Explainer) ExplainWithTemplates

func (e *Explainer) ExplainWithTemplates(ctx context.Context, decision *v1alpha1.Decision) (string, error)

ExplainWithTemplates renders an explanation using Go templates.

type ExplanationContext

type ExplanationContext struct {
	Context       ContextData        `json:"context"`
	History       *HistoryData       `json:"history,omitempty"`
	Winner        *WinnerData        `json:"winner,omitempty"`
	Input         *InputData         `json:"input,omitempty"`
	CriticalSteps *CriticalStepsData `json:"criticalSteps,omitempty"`
	DeletedHosts  *DeletedHostsData  `json:"deletedHosts,omitempty"`
	StepImpacts   []StepImpact       `json:"stepImpacts,omitempty"`
	Chain         *ChainData         `json:"chain,omitempty"`
}

ExplanationContext holds all data needed to render a complete explanation.

type HistoryData

type HistoryData struct {
	PreviousTarget string `json:"previousTarget"`
	CurrentTarget  string `json:"currentTarget"`
}

HistoryData contains information about the previous decision in the chain.

type HostSegment

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

HostSegment represents a segment in the host chain with duration and decision count.

type InputData

type InputData struct {
	InputWinner     string  `json:"inputWinner"`
	InputScore      float64 `json:"inputScore"`
	FinalWinner     string  `json:"finalWinner"`
	FinalScore      float64 `json:"finalScore"`
	FinalInputScore float64 `json:"finalInputScore"` // Final winner's input score
	InputConfirmed  bool    `json:"inputConfirmed"`
}

InputData contains information about input vs final winner comparison.

type ScoreCalculationResult

type ScoreCalculationResult struct {
	FinalScores  map[string]float64
	DeletedHosts map[string][]string // host -> list of steps that deleted it
}

ScoreCalculationResult holds both final scores and deleted host tracking information.

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 TemplateManager

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

func NewTemplateManager

func NewTemplateManager() (*TemplateManager, error)

func (*TemplateManager) RenderExplanation

func (tm *TemplateManager) RenderExplanation(ctx ExplanationContext) (string, error)

type WinnerData

type WinnerData struct {
	HostName       string  `json:"hostName"`
	Score          float64 `json:"score"`
	Gap            float64 `json:"gap"`
	HostsEvaluated int     `json:"hostsEvaluated"`
	HasGap         bool    `json:"hasGap"`
}

Jump to

Keyboard shortcuts

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