aimservice

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPVCHeadroomPercent is the default headroom percentage for PVC sizing
	DefaultPVCHeadroomPercent = 10
)
View Source
const (
	// MaxRoutePathLength is the maximum allowed length for a route path.
	// This prevents excessively long paths that could cause issues with gateways or proxies.
	MaxRoutePathLength = 200
)

Variables

View Source
var ErrMultipleModelsFound = errors.New("multiple models found with the same image")

ErrMultipleModelsFound is returned when multiple models exist with the same image URI

Functions

func DefaultRoutePath

func DefaultRoutePath(service *aimv1alpha1.AIMService) string

DefaultRoutePath returns the default HTTP route prefix.

func FindMatchingCustomModel

func FindMatchingCustomModel(
	ctx context.Context,
	c client.Client,
	namespace string,
	custom *aimv1alpha1.AIMServiceModelCustom,
) (*aimv1alpha1.AIMModel, error)

FindMatchingCustomModel searches for an existing AIMModel that matches the custom model spec. Matching is based on: - spec.image == custom.baseImage - spec.modelSources match (including env vars for S3 endpoint differentiation)

Only namespace-scoped models are searched since custom models from AIMService are always namespace-scoped.

Returns nil if no matching model is found.

func GenerateCustomModelName

func GenerateCustomModelName(custom *aimv1alpha1.AIMServiceModelCustom) string

GenerateCustomModelName generates a unique name for a custom model. Uses the existing utils.GenerateDerivedName to ensure consistent naming with proper sanitization and hash suffix. Format: {modelId-sanitized}-{hash}

func GenerateHTTPRouteName

func GenerateHTTPRouteName(serviceName, namespace string) (string, error)

GenerateHTTPRouteName creates a deterministic name for the HTTPRoute.

func GenerateInferenceServiceName

func GenerateInferenceServiceName(serviceName, namespace string) (string, error)

GenerateInferenceServiceName creates a deterministic name for the InferenceService. KServe creates hostnames in format {isvc-name}-predictor-{namespace}, which must be ≤ 63 chars. We calculate the maximum allowed InferenceService name length based on the namespace length to ensure the final hostname stays within DNS limits.

func GenerateModelName

func GenerateModelName(imageURI string) (string, error)

GenerateModelName creates a Kubernetes-valid name from an image URI using utils.GenerateDerivedName. Returns an error if the image URI cannot be parsed.

func GenerateTemplateCacheName

func GenerateTemplateCacheName(
	templateName, namespace, serviceName, serviceIdentity string,
	cachingMode aimv1alpha1.AIMCachingMode,
) (string, error)

GenerateTemplateCacheName creates a deterministic name for a template cache. For dedicated mode, serviceIdentity should be the service UID to avoid conflicts when a service is deleted and recreated with the same name.

func ResolveServiceRoutePath

func ResolveServiceRoutePath(service *aimv1alpha1.AIMService, runtimeConfig *aimv1alpha1.AIMRuntimeConfigCommon) (string, error)

ResolveServiceRoutePath renders the HTTP route prefix using service and runtime config context. The precedence order is: 1. Service.Spec.Routing.PathTemplate (highest priority) 2. RuntimeConfig.Routing.PathTemplate (base layer)

func ResolveServiceRouteTimeout

func ResolveServiceRouteTimeout(service *aimv1alpha1.AIMService, runtimeConfig *aimv1alpha1.AIMRuntimeConfigCommon) *string

ResolveServiceRouteTimeout resolves the HTTP route timeout using service and runtime config context. The precedence order is: 1. Service.Spec.Routing.RequestTimeout (highest priority) 2. RuntimeConfig.Routing.RequestTimeout (base layer) Returns nil if no timeout is configured at any level.

Types

type CandidateEvaluation

type CandidateEvaluation struct {
	Candidate TemplateCandidate
	Status    string // "chosen" or "rejected"
	Reason    string // CamelCase reason
	Rank      int    // For candidates that passed all filters
}

CandidateEvaluation captures why a specific candidate was chosen or rejected.

type ModelFetchResult

type ModelFetchResult struct {
	Model        controllerutils.FetchResult[*aimv1alpha1.AIMModel]
	ClusterModel controllerutils.FetchResult[*aimv1alpha1.AIMClusterModel]
	// ImageURI is set when Model.Image is specified (needed for building the model in PlanResources).
	ImageURI string
	// CustomSpec is set when Model.Custom is specified (needed for building the model in PlanResources).
	CustomSpec *aimv1alpha1.AIMServiceModelCustom
}

ModelFetchResult holds the result of fetching/resolving a model for the service.

type SelectionDiagnostics

type SelectionDiagnostics struct {
	TotalCandidates                  int
	AfterAvailabilityFilter          int
	AfterUnoptimizedFilter           int
	AfterOverridesFilter             int
	AfterGPUAvailabilityFilter       int
	UnoptimizedTemplatesWereFiltered bool
}

SelectionDiagnostics provides detailed information about why template selection failed.

type ServiceFetchResult

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

ServiceFetchResult holds all fetched resources needed for AIMService reconciliation.

type ServiceObservation

type ServiceObservation struct {
	ServiceFetchResult
	// contains filtered or unexported fields
}

ServiceObservation embeds the fetch result and adds derived state.

func (ServiceObservation) GetComponentHealth

func (obs ServiceObservation) GetComponentHealth(ctx context.Context, clientset kubernetes.Interface) []controllerutils.ComponentHealth

GetComponentHealth returns health status for each component. NOTE: Unlike other controllers where this is on FetchResult, AIMService defines it on ServiceObservation because model health depends on derived state (needsModelCreation) computed in ComposeState. The template/isvc/cache health helpers remain on ServiceFetchResult and are accessible via embedding.

type ServiceReconciler

type ServiceReconciler struct {
	Clientset kubernetes.Interface
	Scheme    *runtime.Scheme
}

ServiceReconciler implements the domain logic for AIMService reconciliation.

func (*ServiceReconciler) ComposeState

ComposeState creates the observation from fetched data, deriving semantic state.

func (*ServiceReconciler) DecorateStatus

DecorateStatus sets domain-specific status fields. Resolved references are only set when the upstream resource is Ready. This ensures we don't "lock in" a reference until it's actually usable, allowing the fetch logic to re-search for better alternatives on subsequent reconciles.

func (*ServiceReconciler) FetchRemoteState

FetchRemoteState fetches all resources needed for AIMService reconciliation. - Always fetch: InferenceService, HTTPRoute, TemplateCache (for health visibility) - Fetch when ISVC not found OR successfully fetched: Model, Template (for both creation and update) - Skip on transient ISVC fetch errors: Model, Template (to avoid accidental SSA re-applies)

func (*ServiceReconciler) PlanResources

PlanResources determines what resources need to be created or updated.

type TemplateCandidate

TemplateCandidate captures the information needed to evaluate a template during selection.

type TemplateFetchResult

TemplateFetchResult holds the result of fetching/resolving a template for the service.

type TemplateSelectionResult

type TemplateSelectionResult struct {
	SelectedTemplate          *aimv1alpha1.AIMServiceTemplate
	SelectedClusterTemplate   *aimv1alpha1.AIMClusterServiceTemplate
	CandidateCount            int
	TemplatesExistButNotReady bool
	SelectionReason           string
	SelectionMessage          string
	MatchingResults           []aimv1alpha1.AIMTemplateCandidateResult
	Error                     error
}

TemplateSelectionResult captures the result of template auto-selection.

Jump to

Keyboard shortcuts

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