status

package
v0.7.5 Latest Latest
Warning

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

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

Documentation

Overview

Package status contains release condition, digest, and history helpers.

Index

Constants

View Source
const (
	ReadyCondition          = meta.ReadyCondition       // "Ready"
	ReconcilingCondition    = meta.ReconcilingCondition // "Reconciling"
	StalledCondition        = meta.StalledCondition     // "Stalled"
	ModuleResolvedCondition = "ModuleResolved"
	DriftedCondition        = "Drifted"
)

Condition types. Ready, Reconciling, and Stalled are reexported from Flux meta for consistency.

View Source
const (
	SuspendedReason               = "Suspended"
	ResolutionFailedReason        = "ResolutionFailed"
	RenderFailedReason            = "RenderFailed"
	ApplyFailedReason             = "ApplyFailed"
	PruneFailedReason             = "PruneFailed"
	ImpersonationFailedReason     = "ImpersonationFailed"
	DeletionSAMissingReason       = "DeletionSAMissing"
	OrphanedOnDeletionReason      = "OrphanedOnDeletion"
	ReconciliationSucceededReason = "ReconciliationSucceeded"
	DriftDetectedReason           = "DriftDetected"

	// Platform-specific reasons.
	MaterializedReason      = "Materialized"      // Ready=True: the Platform materialized successfully.
	MaterializeFailedReason = "MaterializeFailed" // Ready=False: Materialize returned a MaterializeError.

	// Release-specific reasons.
	SourceNotReadyReason       = "SourceNotReady"
	FetchFailedReason          = "FetchFailed"
	PathNotFoundReason         = "PathNotFound"
	ReleaseFileNotFoundReason  = "ReleaseFileNotFound"
	UnsupportedKindReason      = "UnsupportedKind"
	DependenciesNotReadyReason = "DependenciesNotReady"
	PlatformNotReadyReason     = "PlatformNotReady"

	// Event-only reasons (no corresponding condition).
	AppliedReason = "Applied"
	PrunedReason  = "Pruned"
	ResumedReason = "Resumed"
	NoOpReason    = "NoOp"
)

Condition reasons.

View Source
const (
	CounterReconcile = "reconcile"
	CounterApply     = "apply"
	CounterPrune     = "prune"
	CounterDrift     = "drift"
)

Counter field names used by IncrementCounter and ResetCounter.

View Source
const (
	// MaxHistoryEntries is the maximum number of history entries retained.
	// Matches docs/design/module-release-reconcile-loop.md retention policy
	// (design decision 1).
	MaxHistoryEntries = 10
)

Variables

This section is empty.

Functions

func ClearDrifted

func ClearDrifted(obj conditions.Setter)

ClearDrifted removes the Drifted condition (drift resolved by successful apply).

func ConfigDigest

func ConfigDigest(values *releasesv1alpha1.RawValues) string

ConfigDigest computes a deterministic SHA-256 digest of the release values. Serializes RawValues to canonical JSON (sorted keys), then hashes. Returns the SHA-256 of empty input if values is nil (nil = no config), consistent with inventory.ComputeDigest(nil). Format: "sha256:<hex>"

func EnsureCounters

EnsureCounters initializes status.FailureCounters if nil and returns the pointer. Callers can safely use the returned pointer without nil checks.

func EnsureReleaseCounters

func EnsureReleaseCounters(status *releasesv1alpha1.ReleaseStatus) *releasesv1alpha1.FailureCounters

EnsureReleaseCounters is the Release equivalent of EnsureCounters.

func IncrementCounter

func IncrementCounter(counters *releasesv1alpha1.FailureCounters, field string)

IncrementCounter increments the named failure counter by one. Unknown field names are silently ignored.

func IsNoOp

func IsNoOp(current, lastApplied DigestSet) bool

IsNoOp returns true if all four digests in current match lastApplied. Returns false if any lastApplied field is empty (handles first reconcile).

func MarkDrifted

func MarkDrifted(obj conditions.Setter, count int)

MarkDrifted sets Drifted=True with a message indicating the number of drifted resources. Drift is informational only — does not affect Ready condition.

func MarkModuleResolved

func MarkModuleResolved(obj conditions.Setter, moduleRef string)

