controller

package
v1.0.0-alpha.17 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const PlatformModulePath = "opmodel.dev/platforms/cluster@v0"

PlatformModulePath is the generated platform module's own identity: the reserved, never-published platforms namespace (enhancement 0019 D6). Fixed rather than derived per generation so generated files are byte-stable across generations of the same spec, and distinct from every instance module path the render build could pair it with. Operator input to the library's generator, which owns everything else about the module including the core pin (its verified release, schema.DefaultSchemaVersion).

Variables

This section is empty.

Functions

This section is empty.

Types

type ModuleInstanceReconciler

type ModuleInstanceReconciler struct {
	client.Client
	// APIReader is an uncached reader (manager.GetAPIReader()) used for one-off
	// reads that must not provision a cache informer.
	APIReader       client.Reader
	Scheme          *runtime.Scheme
	RestConfig      *rest.Config
	ResourceManager *fluxssa.ResourceManager
	EventRecorder   events.EventRecorder
	Renderer        render.ModuleRenderer
	// DefaultServiceAccount is the fallback SA name used when a
	// ModuleInstance has an empty spec.serviceAccountName. Resolved in the
	// instance's own namespace. Empty disables the default.
	DefaultServiceAccount string
	// Kernel is the shared, long-lived library Kernel constructed once at
	// manager startup. It is the injection seam later enhancement-0001 slices
	// consume to drive the render path; this slice wires it but does not read
	// it on any reconcile path.
	Kernel *kernel.Kernel

	// MaxConcurrentRenders bounds how many ModuleInstances reconcile (and so
	// render) at once: the manager's --max-concurrent-renders, applied as
	// MaxConcurrentReconciles. Zero or negative keeps controller-runtime's
	// default of one.
	MaxConcurrentRenders int
	// contains filtered or unexported fields
}

ModuleInstanceReconciler reconciles a ModuleInstance object. Dependencies are injected via struct fields at manager setup time.

Was: ModuleReleaseReconciler

func (*ModuleInstanceReconciler) Reconcile

Reconcile runs the full ModuleInstance reconcile loop: CUE module synthesis and resolution from OCI registry, rendering, SSA apply, optional prune, and status commit.

func (*ModuleInstanceReconciler) SetupWithManager

