config

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableTelemetry

func EnableTelemetry(enabled bool)

EnableTelemetry enables or disables OpenTelemetry spans in controllers

func IsTelemetryEnabled

func IsTelemetryEnabled() bool

IsTelemetryEnabled reports whether OpenTelemetry spans should be emitted

Types

type ControllerConfig

type ControllerConfig struct {
	// StoryRun controller configuration
	StoryRun StoryRunConfig `json:"storyRun,omitempty"`

	// StepRun controller configuration
	StepRun StepRunConfig `json:"stepRun,omitempty"`

	// Story controller configuration
	Story StoryConfig `json:"story,omitempty"`

	// Engram controller configuration
	Engram EngramConfig `json:"engram,omitempty"`

	// Impulse controller configuration
	Impulse ImpulseConfig `json:"impulse,omitempty"`

	// Template controllers configuration
	Template TemplateConfig `json:"template,omitempty"`

	// MaxStoryWithBlockSizeBytes is the maximum allowed size for a Story's spec.steps.with block.
	// This prevents oversized resources from being stored in etcd.
	// +optional
	MaxStoryWithBlockSizeBytes int `json:"maxStoryWithBlockSizeBytes,omitempty"`

	DefaultEngramImage    string `json:"defaultEngramImage,omitempty"`
	DefaultImpulseImage   string `json:"defaultImpulseImage,omitempty"`
	DefaultEngramGRPCPort int    `json:"defaultEngramGRPCPort,omitempty"`
	DefaultCPURequest     string `json:"defaultCPURequest,omitempty"`
	DefaultCPULimit       string `json:"defaultCPULimit,omitempty"`
	DefaultMemoryRequest  string `json:"defaultMemoryRequest,omitempty"`
	DefaultMemoryLimit    string `json:"defaultMemoryLimit,omitempty"`

	// Global Controller Configuration
	MaxConcurrentReconciles int             `json:"maxConcurrentReconciles,omitempty"`
	RequeueBaseDelay        time.Duration   `json:"requeueBaseDelay,omitempty"`
	RequeueMaxDelay         time.Duration   `json:"requeueMaxDelay,omitempty"`
	HealthCheckInterval     time.Duration   `json:"healthCheckInterval,omitempty"`
	CleanupInterval         metav1.Duration `json:"cleanupInterval,omitempty"`

	// ReconcileTimeout bounds the duration of a single reconcile loop.
	// Set to 0 to disable deadline (not recommended for production).
	ReconcileTimeout time.Duration `json:"reconcileTimeout,omitempty"`

	// Image Configuration
	ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`

	// Resource Limits
	EngramCPURequest    string `json:"engramCpuRequest,omitempty"`
	EngramCPULimit      string `json:"engramCpuLimit,omitempty"`
	EngramMemoryRequest string `json:"engramMemoryRequest,omitempty"`
	EngramMemoryLimit   string `json:"engramMemoryLimit,omitempty"`

	// Retry and Timeout Configuration
	MaxRetries             int           `json:"maxRetries,omitempty"`
	ExponentialBackoffBase time.Duration `json:"exponentialBackoffBase,omitempty"`
	ExponentialBackoffMax  time.Duration `json:"exponentialBackoffMax,omitempty"`
	DefaultStepTimeout     time.Duration `json:"defaultStepTimeout,omitempty"`
	ApprovalDefaultTimeout time.Duration `json:"approvalDefaultTimeout,omitempty"`
	ExternalDataTimeout    time.Duration `json:"externalDataTimeout,omitempty"`
	ConditionalTimeout     time.Duration `json:"conditionalTimeout,omitempty"`

	// Loop Processing Configuration
	MaxLoopIterations    int `json:"maxLoopIterations,omitempty"`
	DefaultLoopBatchSize int `json:"defaultLoopBatchSize,omitempty"`
	MaxLoopBatchSize     int `json:"maxLoopBatchSize,omitempty"`
	MaxLoopConcurrency   int `json:"maxLoopConcurrency,omitempty"`
	MaxConcurrencyLimit  int `json:"maxConcurrencyLimit,omitempty"`

	// Security Configuration
	RunAsNonRoot             bool     `json:"runAsNonRoot,omitempty"`
	ReadOnlyRootFilesystem   bool     `json:"readOnlyRootFilesystem,omitempty"`
	AllowPrivilegeEscalation bool     `json:"allowPrivilegeEscalation,omitempty"`
	DropCapabilities         []string `json:"dropCapabilities,omitempty"`
	RunAsUser                int64    `json:"runAsUser,omitempty"`

	// Job Configuration
	JobBackoffLimit              int32                `json:"jobBackoffLimit,omitempty"`
	JobRestartPolicy             corev1.RestartPolicy `json:"jobRestartPolicy,omitempty"`
	TTLSecondsAfterFinished      int32                `json:"ttlSecondsAfterFinished,omitempty"`
	ServiceAccountName           string               `json:"serviceAccountName,omitempty"`
	AutomountServiceAccountToken bool                 `json:"automountServiceAccountToken,omitempty"`

	// CEL Configuration
	CELEvaluationTimeout   time.Duration `json:"celEvaluationTimeout,omitempty"`
	CELMaxExpressionLength int           `json:"celMaxExpressionLength,omitempty"`
	CELEnableMacros        bool          `json:"celEnableMacros,omitempty"`

	// Telemetry Configuration
	TelemetryEnabled        bool `json:"telemetryEnabled,omitempty"`
	TracePropagationEnabled bool `json:"tracePropagationEnabled,omitempty"`

	// Development/Debug Configuration
	EnableVerboseLogging    bool `json:"enableVerboseLogging,omitempty"`
	EnableStepOutputLogging bool `json:"enableStepOutputLogging,omitempty"`
	EnableMetrics           bool `json:"enableMetrics,omitempty"`

	// Operator-level default storage configuration (applied when Story policy is absent)
	DefaultStorageProvider  string `json:"defaultStorageProvider,omitempty"`
	DefaultS3Bucket         string `json:"defaultS3Bucket,omitempty"`
	DefaultS3Region         string `json:"defaultS3Region,omitempty"`
	DefaultS3Endpoint       string `json:"defaultS3Endpoint,omitempty"`
	DefaultS3UsePathStyle   bool   `json:"defaultS3UsePathStyle,omitempty"`
	DefaultS3AuthSecretName string `json:"defaultS3AuthSecretName,omitempty"`
}

ControllerConfig holds configurable parameters for all controllers

func DefaultControllerConfig

func DefaultControllerConfig() *ControllerConfig

DefaultControllerConfig returns the default configuration

func (*ControllerConfig) BuildCleanupControllerOptions

func (c *ControllerConfig) BuildCleanupControllerOptions() controller.Options

BuildCleanupControllerOptions builds controller.Options for Cleanup

func (*ControllerConfig) BuildEngramControllerOptions

func (c *ControllerConfig) BuildEngramControllerOptions() controller.Options

BuildEngramControllerOptions builds controller.Options for Engram

func (*ControllerConfig) BuildImpulseControllerOptions

func (c *ControllerConfig) BuildImpulseControllerOptions() controller.Options

BuildImpulseControllerOptions builds controller.Options for Impulse

func (*ControllerConfig) BuildRealtimeEngramControllerOptions added in v0.1.3

func (c *ControllerConfig) BuildRealtimeEngramControllerOptions() controller.Options

BuildRealtimeEngramControllerOptions mirrors the Engram controller options for realtime workloads

func (*ControllerConfig) BuildStepRunControllerOptions

func (c *ControllerConfig) BuildStepRunControllerOptions() controller.Options

BuildStepRunControllerOptions builds controller.Options for StepRun

func (*ControllerConfig) BuildStoryControllerOptions

func (c *ControllerConfig) BuildStoryControllerOptions() controller.Options

BuildStoryControllerOptions builds controller.Options for Story

func (*ControllerConfig) BuildStoryRunControllerOptions

func (c *ControllerConfig) BuildStoryRunControllerOptions() controller.Options

BuildControllerOptions builds controller.Options from config

func (*ControllerConfig) BuildTemplateControllerOptions

func (c *ControllerConfig) BuildTemplateControllerOptions() controller.Options

BuildTemplateControllerOptions builds controller.Options for Template controllers

type ControllerDependencies

type ControllerDependencies struct {
	client.Client
	Scheme         *runtime.Scheme
	ConfigResolver *Resolver
	CELEvaluator   cel.Evaluator
}

ControllerDependencies holds all the shared dependencies required by the controllers. This struct is created once in main.go and passed to each controller, ensuring consistent access to shared services like configuration resolvers and CEL evaluators.

type EngramConfig

type EngramConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles
	MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`

	// RateLimiter configuration
	RateLimiter RateLimiterConfig `json:"rateLimiter,omitempty"`
	// EngramControllerConfig holds configuration specific to Engram controllers.
	EngramControllerConfig EngramControllerConfig `json:"engramControllerConfig,omitempty"`
}

