Documentation
¶
Overview ¶
Package controller hosts the resolver, rollout and credentials controllers as thin adapters over the functional packages.
Index ¶
Constants ¶
const ( // ReasonOrphanedObjectsPresent: engine objects of another runtime UID // exist and spec.adoption does not name it; the runtime never adopts // silently and rolls nothing out meanwhile. ReasonOrphanedObjectsPresent = "OrphanedObjectsPresent" // ReasonAdoptionBlocked: the named runtime's objects do not rebuild to a // plan, or were edited out of band. ReasonAdoptionBlocked = "AdoptionBlocked" )
Re-adoption reasons.
const ( // ReasonAssessing: AICR's upgrade-check runs before the rollout exists. ReasonAssessing = "Assessing" // ReasonTransitionBlocked: a blocked verdict or an identity change needs // a separately qualified migration. ReasonTransitionBlocked = "TransitionBlocked" )
Reasons for transitions the rollout controller does not start.
const ( ReasonResolved = "Resolved" ReasonResolving = "Resolving" )
Resolved condition reasons beyond the error-specific ones.
const ( ReasonRolledOut = "RolledOut" ReasonRollingOut = "RollingOut" ReasonStabilizing = "Stabilizing" ReasonAwaitingApproval = "AwaitingApproval" // ReasonAwaitingAcknowledgement: a manual release is applied and its // post-apply steps await the approver's acknowledgement. ReasonAwaitingAcknowledgement = "AwaitingAcknowledgement" ReasonActionTimeout = "ActionTimeout" ReasonValidationMissing = "ValidationUnavailable" ReasonNotReady = "NotReady" ReasonNoActivePlan = "NoActivePlan" ReasonHealthy = "Healthy" ReasonEngineAvailable = "EngineAvailable" ReasonPaused = "Paused" // ReasonEngineSuspended: spec.suspendEngine stopped automated engine // syncs; no step starts and no drift is repaired. ReasonEngineSuspended = "EngineSuspended" // ReasonPlanMissing: the active plan ConfigMap is gone and the live // engine objects do not rebuild to it. ReasonPlanMissing = "PlanMissing" // ReasonPlanOfAnotherRuntime: the target plan records another runtime's // UID, as an earlier runtime's plan does; it is never rolled out. ReasonPlanOfAnotherRuntime = "PlanOfAnotherRuntime" // ReasonPlanWithoutRecipe: the target plan was rebuilt from engine // objects and records no recipe, so deployment validation cannot run // against it; it is not rolled out while validation is required. ReasonPlanWithoutRecipe = "PlanWithoutRecipe" // ReasonMovedReleaseMissing: the Application of a release that a rollout // which did not succeed may have moved is gone; repairing it from the // active plan would roll it back without approval. ReasonMovedReleaseMissing = "MovedReleaseMissing" // ReasonEngineSuspensionRefused: the API server refused for good to // change an Application's automated sync for spec.suspendEngine, so the // engine is not suspended or resumed as declared. ReasonEngineSuspensionRefused = "EngineSuspensionRefused" )
Runtime and rollout condition reasons.
const ( // EventFieldOwnershipOverridden: an Ensure forced fields that other // managers had changed back to the plan. EventFieldOwnershipOverridden = "FieldOwnershipOverridden" // EventApplicationRecreated: an active release's Application was deleted // by hand and written again; its resources were never deleted. EventApplicationRecreated = "ApplicationRecreated" // EventReconcileFailed, on the runtime: a reconcile ended in an error it // retries, named so an outage is visible without logs. EventReconcileFailed = "ReconcileFailed" // EventAICRRunFailed, on the runtime: an AICR run failed, with its // stage, run, retry class and error. EventAICRRunFailed = "AICRRunFailed" // EventStalled, on the runtime: it turned Stalled, or stalled for // another reason. EventStalled = "Stalled" // EventStepStarted, on the rollout: a release's step started. EventStepStarted = "StepStarted" // EventStepWaiting, on the rollout: a step in progress waits on another // reason than it last reported. EventStepWaiting = "StepWaiting" // EventStepFinished, on the rollout: a step ended, with its outcome, its // duration and what it last waited on; a warning when it failed. EventStepFinished = "StepFinished" // EventEngineSuspensionRefused, on the runtime: the API server refused // for good to change an Application's automated sync. EventEngineSuspensionRefused = ReasonEngineSuspensionRefused )
Event reasons the rollout controller records on engine objects and the runtime.
const ( // ReasonValidating: the rollout's steps are ready and AICR's deployment // validation runs. ReasonValidating = "Validating" // ReasonValidationDisabled: the runtime is rolled out and ready, with // deployment validation disabled. ReasonValidationDisabled = "ValidationDisabled" )
Deployment validation reasons.
const ReasonInventoryDrift = "InventoryDrift"
ReasonInventoryDrift reports that the live engine objects changed out of band since the rollout was created and approved.
const ReasonRegistryCredentialsStale = "RegistryCredentialsStale"
ReasonRegistryCredentialsStale reports that the engine's registry token has expired or is about to.
const ReasonRemovalFailed = "RemovalFailed"
ReasonRemovalFailed reports that the removal rollout of a runtime deleted with deletionPolicy Delete ended without removing everything; the cleanup finalizer stays until a retry succeeds.
const ResolverFieldManager = "aicr-operator-resolver"
ResolverFieldManager owns the resolver's status fields.
const RolloutFieldManager = "aicr-operator-rollout"
RolloutFieldManager owns the rollout controller's runtime status fields.
Variables ¶
This section is empty.
Functions ¶
func CacheOptions ¶
CacheOptions scopes the manager's caches to what the operator's RBAC lets it read: its ConfigMaps in the operator namespace, its AICR Jobs in the Job namespaces, and Nodes stripped by the discovery transform. The engine's objects have their own cache (engineCacheOptions). Everything else is read uncached.
func Collectors ¶
func Collectors() []prometheus.Collector
Collectors are the controllers' metrics, for the manager's registry, with every known label value already at zero, so a rate reads zero rather than nothing before the first event.
Types ¶
type Engine ¶
type Engine interface {
Capabilities(ctx context.Context) error
Ensure(ctx context.Context, p *plan.Document, r *plan.Release, valuesJSON []byte) (*argocd.Ensured, error)
Verify(ctx context.Context, p *plan.Document, r *plan.Release, valuesJSON []byte) error
// Refresh asks the engine to compare a release's object now.
Refresh(ctx context.Context, r *plan.Release) error
Observe(ctx context.Context, p *plan.Document, r *plan.Release, valuesJSON []byte, since time.Time, verify bool) (argocd.Observation, error)
Remove(ctx context.Context, runtimeUID, name, uid, rollout string) error
Retired(ctx context.Context, name, uid string) (argocd.Observation, error)
Inventory(ctx context.Context, runtimeUID string) ([]argocd.InventoryItem, error)
// RebuildLive rebuilds the plan from the Applications of runtimeUID and
// of the runtimes named in also.
RebuildLive(ctx context.Context, runtimeUID string, also ...string) (*plan.Document, []*plan.Content, error)
Suspend(ctx context.Context, runtimeUID string, suspended bool) ([]string, error)
Orphan(ctx context.Context, runtimeUID string) ([]string, error)
Foreign(ctx context.Context, runtimeUID string) (map[string][]string, error)
Adopt(ctx context.Context, fromUID, toUID, name, uid string) error
}
Engine is the adapter contract the rollout controller drives.
type EvidenceRegistry ¶
type EvidenceRegistry interface {
Resolve(ctx context.Context, r registry.Repository, tag string) (string, error)
PullBundle(ctx context.Context, r registry.Repository, digest string) (*registry.Bundle, error)
SigstoreBundles(ctx context.Context, r registry.Repository, subject string) ([][]byte, error)
Describe(ctx context.Context, r registry.Repository, digest string) (ocispec.Descriptor, error)
PushStatement(ctx context.Context, r registry.Repository, tag, artifactType string, statement []byte, subject ocispec.Descriptor) (string, error)
}
EvidenceRegistry is what deployment validation needs from the runtime registry: AICR's evidence by run tag with the signatures attached to it, and the operator's binding pushed next to it.
type OperatorImage ¶
type OperatorImage struct {
Reader client.Reader
Namespace string
Pod string
Container string
// contains filtered or unexported fields
}
OperatorImage reads the operator's own image from its pod, for evidence: the reference the pod spec names and its digest. A reference pinned by digest is its own digest, which the kubelet resolved by content; a tag is resolved through the image ID the kubelet reports, which for an image it loaded rather than pulled can name a loader's wrapper. The first complete answer is kept for the process's life.
type Registry ¶
type Registry interface {
Resolve(ctx context.Context, r registry.Repository, tag string) (string, error)
PullBundle(ctx context.Context, r registry.Repository, digest string) (*registry.Bundle, error)
resolver.ChartDelivery
}
Registry is what the resolver needs from the runtime registry.
type RepoCredsRefresher ¶
type RepoCredsRefresher struct {
Client client.Client
Reader client.Reader
Provider *registry.ECRProvider
Namespace string
Name string
Interval time.Duration
// RetryBackoff is the first wait after a failed refresh; zero means
// defaults.RepoCredsRetryBackoff.
RetryBackoff time.Duration
Now func() time.Time
// contains filtered or unexported fields
}
RepoCredsRefresher keeps the Argo CD repo-creds Secret's ECR token current: at start, so an outage longer than a token's lifetime recovers on restart, and then every interval. It reads the Secret by name through the uncached reader, never watches Secrets, and runs only on the leader.
func (*RepoCredsRefresher) Check ¶
func (r *RepoCredsRefresher) Check(ctx context.Context) (warning string, err error)
Check returns an error with reason RegistryCredentialsStale when the repo-creds Secret is missing, carries no token expiry, or holds a token expiring within defaults.RepoCredsStaleAfter. An error reading the Secret has no reason, since it says nothing about the token. While the token is current but minting a new one fails, err is nil and warning names the failure and whether the operator still holds a token it can use.
func (*RepoCredsRefresher) Collectors ¶
func (r *RepoCredsRefresher) Collectors() []prometheus.Collector
Collectors returns gauges of the token's expiry and last refresh, and a counter of failed mints. Each gauge is a Unix time, 0 until known, so an alert on its age reads it as long ago, never as fresh.
func (*RepoCredsRefresher) Refresh ¶
func (r *RepoCredsRefresher) Refresh(ctx context.Context) error
Refresh writes a current token into the repo-creds Secret and records its expiry on the Secret, so the record survives an operator restart.
func (*RepoCredsRefresher) Start ¶
func (r *RepoCredsRefresher) Start(ctx context.Context) error
Start refreshes until ctx ends: every interval after a success, and with backoff after a failure, so one failed mint never leaves the engine without credentials until the next interval. Staleness is reported through Check, not by stopping the manager.
type ResolverReconciler ¶
type ResolverReconciler struct {
Client client.Client
Reader client.Reader
Config *config.Config
Registry Registry
OperatorVersion string
// Credentials supplies pushing Jobs' registry credentials; nil is an
// anonymous registry.
Credentials registry.Provider
// Now is the clock for the snapshot refresh period; nil is time.Now.
Now func() time.Time
// Events records failed AICR runs on the runtime; nil records none.
Events events.EventRecorder
// contains filtered or unexported fields
}
ResolverReconciler turns the ClusterRuntime into a candidate plan through AICR recipe and render Jobs. It writes plans and its own status fields, never engine objects. Recipe and render outputs stay owned by their Jobs until the plan exists, so a restart resumes at the first stage whose output is missing.
func (*ResolverReconciler) SetupWithManager ¶
func (r *ResolverReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager registers the resolver: the runtime, its AICR Jobs and, with discovery, the Nodes that make up the placement groups.
type RolloutReconciler ¶
type RolloutReconciler struct {
Client client.Client
Reader client.Reader
Config *config.Config
Engine Engine
Now func() time.Time
// Credentials, when set, checks that the engine's registry credentials
// are current (aws provider), returning a warning that does not stop
// rollouts.
Credentials interface {
Check(context.Context) (string, error)
}
// Events, when set, records Events on engine objects.
Events events.EventRecorder
// Registry holds deployment validation evidence.
Registry EvidenceRegistry
// JobCredentials supplies the validation Job's registry credentials;
// nil is an anonymous registry.
JobCredentials registry.Provider
// Operator reports the operator's own image and the digest it runs as,
// for the evidence; nil records none.
Operator func(context.Context) (evidence.Image, error)
// contains filtered or unexported fields
}
RolloutReconciler moves the runtime from its active plan to its target plan through RuntimeRollouts, one engine mutation per step. It owns every runtime condition except Resolved.
func (*RolloutReconciler) SetupWithManager ¶
func (r *RolloutReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager registers the rollout controller: the runtime and its rollouts, and the engine's objects once their kind is served: a missing engine CRD never stops the manager, and the controller re-observes on a resync until the watch exists.