defaults

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package defaults provides centralized configuration constants for the AICR system.

This package defines timeout values, retry parameters, and other configuration defaults used across the codebase. Centralizing these values ensures consistency and makes tuning easier.

Timeout Categories

Timeouts are organized by component:

  • Collector timeouts: For system data collection operations
  • Handler timeouts: For HTTP request processing
  • Server timeouts: For HTTP server configuration
  • Kubernetes timeouts: For K8s API operations
  • HTTP client timeouts: For outbound HTTP requests

Usage

Import and use constants directly:

import "github.com/NVIDIA/aicr/pkg/defaults"

ctx, cancel := context.WithTimeout(ctx, defaults.CollectorTimeout)
defer cancel()

Timeout Guidelines

When choosing timeout values:

  • Collectors: 10s default, respects parent context deadline
  • HTTP handlers: 30s for recipes, 60s for bundles
  • K8s operations: 30s for API calls, 5m for job completion
  • Server shutdown: 30s for graceful shutdown

Index

Constants

View Source
const (
	// CollectorTimeout is the default timeout for collector operations.
	// Collectors should respect parent context deadlines when shorter.
	CollectorTimeout = 10 * time.Second

	// CollectorK8sTimeout is the timeout for Kubernetes API calls in collectors.
	CollectorK8sTimeout = 30 * time.Second
)

Collector timeouts for data collection operations.

View Source
const (
	// RecipeHandlerTimeout is the timeout for recipe generation requests.
	RecipeHandlerTimeout = 30 * time.Second

	// RecipeBuildTimeout is the internal timeout for recipe building.
	// Should be less than RecipeHandlerTimeout to allow error handling.
	RecipeBuildTimeout = 25 * time.Second

	// BundleHandlerTimeout is the timeout for bundle generation requests.
	// Longer than recipe due to file I/O operations.
	BundleHandlerTimeout = 60 * time.Second

	// RecipeCacheTTL is the default cache duration for recipe responses.
	RecipeCacheTTL = 10 * time.Minute
)

Handler timeouts for HTTP request processing.

View Source
const (
	// ServerReadTimeout is the maximum duration for reading request headers.
	ServerReadTimeout = 10 * time.Second

	// ServerReadHeaderTimeout prevents slow header attacks.
	ServerReadHeaderTimeout = 5 * time.Second

	// ServerWriteTimeout is the maximum duration for writing a response.
	ServerWriteTimeout = 30 * time.Second

	// ServerIdleTimeout is the maximum duration to wait for the next request.
	ServerIdleTimeout = 120 * time.Second

	// ServerShutdownTimeout is the maximum duration for graceful shutdown.
	ServerShutdownTimeout = 30 * time.Second
)

Server timeouts for HTTP server configuration.

View Source
const (
	// K8sJobCreationTimeout is the timeout for creating K8s Job resources.
	K8sJobCreationTimeout = 30 * time.Second

	// K8sPodReadyTimeout is the timeout for waiting for pods to be ready.
	K8sPodReadyTimeout = 60 * time.Second

	// K8sJobCompletionTimeout is the default timeout for job completion.
	K8sJobCompletionTimeout = 5 * time.Minute

	// K8sCleanupTimeout is the timeout for cleanup operations.
	K8sCleanupTimeout = 30 * time.Second
)

Kubernetes timeouts for K8s API operations.

View Source
const (
	// HTTPClientTimeout is the default total timeout for HTTP requests.
	HTTPClientTimeout = 30 * time.Second

	// HTTPConnectTimeout is the timeout for establishing connections.
	HTTPConnectTimeout = 5 * time.Second

	// HTTPTLSHandshakeTimeout is the timeout for TLS handshake.
	HTTPTLSHandshakeTimeout = 5 * time.Second

	// HTTPResponseHeaderTimeout is the timeout for reading response headers.
	HTTPResponseHeaderTimeout = 10 * time.Second

	// HTTPIdleConnTimeout is the timeout for idle connections in the pool.
	HTTPIdleConnTimeout = 90 * time.Second

	// HTTPKeepAlive is the keep-alive duration for connections.
	HTTPKeepAlive = 30 * time.Second

	// HTTPExpectContinueTimeout is the timeout for Expect: 100-continue.
	HTTPExpectContinueTimeout = 1 * time.Second
)

HTTP client timeouts for outbound requests.

View Source
const (
	// ValidateReadinessTimeout is the default timeout for readiness validation.
	ValidateReadinessTimeout = 5 * time.Minute

	// ValidateDeploymentTimeout is the default timeout for deployment validation.
	ValidateDeploymentTimeout = 10 * time.Minute

	// ValidatePerformanceTimeout is the default timeout for performance validation.
	// Performance tests may take longer due to GPU benchmarks.
	ValidatePerformanceTimeout = 30 * time.Minute

	// ValidateConformanceTimeout is the default timeout for conformance validation.
	ValidateConformanceTimeout = 15 * time.Minute

	// ResourceVerificationTimeout is the timeout for verifying individual
	// expected resources exist and are healthy during deployment validation.
	ResourceVerificationTimeout = 10 * time.Second

	// ComponentRenderTimeout is the maximum time to render a single component
	// via helm template or manifest file rendering during resource discovery.
	ComponentRenderTimeout = 60 * time.Second
)

Validation phase timeouts for validation phase operations. These are used when the recipe does not specify a timeout.

View Source
const (
	// PodWaitTimeout is the maximum time to wait for pod operations to complete.
	PodWaitTimeout = 10 * time.Minute

	// PodPollInterval is the interval for polling pod status.
	// Used in legacy polling code (to be replaced with watch API in Phase 3).
	PodPollInterval = 500 * time.Millisecond

	// ValidationPodTimeout is the timeout for validation pod operations.
	ValidationPodTimeout = 10 * time.Minute

	// DiagnosticTimeout is the timeout for collecting diagnostic information.
	DiagnosticTimeout = 2 * time.Minute

	// PodReadyTimeout is the timeout for waiting for pods to become ready.
	PodReadyTimeout = 2 * time.Minute
)

Pod operation timeouts for validation and agent operations.

View Source
const (
	// CLISnapshotTimeout is the default timeout for snapshot operations.
	CLISnapshotTimeout = 5 * time.Minute
)

CLI timeouts for command-line operations.

View Source
const (
	// ConfigMapWriteTimeout is the timeout for writing to ConfigMaps.
	ConfigMapWriteTimeout = 30 * time.Second
)

ConfigMap timeouts for Kubernetes ConfigMap operations.

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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