Documentation
¶
Index ¶
- Constants
- type App
- type Module
- type Runtime
- func (r *Runtime) BuildKubeTasks(ctx context.Context, kubeEvent shkubetypes.KubeEvent) map[string][]queue.Task
- func (r *Runtime) BuildScheduleTasks(ctx context.Context, crontab string) map[string][]queue.Task
- func (r *Runtime) CheckConstraints(constraints schedule.Constraints) error
- func (r *Runtime) Dump() []byte
- func (r *Runtime) DumpByName(name string) []byte
- func (r *Runtime) RemoveApp(namespace, instance string)
- func (r *Runtime) RemoveModule(name string)
- func (r *Runtime) Run()
- func (r *Runtime) Scheduler() *schedule.Scheduler
- func (r *Runtime) Status() *status.Service
- func (r *Runtime) Stop()
- func (r *Runtime) UpdateApp(repo registry.Remote, app App)
- func (r *Runtime) UpdateModule(repo registry.Remote, module Module)
- func (r *Runtime) ValidateSettings(ctx context.Context, name string, settings addonutils.Values) (settingscheck.Result, error)
Constants ¶
const (
ConditionReasonLoadFailed status.ConditionReason = "LoadFailed"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Name string
Namespace string
Definition apps.Definition
Settings addonutils.Values
}
App represents an application instance as received from the Application controller. It carries the user-specified package identity, version constraints, and settings.
type Module ¶
type Module struct {
Name string
Definition modules.Definition
Settings addonutils.Values
}
Module represents a module instance as received from the module controller. Unlike App, modules always run in the d8-system namespace.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime orchestrates the full lifecycle of application packages: discovery, installation, hook execution, Helm release management, and removal.
State is split across three structures, all protected by r.mu:
- packages (lifecycle.Store): contexts and pending settings — the cancellation and change-detection layer, type-agnostic
- apps: loaded Application instances, keyed by name
- modules: loaded Module instances, keyed by name
Task execution is delegated to queue.Service (one queue per package), and cluster coordination to the scheduler, NELM, and hook event systems.
func New ¶
func New(cli kclient.Client, moduleManager moduleManagerI, dc dependency.Container, logger *log.Logger) (*Runtime, error)
New creates and initializes a Runtime with all subsystems wired together. Blocks until the NELM cache completes its initial sync.
func (*Runtime) BuildKubeTasks ¶
func (r *Runtime) BuildKubeTasks(ctx context.Context, kubeEvent shkubetypes.KubeEvent) map[string][]queue.Task
BuildKubeTasks converts a Kubernetes event into executable tasks for all matching hooks.
For each package:
- Find hooks that are bound to Kubernetes events
- Check if the hook can handle this specific event (filtering)
- Generate tasks for matching hooks using the provided builder
Returns a map of queue names to tasks, allowing different hooks to be routed to different queues (e.g., priority queues, sequential queues).
func (*Runtime) BuildScheduleTasks ¶
BuildScheduleTasks converts a schedule (cron) event into executable tasks for all matching hooks.
For each package:
- Find hooks that are bound to schedule events
- Check if the hook's schedule matches the triggered crontab
- Generate tasks for matching hooks using the provided builder
Returns a map of queue names to tasks, allowing hooks to specify their execution queue.
func (*Runtime) CheckConstraints ¶ added in v1.76.0
func (r *Runtime) CheckConstraints(constraints schedule.Constraints) error
CheckConstraints checks constraints in scheduler
func (*Runtime) Dump ¶
Dump returns a YAML snapshot of all packages and their current state.
Includes for each package:
- Status: Current phase (Pending/Loaded/Running)
- State: Scheduler state (enabled/disabled with reason)
- Info: Instance name and namespace, current package configuration values and hooks
Used for debugging and introspection of operator internal state. Skips packages that have been removed from the manager.
func (*Runtime) DumpByName ¶ added in v1.76.0
DumpByName returns a YAML snapshot of a single package by name. Checks apps first, then modules. Returns an empty dump if not found.
func (*Runtime) RemoveApp ¶
RemoveApp removes an application and cancels all its running operations.
After the uninstall task succeeds, a cleanup goroutine removes the Store entry and stops the queue. The goroutine is necessary because queueService.Remove stops the queue — calling it synchronously from within the queue's own processing loop would deadlock on WaitGroup.
Store.Delete has a state guard: if UpdateApp re-created the package between uninstall and cleanup, Delete is a no-op (version != "").
func (*Runtime) RemoveModule ¶
RemoveModule removes a module and cancels all its running operations. After uninstall, a cleanup goroutine removes the Store entry and stops the queue. See RemoveApp for detailed rationale on the async cleanup pattern.
func (*Runtime) Run ¶ added in v1.76.0
func (r *Runtime) Run()
Run starts the scheduler event loop in a background goroutine. It listens for schedule and disable events from the scheduler and dispatches them to the appropriate handler, driving the enable/disable lifecycle for all packages.
func (*Runtime) Stop ¶
func (r *Runtime) Stop()
Stop performs graceful shutdown of all operator subsystems.
Shutdown order ensures safe termination:
- Stop NELM monitors (cleanup resource monitoring)
- Pause Kubernetes event handling (no new resource events)
- Stop schedule manager (no new cron triggers)
- Stop event handler (no new task generation)
- Stop queue service (no new task processing)
This order prevents new work from entering the system while allowing in-flight operations to complete gracefully where possible.
func (*Runtime) UpdateApp ¶
UpdateApp handles application creation and version changes from the Application controller.
Flow:
- NeedUpdate fast-path: skip if version and settings checksum are unchanged
- Store.Update: if version changed → new root context, enqueue full pipeline (Disable → Download → Install → Load); if only settings changed → nil context, trigger Reschedule so the scheduler re-runs Configure → Startup → Run
- CheckConstraints: validate Kubernetes/Deckhouse version requirements before enqueuing
Settings are applied lazily: the scheduler's schedulePackage reads pending settings from the Store via GetPendingSettings when the package is scheduled for startup.
func (*Runtime) UpdateModule ¶
UpdateModule handles module creation and version changes from the module controller.
Flow mirrors UpdateApp: version changes enqueue the full pipeline (Disable → Download → Install → Load), settings-only changes trigger Reschedule to re-apply settings through the scheduler's schedule pipeline. See UpdateApp for detailed flow documentation.
func (*Runtime) ValidateSettings ¶
func (r *Runtime) ValidateSettings(ctx context.Context, name string, settings addonutils.Values) (settingscheck.Result, error)
ValidateSettings checks settings against the package's OpenAPI schema. Returns valid if the package is not loaded yet (settings validated on load).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package debug provides a Unix socket-based HTTP server and client for runtime debugging and inspection.
|
Package debug provides a Unix socket-based HTTP server and client for runtime debugging and inspection. |
|
Package hookevent provides event handling for Kubernetes and schedule events.
|
Package hookevent provides event handling for Kubernetes and schedule events. |
|
tasks
|
|