EngramConfig contains Engram controller settings

type EngramControllerConfig

type EngramControllerConfig struct {
	// DefaultGRPCPort is the default port used for gRPC communication with realtime engrams.
	DefaultGRPCPort int `json:"defaultGRPCPort,omitempty"`
	// DefaultMaxInlineSize is the default maximum size in bytes for inputs/outputs
	// to be passed directly as environment variables. Larger values will be offloaded
	// to the configured storage backend.
	DefaultMaxInlineSize int `json:"defaultMaxInlineSize,omitempty"`
	// DefaultStorageTimeout is the timeout for storage operations (upload/download) in seconds.
	// This should be tuned based on expected output sizes and S3 latency:
	//   timeout >= (max_output_mb / upload_bandwidth_mbps) * 1.5 + baseline_latency_sec
	DefaultStorageTimeoutSeconds int `json:"defaultStorageTimeoutSeconds,omitempty"`
	// DefaultGracefulShutdownTimeoutSeconds is the timeout for streaming engrams to drain
	// in-flight messages during graceful shutdown. Should be set to terminationGracePeriodSeconds - 10s
	// to leave adequate margin before Kubernetes sends SIGKILL.
	DefaultGracefulShutdownTimeoutSeconds int `json:"defaultGracefulShutdownTimeoutSeconds,omitempty"`
	// DefaultTerminationGracePeriodSeconds is the grace period for pod termination.
	// Applies to both batch Jobs and streaming Deployments.
	DefaultTerminationGracePeriodSeconds int64 `json:"defaultTerminationGracePeriodSeconds,omitempty"`

	// DefaultMaxRecvMsgBytes is the default max gRPC message size for receiving.
	DefaultMaxRecvMsgBytes int `json:"defaultMaxRecvMsgBytes,omitempty"`
	// DefaultMaxSendMsgBytes is the default max gRPC message size for sending.
	DefaultMaxSendMsgBytes int `json:"defaultMaxSendMsgBytes,omitempty"`
	// DefaultDialTimeoutSeconds is the client-side timeout for establishing a gRPC connection.
	DefaultDialTimeoutSeconds int `json:"defaultDialTimeoutSeconds,omitempty"`
	// DefaultChannelBufferSize is the in-memory channel buffer size for SDK streams.
	DefaultChannelBufferSize int `json:"defaultChannelBufferSize,omitempty"`
	// DefaultReconnectMaxRetries is the number of retries on transient gRPC connection errors.
	DefaultReconnectMaxRetries int `json:"defaultReconnectMaxRetries,omitempty"`
	// DefaultReconnectBaseBackoffMillis is the base backoff delay for reconnect attempts.
	DefaultReconnectBaseBackoffMillis int `json:"defaultReconnectBaseBackoffMillis,omitempty"`
	// DefaultReconnectMaxBackoffSeconds is the max backoff delay for reconnect attempts.
	DefaultReconnectMaxBackoffSeconds int `json:"defaultReconnectMaxBackoffSeconds,omitempty"`
	// DefaultHangTimeoutSeconds is the timeout for detecting a hung gRPC stream (no heartbeats).
	DefaultHangTimeoutSeconds int `json:"defaultHangTimeoutSeconds,omitempty"`
	// DefaultMessageTimeoutSeconds is the timeout for individual message operations.
	DefaultMessageTimeoutSeconds int `json:"defaultMessageTimeoutSeconds,omitempty"`
}

