Documentation
¶
Overview ¶
Package resolver turns runtime intent into a plan: it maps ClusterRuntime fields onto AICR recipe and bundle arguments, computes the resolution inputDigest, and assembles the plan from a rendered bundle. It performs no Kubernetes I/O; the resolver controller drives it.
Index ¶
- Constants
- func BaseSpec(spec *v1alpha1.ClusterRuntimeSpec) *v1alpha1.ClusterRuntimeSpec
- func BundleValues(b *registry.Bundle, declaredVersion string) (map[string]map[string]any, error)
- func CheckNamespaces(p *plan.Document, allowed []string) error
- func CheckOverridePaths(overrides []v1alpha1.Override, base, chartDefaults map[string]map[string]any) error
- func RecipeArgs(spec *v1alpha1.ClusterRuntimeSpec, derived map[string]string, ...) []string
- func RenderArgs(spec *v1alpha1.ClusterRuntimeSpec, recipeURI, outputRef string, plainHTTP bool) ([]string, error)
- func RenderFlags(spec *v1alpha1.ClusterRuntimeSpec) ([]string, error)
- func ShortDigest(digest string) string
- func SnapshotArgs(p *v1alpha1.Placement, ...) ([]string, error)
- func ValueOverrides(spec *v1alpha1.ClusterRuntimeSpec) bool
- type BuildInput
- type Built
- type ChartDelivery
- type Inputs
Constants ¶
const ( ReasonInvalidOverride = "InvalidOverride" ReasonInvalidPlacement = "InvalidPlacement" )
Condition reasons for spec fields AICR cannot express.
const MaxOverrideValueBytes = 4 << 10
MaxOverrideValueBytes bounds one encoded override value.
const ReasonChartSourceUnsupported = "ChartSourceUnsupported"
ReasonChartSourceUnsupported marks a release whose rendered directory holds neither an upstream chart reference nor a local chart.
const ReasonNamespaceNotAllowed = "NamespaceNotAllowed"
ReasonNamespaceNotAllowed marks a plan that renders a release into a namespace outside the installation's component namespaces.
const ReasonOverridePathUnknown = "OverridePathUnknown"
ReasonOverridePathUnknown marks an override whose path neither the base render nor the chart's defaults know: a likely typo.
Variables ¶
This section is empty.
Functions ¶
func BaseSpec ¶
func BaseSpec(spec *v1alpha1.ClusterRuntimeSpec) *v1alpha1.ClusterRuntimeSpec
BaseSpec is the base render's input: the spec with its component toggles but without value overrides, so the same components render with the values AICR alone produces.
func BundleValues ¶
BundleValues returns each component's merged values in a rendered bundle: those of its primary release.
func CheckNamespaces ¶
CheckNamespaces refuses a plan whose releases target namespaces outside allowed, before anything reaches the engine. The engine's admission policy and project would refuse the write anyway; refusing the plan stalls at resolution and names every release instead of failing a rollout step.
func CheckOverridePaths ¶
func CheckOverridePaths(overrides []v1alpha1.Override, base, chartDefaults map[string]map[string]any) error
CheckOverridePaths rejects a value override, unless it is additive, whose path exists neither in the base render's values for its component nor in its chart's defaults. AICR creates missing intermediate maps, so without this check a mistyped path renders silently.
func RecipeArgs ¶
func RecipeArgs(spec *v1alpha1.ClusterRuntimeSpec, derived map[string]string, snapshotURI, outputURI string) []string
RecipeArgs returns the recipe Job arguments: the runtime's intent, platform and profile, for service, accelerator and OS the declared criteria or else the snapshot's, and its recipe configuration, with JSON output to outputURI. Stating the snapshot's dimensions keeps AICR from relaxing one no recipe covers (at v1.0.0, os=amazonlinux becomes any) into a generic recipe: AICR fails instead with INVALID_REQUEST.
func RenderArgs ¶
func RenderArgs(spec *v1alpha1.ClusterRuntimeSpec, recipeURI, outputRef string, plainHTTP bool) ([]string, error)
RenderArgs returns the bundle Job arguments: the recipe, the render flags and a push to outputRef.
func RenderFlags ¶
func RenderFlags(spec *v1alpha1.ClusterRuntimeSpec) ([]string, error)
RenderFlags returns the `aicr bundle` flags that shape a render: the engine-neutral Helm layout with readiness gates and the runtime's placement and overrides. The plan records them, so the AICR CLI can render the same bundle from the plan's recipe (`kubectl aicr reproduce`).
func ShortDigest ¶
ShortDigest is the first 16 hex characters of a digest, the form labels carry.
func SnapshotArgs ¶
func SnapshotArgs(p *v1alpha1.Placement, namespace, agentAccount, image, requests, outputURI string) ([]string, error)
SnapshotArgs returns the snapshot Job arguments: AICR's agent runs in exact-ServiceAccount mode, pinned to the accelerated group's selector and tolerations, because AICR's default selector matches no node before GPU feature discovery runs. requests, when set, overrides the agent's resource requests, for test clusters.
func ValueOverrides ¶
func ValueOverrides(spec *v1alpha1.ClusterRuntimeSpec) bool
ValueOverrides reports whether a spec overrides values, not only component toggles; only then does resolution need a base render.
Types ¶
type BuildInput ¶
type BuildInput struct {
Bundle *registry.Bundle
// BundleURI is the bundle's pinned reference, recorded as provenance.
BundleURI string
// DeclaredVersion is the installation's aicr.version.
DeclaredVersion string
RuntimeUID string
Engine plan.Engine
EnginePolicy string
// Charts is the runtime registry repository mirrored charts go below.
Charts registry.Repository
// EarlierCharts are the charts of this runtime's earlier resolved plans,
// which Build reuses, with no upstream request, for a release pinning the
// same upstream chart.
EarlierCharts []plan.Chart
// Wrappers is the repository wrapper charts go below, one per release.
Wrappers registry.Repository
InputDigest string
Provenance plan.Provenance
// Recipe identifies the recipe Job's RecipeResult and its ConfigMap.
Recipe *plan.Recipe
}
BuildInput is everything Build needs beyond the bundle.
type Built ¶
type Built struct {
Plan *plan.Document
Values []*plan.Content
ValidationRecipe *plan.Content
// ChartDefaults are each component's chart default values, from its
// primary release's archive, for the override path check.
ChartDefaults map[string]map[string]any
}
Built is an assembled plan and the content it references: each release's values and, with a recipe, the bundle's recipe that validation reads.
func Build ¶
func Build(ctx context.Context, delivery ChartDelivery, in *BuildInput) (*Built, error)
Build assembles the plan for a rendered bundle: releases in AICR's order with inferred phases, dependency edges from the bundle's own recipe, merged values, and each chart mirrored into the runtime registry and pinned by digest. It fails closed: any contract mismatch is an error.
type ChartDelivery ¶
type ChartDelivery interface {
MirrorHTTPChart(ctx context.Context, up registry.UpstreamChart, target registry.Repository) (*registry.MirroredChart, error)
MirrorOCIChart(ctx context.Context, up registry.UpstreamChart, target registry.Repository) (*registry.MirroredChart, error)
ReuseChart(ctx context.Context, r registry.Repository, version, digest string) (*registry.MirroredChart, error)
PushWrapper(ctx context.Context, target registry.Repository, files map[string][]byte) (*registry.MirroredChart, error)
}
ChartDelivery serves every chart from the runtime registry. It mirrors an upstream chart with its digests verified, or reuses one an earlier plan mirrored, and packages a local chart deterministically.
type Inputs ¶
type Inputs struct {
RuntimeUID string `json:"runtimeUID"`
Intent string `json:"intent"`
Platform string `json:"platform,omitempty"`
Profile string `json:"profile,omitempty"`
Criteria *v1alpha1.DeclaredCriteria `json:"criteria,omitempty"`
Placement v1alpha1.Placement `json:"placement"`
Configuration *v1alpha1.RecipeConfiguration `json:"configuration,omitempty"`
Overrides []v1alpha1.Override `json:"overrides,omitempty"`
AICRImage string `json:"aicrImage"`
AICRVersion string `json:"aicrVersion"`
OperatorVersion string `json:"operatorVersion"`
Engine plan.Engine `json:"engine"`
EnginePolicy string `json:"enginePolicy"`
Registry string `json:"registry"`
// SnapshotDigest is the AICR snapshot the recipe was resolved from;
// empty without discovery.
SnapshotDigest string `json:"snapshotDigest,omitempty"`
}
Inputs are everything a resolution depends on. Their digest, inputDigest, is provenance: it decides whether to resolve again, never whether to roll out; desiredStateDigest decides that. Optional fields are omitted when unset, so a runtime that leaves a newer field unset keeps the inputDigest it had before the field existed.