utils

package
v0.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Standard backoff for most operations
	StandardBackoff = wait.Backoff{
		Duration: 100 * time.Millisecond,
		Factor:   2.0,
		Jitter:   0.1,
		Steps:    5,
	}

	// Slow backoff for operations that need more time
	ReconcileBackoff = wait.Backoff{
		Duration: 500 * time.Millisecond,
		Factor:   2.0,
		Steps:    5,
	}

	// Prometheus validation backoff with longer intervals
	// TODO: investigate why Prometheus needs longer backoff durations
	PrometheusBackoff = wait.Backoff{
		Duration: 5 * time.Second,
		Factor:   2.0,
		Jitter:   0.1,
		Steps:    6,
	}
)

Global backoff configurations

Functions

func AddModelAcceleratorProfileToSystemData

func AddModelAcceleratorProfileToSystemData(
	sd *infernoConfig.SystemData,
	modelName string,
	modelAcceleratorProfile *llmdVariantAutoscalingV1alpha1.AcceleratorProfile) (err error)

add model accelerator pair profile data to inferno system data

func AddServerInfoToSystemData

func AddServerInfoToSystemData(
	sd *infernoConfig.SystemData,
	va *llmdVariantAutoscalingV1alpha1.VariantAutoscaling,
	className string) (err error)

Add server specs to inferno system data

func CheckValue

func CheckValue(x float64) bool

Helper to check if a value is valid (not NaN or infinite)

func CreateOptimizedAlloc

func CreateOptimizedAlloc(name string,
	namespace string,
	allocationSolution *infernoConfig.AllocationSolution) (*llmdVariantAutoscalingV1alpha1.OptimizedAlloc, error)

Adapter from inferno alloc solution to optimized alloc

func CreatePrometheusClientConfig

func CreatePrometheusClientConfig(config *interfaces.PrometheusConfig) (*api.Config, error)

CreatePrometheusClientConfig creates a complete Prometheus client configuration with HTTPS support. Supports both direct bearer tokens and token files for flexible authentication.

func CreatePrometheusTransport

func CreatePrometheusTransport(config *interfaces.PrometheusConfig) (http.RoundTripper, error)

CreatePrometheusTransport creates a custom HTTPS transport for Prometheus client with TLS support. TLS is always enabled for HTTPS-only support with configurable certificate validation.

func CreateSystemData

func CreateSystemData(
	acceleratorCm map[string]map[string]string,
	serviceClassCm map[string]string) *infernoConfig.SystemData

Adapter to create wva system data types from config maps. Note: WVA operates in unlimited mode, so capacity data is not used.

func CreateTLSConfig

func CreateTLSConfig(promConfig *interfaces.PrometheusConfig) (*tls.Config, error)

CreateTLSConfig creates a TLS configuration from PrometheusConfig. TLS is always enabled for HTTPS-only support. The configuration supports: - Server certificate validation via CA certificate - Mutual TLS authentication via client certificates - Insecure certificate verification (development/testing only)

func FindModelSLO

func FindModelSLO(cmData map[string]string, targetModel string) (*interfaces.ServiceClassEntry, string, error)

Helper to find SLOs for a model variant

func FullName

func FullName(name string, namespace string) string

Helper to create a (unique) full name from name and namespace

func GetConfigMapWithBackoff

func GetConfigMapWithBackoff(ctx context.Context, c client.Client, name, namespace string, cm *corev1.ConfigMap) error

func GetConfigValue

func GetConfigValue(data map[string]string, key, def string) string

GetConfigValue retrieves a value from a ConfigMap with a default fallback

func GetDeploymentWithBackoff

func GetDeploymentWithBackoff(ctx context.Context, c client.Client, name, namespace string, deploy *appsv1.Deployment) error

Helper functions for common resource types with standard backoff

func GetResourceWithBackoff

func GetResourceWithBackoff[T client.Object](ctx context.Context, c client.Client, objKey client.ObjectKey, obj T, backoff wait.Backoff, resourceType string) error

GetResourceWithBackoff performs a Get operation with exponential backoff retry logic

func GetVariantAutoscalingWithBackoff

func GetVariantAutoscalingWithBackoff(ctx context.Context, c client.Client, name, namespace string, va *llmdVariantAutoscalingV1alpha1.VariantAutoscaling) error

func GetZapLevelFromEnv

func GetZapLevelFromEnv() zapcore.Level

func MarshalStructToJsonString

func MarshalStructToJsonString(t any) string

func ParsePrometheusConfigFromEnv

func ParsePrometheusConfigFromEnv() *interfaces.PrometheusConfig

ParsePrometheusConfigFromEnv parses Prometheus configuration from environment variables. Supports both direct values and file paths for flexible deployment scenarios.

func Ptr

func Ptr[T any](v T) *T

func UpdateStatusWithBackoff

func UpdateStatusWithBackoff[T client.Object](ctx context.Context, c client.Client, obj T, backoff wait.Backoff, resourceType string) error

UpdateStatusWithBackoff performs a Status Update operation with exponential backoff retry logic

func ValidatePrometheusAPI

func ValidatePrometheusAPI(ctx context.Context, promAPI promv1.API) error

ValidatePrometheusAPI validates Prometheus API connectivity using standard Prometheus backoff

func ValidatePrometheusAPIWithBackoff

func ValidatePrometheusAPIWithBackoff(ctx context.Context, promAPI promv1.API, backoff wait.Backoff) error

ValidatePrometheusAPIWithBackoff validates Prometheus API connectivity with retry logic

func ValidateTLSConfig

func ValidateTLSConfig(promConfig *interfaces.PrometheusConfig) error

ValidateTLSConfig validates TLS configuration. Ensures HTTPS is used and certificate files exist when verification is enabled. Note: This function assumes promConfig is not nil - nil checks should be performed at a higher level.

Types

This section is empty.

Jump to

Keyboard shortcuts

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