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) Dump() []byte
- func (r *Runtime) RemoveApp(namespace, instance string)
- func (r *Runtime) RemoveModule(name string)
- 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 ( ConditionReasonValidationFailed status.ConditionReason = "ValidationFailed" ConditionReasonApplySettings status.ConditionReason = "ApplySettings" 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.
It delegates package state to lifecycle.Store (the single source of truth), task execution to queue.Service (one queue per package), and cluster coordination to the scheduler, NELM, and hook event systems.
All package mutations flow through lifecycle.Store callbacks, ensuring atomicity between state changes and task enqueueing.
func New ¶
func New(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) 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) 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) 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 updates (version changes and settings changes). Version changes and settings changes are handled independently with separate contexts.
func (*Runtime) UpdateModule ¶
UpdateModule handles module updates (version changes and settings changes). On version change: validates requirements, then queues download → install → load. On settings change: queues apply-settings → run.
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
|
|