reconcile

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package reconcile contains high-level release reconciliation orchestration.

Index

Constants

View Source
const (
	// BackoffBaseDelay is the initial retry delay after the first transient failure.
	BackoffBaseDelay = 5 * time.Second

	// BackoffMaxDelay is the maximum retry delay (cap for exponential growth).
	BackoffMaxDelay = 5 * time.Minute

	// StalledRecheckInterval is the periodic safety recheck for stalled failures,
	// guarding against misclassification.
	StalledRecheckInterval = 30 * time.Minute
)
View Source
const DefaultReleaseInterval = 5 * time.Minute

DefaultReleaseInterval is the fallback requeue interval when spec.interval is not set.

View Source
const (
	// FinalizerName is the finalizer registered on ModuleRelease resources
	// to ensure owned resources are cleaned up before deletion completes.
	FinalizerName = "releases.opmodel.dev/cleanup"
)

Variables

This section is empty.

Functions

func ComputeBackoff

func ComputeBackoff(failureCount int64) time.Duration

ComputeBackoff returns the exponential backoff delay for a given failure count. Formula: min(baseDelay * 2^(failures-1), maxDelay). Returns baseDelay when failureCount is 0 or 1.

func ReconcileModuleRelease

func ReconcileModuleRelease(
	ctx context.Context,
	params *ModuleReleaseParams,
	req ctrl.Request,
) (ctrl.Result, error)

ReconcileModuleRelease orchestrates all phases of the reconcile loop. Phases run sequentially; errors halt progression. Status is always patched at the end via deferred function.

func ReconcileRelease

func ReconcileRelease(
	ctx context.Context,
	params *ReleaseParams,
	req ctrl.Request,
) (ctrl.Result, error)

ReconcileRelease runs the full Release reconcile loop: source resolution, artifact fetch, path navigation, CUE load, kind detection, render, apply, prune, and status commit. Mirrors the ModuleRelease loop but sources the CUE package from a Flux artifact instead of synthesizing it.

Types

type ModuleReleaseParams

type ModuleReleaseParams struct {
	Client client.Client
	// APIReader is an uncached reader used for one-off reads (e.g. ServiceAccount
	// existence checks for impersonation) that should not provision a cache informer.
	APIReader       client.Reader
	RestConfig      *rest.Config
	ResourceManager *fluxssa.ResourceManager
	EventRecorder   events.EventRecorder
	// Renderer produces the render result for a ModuleRelease. Must be non-nil;
	// production wires render.KernelModuleRenderer, tests wire a stub.
	Renderer render.ModuleRenderer
	// DefaultServiceAccount is the fallback SA name used when a
	// ModuleRelease has an empty spec.serviceAccountName. Empty disables
	// the default and preserves the controller-client fallback.
	DefaultServiceAccount string
}

ModuleReleaseParams holds the dependencies injected into the reconcile loop.

type Outcome

type Outcome int

Outcome classifies the result of a reconcile attempt. Drives requeue behavior and condition setting.

const (
	// NoOp — all four digests match last applied. Ready=True, Reconciling=False.
	// Requeue: none (watch-driven only).
	NoOp Outcome = iota

	// Applied — resources applied successfully (no prune needed or prune disabled).
	// Ready=True, Reconciling=False. Requeue: none.
	Applied

	// AppliedAndPruned — resources applied and stale resources pruned.
	// Ready=True, Reconciling=False. Requeue: none.
	AppliedAndPruned

	// FailedTransient — temporary failure (network, API server).
	// Ready=False, Reconciling=True. Requeue: exponential backoff.
	FailedTransient

	// FailedStalled — permanent failure (invalid config, invalid module).
	// Ready=False, Stalled=True. Requeue: none (wait for spec change).
	FailedStalled
)

func (Outcome) MetricLabel

func (o Outcome) MetricLabel() string

MetricLabel returns the snake_case label value for Prometheus metrics.

func (Outcome) String

func (o Outcome) String() string

String returns a human-readable name for the outcome.

type ReleaseParams

type ReleaseParams struct {
	Client client.Client
	// APIReader is an uncached reader used for one-off reads (e.g. ServiceAccount
	// existence checks for impersonation) that should not provision a cache informer.
	APIReader       client.Reader
	RestConfig      *rest.Config
	ResourceManager *fluxssa.ResourceManager
	EventRecorder   events.EventRecorder

	// Fetcher downloads Flux source artifacts. Typically
	// &opmsource.ArtifactFetcher{} in production; tests inject a stub.
	Fetcher opmsource.Fetcher

	// Renderer loads and renders a CUE release package from a local directory.
	// Production wires render.KernelReleaseRenderer; tests inject a stub. It is
	// required — a nil Renderer is a programming error.
	Renderer render.ReleaseRenderer

	// DefaultServiceAccount is the fallback SA name used when a Release has
	// an empty spec.serviceAccountName. Empty disables the default and
	// preserves the controller-client fallback.
	DefaultServiceAccount string
}

ReleaseParams holds the dependencies for the Release reconcile loop.

Jump to

Keyboard shortcuts

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