func (r *ModuleInstanceReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

Watches:

  • ModuleInstance CRs (primary, generation-change predicate)
  • Platform (cluster singleton) — every change re-enqueues all ModuleInstances via mapPlatformToModuleInstances so releases blocked on PlatformNotReady recover promptly when the platform is generated, and instances rendered under a superseded pin set or skew policy re-render. The generation predicate lives on For() (not as a global event filter) so it does not suppress the Platform watch, whose trigger (the reconciler's status update) does not bump generation.

MaxConcurrentRenders (the manager's --max-concurrent-renders) becomes the controller's MaxConcurrentReconciles: renders share nothing (library ADR-005, ADR-007), so the only bound is memory.

type ModulePackageReconciler

type ModulePackageReconciler struct {
	client.Client
	// APIReader is an uncached reader (manager.GetAPIReader()) used for one-off
	// reads that must not provision a cache informer.
	APIReader       client.Reader
	Scheme          *runtime.Scheme
	RestConfig      *rest.Config
	ResourceManager *fluxssa.ResourceManager
	EventRecorder   events.EventRecorder

	// Fetcher downloads Flux source artifacts. Injected for testability.
	Fetcher opmsource.Fetcher

	// Renderer loads and renders the CUE package from the extracted
	// artifact directory. Injected for testability.
	Renderer render.PackageRenderer

	// DefaultServiceAccount is the fallback SA name used when a ModulePackage has
	// an empty spec.serviceAccountName. Resolved in the ModulePackage's own
	// namespace. Empty disables the default.
	DefaultServiceAccount string

	// Kernel is the shared, long-lived library Kernel constructed once at
	// manager startup. It is the injection seam later enhancement-0001 slices
	// consume to drive the render path; this slice wires it but does not read
	// it on any reconcile path.
	Kernel *kernel.Kernel

	// MaxConcurrentRenders bounds how many ModulePackages reconcile (and so
	// render) at once: the manager's --max-concurrent-renders, applied as
	// MaxConcurrentReconciles. Zero or negative keeps controller-runtime's
	// default of one.
	MaxConcurrentRenders int
	// contains filtered or unexported fields
}

Was: ReleaseReconciler ModulePackageReconciler reconciles a ModulePackage object.

func (*ModulePackageReconciler) Reconcile

func (r *ModulePackageReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile runs the full ModulePackage reconcile loop: source resolution, artifact fetch, path navigation, CUE load, kind detection, render, apply, prune, and status commit.

func (*ModulePackageReconciler) SetupWithManager

func (r *ModulePackageReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager wires the controller into mgr. Watches:

  • ModulePackage CRs (primary, generation-change predicate)
  • OCIRepository, GitRepository, Bucket (artifact-change predicate, mapped to referencing ModulePackages) — only when those Flux source CRDs are installed; see fluxSourceCRDsInstalled.
  • Platform (cluster singleton) — every change re-enqueues all ModulePackages via mapPlatformToModulePackages so packages blocked on PlatformNotReady recover promptly when the platform is generated. The generation predicate lives on For() (not as a global filter) so it does not suppress the Platform watch, whose trigger (the reconciler's status update) does not bump generation.

MaxConcurrentRenders (the manager's --max-concurrent-renders) becomes the controller's MaxConcurrentReconciles: renders share nothing (library ADR-005, ADR-007), so the only bound is memory.

type PlatformReconciler added in v0.7.0

type PlatformReconciler struct {
	client.Client
	Scheme        *runtime.Scheme
	EventRecorder events.EventRecorder

	// Kernel is the shared, long-lived library Kernel constructed once at
	// manager startup. The platform build runs on it.
	Kernel *kernel.Kernel

	// Store holds the current generated platform. Written here, read by the
	// render path.
	Store *platformstore.Store

	// Registry is the CUE registry mapping (the manager's --registry value)
	// the closure derivation resolves through; the build resolves through
	// the mapping Kernel was constructed with. Empty falls back to the
	// process CUE_REGISTRY.
	Registry string

	// Layout owns the module directories under the manager's --platform-dir.
	Layout platformstore.Layout

	// ModFiles serves published module files for the closure derivation.
	// Nil constructs one from Registry on first use; a test may inject a
	// fixture graph.
	ModFiles platformmodule.ModFileSource
}

PlatformReconciler reconciles the singleton Platform CR into a platform CUE module on the operator's own disk (enhancement 0019 D6). Per CR generation it derives the module's dependency closure from the pinned catalogs' published module files and generates the module through the library's platform-module helper (one importing #registry entry per subscription, the CR's version stamped as the expected-version tripwire, core pinned at the library's verified release), writes it under a per-generation directory, builds it through the kernel's shape-gated platform loader, and records the result together with the resolved skew policy (spec.skewPolicy, 0019 D7/D18) in the process-local store for the render path. The outcome surfaces on the CR's Ready condition: Generated, GenerateFailed or BuildFailed.

func (*PlatformReconciler) Reconcile added in v0.7.0

func (r *PlatformReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile generates and builds the platform module for the cluster-singleton Platform and records the outcome on its status. It reconciles only the object named "cluster"; any other name is ignored without error. On delete it clears the store (workloads are untouched: §8.4 freeze-don't-teardown); the module directories are left for the next generation's prune or the next manager start.

func (*PlatformReconciler) SetupWithManager added in v0.7.0

func (r *PlatformReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager wires the controller into mgr, watching the Platform singleton with a generation-change predicate.

Jump to

Keyboard shortcuts

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