Documentation
¶
Overview ¶
Package status contains release condition, digest, and history helpers.
Index ¶
- Constants
- func ClearDrifted(obj conditions.Setter)
- func ConfigDigest(values *releasesv1alpha1.RawValues) string
- func EnsureCounters(status *releasesv1alpha1.ModuleInstanceStatus) *releasesv1alpha1.FailureCounters
- func EnsureModulePackageCounters(status *releasesv1alpha1.ModulePackageStatus) *releasesv1alpha1.FailureCounters
- func IncrementCounter(counters *releasesv1alpha1.FailureCounters, field string)
- func IsNoOp(current, lastApplied DigestSet) bool
- func MarkDrifted(obj conditions.Setter, count int)
- func MarkManagedExternally(obj conditions.Setter)
- func MarkModuleResolved(obj conditions.Setter, moduleRef string)
- func MarkNotReady(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)
- func MarkReady(obj conditions.Setter, messageFormat string, messageArgs ...any)
- func MarkReadyWithReason(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)
- func MarkReconciling(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)
- func MarkStalled(obj conditions.Setter, reason, messageFormat string, messageArgs ...any)
- func MarkSuspended(obj conditions.Setter)
- func ModuleSourceDigest(modulePath, moduleVersion string) string
- func NewFailureEntry(action string, message string, digests DigestSet) releasesv1alpha1.HistoryEntry
- func NewSuccessEntry(action string, phase string, digests DigestSet, inventoryCount int64) releasesv1alpha1.HistoryEntry
- func RecordHistory(status *releasesv1alpha1.ModuleInstanceStatus, ...)
- func RecordModulePackageHistory(status *releasesv1alpha1.ModulePackageStatus, ...)
- func RenderDigest(resources []*core.Resource) (string, error)
- func ResetCounter(counters *releasesv1alpha1.FailureCounters, field string)
- type DigestSet
Constants ¶
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.
const ( SuspendedReason = "Suspended" ResolutionFailedReason = "ResolutionFailed" RenderFailedReason = "RenderFailed" // SkewRefusedReason: Ready=False, the platform's skew policy is Refuse and // the module requires a newer catalog build than the platform pins // (enhancement 0019 D7/D18). The fix is a platform pin bump or a module // downgrade, so it is distinct from RenderFailed. SkewRefusedReason = "SkewRefused" ApplyFailedReason = "ApplyFailed" PruneFailedReason = "PruneFailed" ImpersonationFailedReason = "ImpersonationFailed" DeletionSAMissingReason = "DeletionSAMissing" OrphanedOnDeletionReason = "OrphanedOnDeletion" ReconciliationSucceededReason = "ReconciliationSucceeded" DriftDetectedReason = "DriftDetected" ManagedExternallyReason = "ManagedExternally" // Platform-specific reasons (enhancement 0019 D6: the reconciler generates // and builds the platform module). GeneratedReason = "Generated" // Ready=True: the platform module was generated and built. GenerateFailedReason = "GenerateFailed" // Ready=False: the module could not be written to disk. BuildFailedReason = "BuildFailed" // Ready=False: a dependency did not resolve or the module did not build. // ModulePackage-specific reasons. SourceNotReadyReason = "SourceNotReady" FetchFailedReason = "FetchFailed" PathNotFoundReason = "PathNotFound" // Was: ReleaseFileNotFoundReason = "ReleaseFileNotFound" InstanceFileNotFoundReason = "InstanceFileNotFound" UnsupportedKindReason = "UnsupportedKind" DependenciesNotReadyReason = "DependenciesNotReady" PlatformNotReadyReason = "PlatformNotReady" // TransformerRegistration-specific reasons (enhancement 0015 D3: a claim // carries a verdict). Every refusal gets a reason of its own: a claimant // acts on the reason, and collapsing two causes into one sends them to // the wrong fix. // AcceptedReason: Ready=True, the claim passed every check. It is not // active: acceptance changes what a claim reports, not what it does. AcceptedReason = "Accepted" // CatalogUnresolvedReason: the claimed coordinate resolves to nothing. A // registry or coordinate problem, distinct from CatalogWrongKind, which // is an authoring one — collapsing the two sends the claimant to the // wrong fix (enhancement 0015 D10). CatalogUnresolvedReason = "CatalogUnresolved" CatalogWrongKindReason = "CatalogWrongKind" // ProvidesMismatchReason: the contract set re-derived from the catalog is // not exactly what the claim lists (enhancement 0015 D11). ProvidesMismatchReason = "ProvidesMismatch" // ProviderMismatchReason: the claim did not come from the ModuleInstance // its providerRef names — the instance is absent, or its inventory // settled without this claim (enhancement 0015 D11). ProviderMismatchReason = "ProviderMismatch" // ProviderInventoryPendingReason: Ready=Unknown, the naming instance has // not written an inventory yet. A race, not a verdict. ProviderInventoryPendingReason = "ProviderInventoryPending" // BuildIncompatibleReason: the claimed catalog requires a shared // OPM-namespace path at a version the platform did not resolve to // (enhancement 0015 D8). Refused at acceptance rather than at render, // where the failure would name an unrelated module instance. BuildIncompatibleReason = "BuildIncompatible" // DuplicateClaimReason: another claim already holds this provider catalog // (enhancement 0015 D12). The message names the holder, so an operator // can see which object to remove. DuplicateClaimReason = "DuplicateClaim" // Event-only reasons (no corresponding condition). AppliedReason = "Applied" PrunedReason = "Pruned" ResumedReason = "Resumed" NoOpReason = "NoOp" // RenderWarningReason is the Warning event a successful render's advisory // messages (catalog skew under Warn, unhandled optional traits) are // emitted under, once per distinct message when the object's warning set // changes. RenderWarningReason = "RenderWarning" )
Condition reasons.
const ( CounterReconcile = "reconcile" CounterApply = "apply" CounterPrune = "prune" CounterDrift = "drift" )
Counter field names used by IncrementCounter and ResetCounter.
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 ¶
func EnsureCounters(status *releasesv1alpha1.ModuleInstanceStatus) *releasesv1alpha1.FailureCounters
EnsureCounters initializes status.FailureCounters if nil and returns the pointer. Callers can safely use the returned pointer without nil checks.
func EnsureModulePackageCounters ¶
func EnsureModulePackageCounters(status *releasesv1alpha1.ModulePackageStatus) *releasesv1alpha1.FailureCounters
Was: EnsureReleaseCounters EnsureModulePackageCounters is the ModulePackage 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 ¶
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 MarkManagedExternally ¶
func MarkManagedExternally(obj conditions.Setter)
MarkManagedExternally sets Ready=Unknown with reason ManagedExternally and removes Reconciling and Stalled conditions. Used by the owner-skip gate for CLI-owned instances the operator deliberately does not reconcile. The static message keeps the write idempotent: re-acknowledging an already-marked instance produces an empty patch diff.
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 Generated 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 ¶
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.ModuleInstanceStatus, 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 RecordModulePackageHistory ¶
func RecordModulePackageHistory( status *releasesv1alpha1.ModulePackageStatus, entry releasesv1alpha1.HistoryEntry, )
Was: RecordReleaseHistory RecordModulePackageHistory is the ModulePackage equivalent of RecordHistory.
func RenderDigest ¶
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 ModuleInstance.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