EngramControllerConfig holds configuration specific to Engram controllers.

type ImpulseConfig

type ImpulseConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles
	MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`

	// RateLimiter configuration
	RateLimiter RateLimiterConfig `json:"rateLimiter,omitempty"`
}

ImpulseConfig contains Impulse controller settings

type OperatorConfig

type OperatorConfig struct {
	Controller ControllerConfig `json:"controller,omitempty"`
}

OperatorConfig holds the configuration for the operator

func DefaultOperatorConfig

func DefaultOperatorConfig() *OperatorConfig

DefaultOperatorConfig returns the default configuration

type OperatorConfigManager

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

OperatorConfigManager manages the operator's dynamic configuration It implements the controller-runtime reconcile.Reconciler interface

func NewOperatorConfigManager

func NewOperatorConfigManager(k8sClient client.Client, namespace, configMapName string) *OperatorConfigManager

NewOperatorConfigManager creates a new configuration manager

func (*OperatorConfigManager) GetConfig

func (m *OperatorConfigManager) GetConfig() *OperatorConfig

GetConfig returns the current operator configuration

func (*OperatorConfigManager) GetControllerConfig

func (m *OperatorConfigManager) GetControllerConfig() *ControllerConfig

GetControllerConfig returns the controller-specific configuration

func (*OperatorConfigManager) LoadInitial added in v0.1.3

func (m *OperatorConfigManager) LoadInitial(ctx context.Context) error

LoadInitial performs a one-time synchronous load of the operator configuration.

func (*OperatorConfigManager) Reconcile added in v0.1.3

Reconcile handles ConfigMap changes and updates the operator configuration. This is the event-driven approach that reacts to ConfigMap updates immediately.

func (*OperatorConfigManager) RefreshConfig

func (ocm *OperatorConfigManager) RefreshConfig()

RefreshConfig clears the cache and forces a reload

func (*OperatorConfigManager) SetAPIReader added in v0.1.3

func (m *OperatorConfigManager) SetAPIReader(reader client.Reader)

SetAPIReader configures a non-cached reader for situations where the cache is not yet running.

func (*OperatorConfigManager) SetupWithManager added in v0.1.3

func (m *OperatorConfigManager) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type RateLimiterConfig

type RateLimiterConfig struct {
	// BaseDelay is the base delay for exponential backoff
	BaseDelay time.Duration `json:"baseDelay,omitempty"`

	// MaxDelay is the maximum delay for exponential backoff
	MaxDelay time.Duration `json:"maxDelay,omitempty"`
}

RateLimiterConfig contains rate limiter settings

type ResolvedExecutionConfig

type ResolvedExecutionConfig struct {
	Image                        string
	ImagePullPolicy              corev1.PullPolicy
	Resources                    corev1.ResourceRequirements
	Storage                      *v1alpha1.StoragePolicy
	ServiceAccountName           string
	AutomountServiceAccountToken bool
	RunAsNonRoot                 bool
	ReadOnlyRootFilesystem       bool
	AllowPrivilegeEscalation     bool
	RunAsUser                    int64
	BackoffLimit                 int32
	TTLSecondsAfterFinished      int32
	RestartPolicy                corev1.RestartPolicy
	DefaultStepTimeout           time.Duration
	MaxRetries                   int
	BackoffBase                  time.Duration
	BackoffMax                   time.Duration
	Secrets                      map[string]string

	// Health check probes (from template, can be disabled at instance level)
	LivenessProbe  *corev1.Probe
	ReadinessProbe *corev1.Probe
	StartupProbe   *corev1.Probe

	// Service configuration (from template)
	ServicePorts       []corev1.ServicePort
	ServiceLabels      map[string]string
	ServiceAnnotations map[string]string
}

ResolvedExecutionConfig represents the final resolved configuration for a StepRun

func (*ResolvedExecutionConfig) ToContainerSecurityContext

func (config *ResolvedExecutionConfig) ToContainerSecurityContext() *corev1.SecurityContext

ToContainerSecurityContext converts to Kubernetes SecurityContext for a container

func (*ResolvedExecutionConfig) ToPodSecurityContext

func (config *ResolvedExecutionConfig) ToPodSecurityContext() *corev1.PodSecurityContext

ToPodSecurityContext converts to Kubernetes PodSecurityContext

func (*ResolvedExecutionConfig) ToResourceRequirements

func (config *ResolvedExecutionConfig) ToResourceRequirements() corev1.ResourceRequirements

ToResourceRequirements converts to Kubernetes ResourceRequirements

type Resolver

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

Resolver resolves configuration with hierarchical priority Priority (highest to lowest): StepRun > Story.Policy > Namespace > Controller Config

func NewResolver

func NewResolver(k8sClient client.Client, configManager *OperatorConfigManager) *Resolver

NewResolver creates a new configuration resolver

func (*Resolver) ApplyExecutionOverrides

func (cr *Resolver) ApplyExecutionOverrides(overrides *v1alpha1.ExecutionOverrides, config *ResolvedExecutionConfig)

ApplyExecutionOverrides applies ExecutionOverrides from either Engram or Impulse This is a public method so controllers can apply instance-level overrides

func (*Resolver) GetOperatorConfig

func (cr *Resolver) GetOperatorConfig() *OperatorConfig

GetOperatorConfig returns the current, raw operator configuration. This is the primary way for controllers to access global, non-hierarchical configuration values like default ports or image names.

func (*Resolver) ResolveExecutionConfig

func (cr *Resolver) ResolveExecutionConfig(ctx context.Context, step *runsv1alpha1.StepRun, story *v1alpha1.Story, engram *v1alpha1.Engram, template *catalogv1alpha1.EngramTemplate, storyStep *v1alpha1.Step) (*ResolvedExecutionConfig, error)

ResolveExecutionConfig resolves the final execution configuration for a step by merging settings from all levels of the hierarchy. The precedence order is: StepRun -> Story Step -> Engram -> EngramTemplate -> Operator Config -> Hardcoded Defaults.

func (*Resolver) ResolveImagePullPolicy

func (cr *Resolver) ResolveImagePullPolicy(ctx context.Context, step *runsv1alpha1.StepRun, story *v1alpha1.Story, engram *v1alpha1.Engram, template *catalogv1alpha1.EngramTemplate) corev1.PullPolicy

ResolveImagePullPolicy resolves the image pull policy from the hierarchy.

type StepRunConfig

type StepRunConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles
	MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`

	// RateLimiter configuration
	RateLimiter RateLimiterConfig `json:"rateLimiter,omitempty"`
}

StepRunConfig contains StepRun controller settings

type StoryConfig

type StoryConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles
	MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`

	// RateLimiter configuration
	RateLimiter RateLimiterConfig `json:"rateLimiter,omitempty"`
}

StoryConfig contains Story controller settings

type StoryRunConfig

type StoryRunConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles
	MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`

	// RateLimiter configuration
	RateLimiter RateLimiterConfig `json:"rateLimiter,omitempty"`

	// MaxInlineInputsSize is the maximum size in bytes for StoryRun spec.inputs.
	// Payloads larger than this will be rejected by the controller if webhooks are disabled.
	MaxInlineInputsSize int `json:"maxInlineInputsSize,omitempty"`
}

StoryRunConfig contains StoryRun controller settings

type TemplateConfig

type TemplateConfig struct {
	// MaxConcurrentReconciles is the maximum number of concurrent reconciles
	MaxConcurrentReconciles int `json:"maxConcurrentReconciles,omitempty"`

	// RateLimiter configuration
	RateLimiter RateLimiterConfig `json:"rateLimiter,omitempty"`
}

TemplateConfig contains Template controller settings (EngramTemplate, ImpulseTemplate)

Jump to

Keyboard shortcuts

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