MarkModuleResolved sets ModuleResolved=True indicating the CUE module was successfully resolved from the OCI registry.

func MarkNotReady

func MarkNotReady(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)

MarkNotReady sets Ready=False with the given reason and message.

func MarkReady

func MarkReady(obj conditions.Setter, messageFormat string, messageArgs ...any)

MarkReady sets Ready=True and removes Reconciling and Stalled conditions.

func MarkReadyWithReason added in v0.7.0

func MarkReadyWithReason(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)

MarkReadyWithReason sets Ready=True with an explicit reason and removes Reconciling and Stalled conditions. Used where the success reason is not the generic ReconciliationSucceeded (e.g. the Platform's Materialized reason).

func MarkReconciling

func MarkReconciling(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)

MarkReconciling sets Reconciling=True, removes Stalled, and sets Ready=Unknown.

func MarkStalled

func MarkStalled(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)

MarkStalled sets Stalled=True, removes Reconciling, and sets Ready=False.

func MarkSuspended

func MarkSuspended(obj conditions.Setter)

MarkSuspended sets Ready=False with reason Suspended and removes Reconciling and Stalled conditions.

func ModuleSourceDigest

func ModuleSourceDigest(modulePath, moduleVersion string) string

ModuleSourceDigest computes a deterministic source digest from a CUE module path and version. Replaces SourceDigest for the CUE-native module resolution path where there is no Flux artifact digest.

func NewFailureEntry

func NewFailureEntry(
	action string,
	message string,
	digests DigestSet,
) releasesv1alpha1.HistoryEntry

NewFailureEntry creates a HistoryEntry for a failed reconcile attempt. Populates timestamps via metav1.Now(). Digests may be partially filled depending on which phase failed.

func NewSuccessEntry

func NewSuccessEntry(
	action string,
	phase string,
	digests DigestSet,
	inventoryCount int64,
) releasesv1alpha1.HistoryEntry

NewSuccessEntry creates a HistoryEntry for a successful reconcile action. Populates timestamps via metav1.Now() automatically (design decision 2: typed helpers). Digest fields are populated from the DigestSet (change 6).

func RecordHistory

func RecordHistory(
	status *releasesv1alpha1.ModuleReleaseStatus,
	entry releasesv1alpha1.HistoryEntry,
)

RecordHistory prepends entry to status.History and trims to MaxHistoryEntries. The entry's Sequence is set to nextSequence(status.History) before prepending. Newest entry is at index 0 after prepend.

Does not record periodic no-ops (caller responsibility — design doc explicitly excludes recording every periodic no-op).

func RecordReleaseHistory

func RecordReleaseHistory(
	status *releasesv1alpha1.ReleaseStatus,
	entry releasesv1alpha1.HistoryEntry,
)

RecordReleaseHistory is the Release equivalent of RecordHistory.

func RenderDigest

func RenderDigest(resources []*core.Resource) (string, error)

RenderDigest computes a deterministic SHA-256 digest of the rendered resource set. Sorts resources by GVK + namespace + name (same order as inventory.ComputeDigest for consistency), serializes each via core.Resource.MarshalJSON(), and hashes the concatenation. Format: "sha256:<hex>"

func ResetCounter

func ResetCounter(counters *releasesv1alpha1.FailureCounters, field string)

ResetCounter sets the named failure counter to zero. Unknown field names are silently ignored.

Types

type DigestSet

type DigestSet struct {
	// Source is the artifact content digest from Flux OCIRepository.status.artifact.
	Source string

	// Config is the SHA-256 of normalized user values.
	Config string

	// Render is the SHA-256 of the sorted, serialized rendered resource set.
	Render string

	// Inventory is the SHA-256 of the owned resource inventory
	// (computed via internal/inventory.ComputeDigest).
	Inventory string
}

DigestSet holds the four reconcile digests tracked in ModuleRelease.status. Uses named fields rather than a map for type safety (design decision 3).

Maps to status fields:

Source    → lastAttemptedSourceDigest / lastAppliedSourceDigest
Config    → lastAttemptedConfigDigest / lastAppliedConfigDigest
Render    → lastAttemptedRenderDigest / lastAppliedRenderDigest
Inventory → status.inventory.digest

Jump to

Keyboard shortcuts

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