operator

package
v1.74.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	Name       string
	Namespace  string
	Definition apps.Definition
	Settings   map[string]interface{}
}

type Operator

type Operator struct {
	// contains filtered or unexported fields
}

func New

func New(moduleManager moduleManager, dc dependency.Container, logger *log.Logger) (*Operator, error)

New creates and initializes a new Operator instance with all subsystems.

Initialization order is important:

  1. Queue and schedule services (independent)
  2. NELM service (requires its own client and cache)
  3. Object patcher (for hook-driven resource modifications)
  4. Kubernetes events manager (watches cluster resources)
  5. Package manager (depends on all above services)
  6. Event handler (coordinates everything, starts immediately)

Each Kubernetes integration gets its own client with specific rate limits:

  • Object patcher: Higher QPS for batch patching operations
  • Kube events: Standard QPS for resource watching
  • NELM monitor: Tuned QPS for Helm resource monitoring

The event handler starts immediately to begin processing events.

func (*Operator) Dump

func (o *Operator) Dump() []byte

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 (*Operator) Remove

func (o *Operator) Remove(ctx context.Context, namespace, instance string)

Remove uninstalls a package and cleans up all associated resources.

Cleanup sequence:

  1. Disable package hooks and stop monitoring (taskdisable)
  2. Clean up custom queues created by package hooks
  3. Uninstall package resources (taskuninstall)
  4. Remove package's main queue

func (*Operator) Scheduler

func (o *Operator) Scheduler() *schedule.Scheduler

Scheduler return the scheduler for external access

func (*Operator) Stop

func (o *Operator) Stop()

Stop performs graceful shutdown of all operator subsystems.

Shutdown order ensures safe termination:

  1. Stop NELM monitors (cleanup resource monitoring)
  2. Pause Kubernetes event handling (no new resource events)
  3. Stop schedule manager (no new cron triggers)
  4. Stop event handler (no new task generation)
  5. 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 (*Operator) Update

func (o *Operator) Update(ctx context.Context, repo *v1alpha1.PackageRepository, inst Instance)

Update installs a new package or updates an existing package's configuration.

For new packages (Pending phase):

  1. Install package from repository (download and extract)
  2. Load package hooks and configuration into memory
  3. Register with scheduler for enable/disable lifecycle management

For existing packages:

  • If settings changed, apply new settings and trigger hook re-execution

Cancels any in-flight tasks from previous Update calls via context renewal.

type Package

type Package struct {
	// contains filtered or unexported fields
}

type Phase

type Phase string
const (
	Pending Phase = "Pending" // wait for installing and loading
	Loaded  Phase = "Loaded"  // wait for startup
	Running Phase = "Running"
)

type Status

type Status struct {
	Phase Phase `json:"phase" yaml:"phase"`
}

Directories

Path Synopsis
Package eventhandler provides event handling for Kubernetes and schedule events.
Package eventhandler provides event handling for Kubernetes and schedule events.
tasks
run

Jump to

Keyboard shortcuts

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