Skip to main content
Version: v3.9.0

Supervisor

The Supervisor is the daemon orchestrator. It owns process lifecycle for all runtime modules, wires the container engine into Process Manager, handles config reload (SIGHUP), graceful shutdown, and embedded containerd watchdog behavior on Linux.

Code: internal/supervisor/

Purpose​

  • Open and close the SQLite store at daemon start/stop
  • Start modules in a fixed dependency order and publish status via StatusReporter
  • Create and inject the ContainerEngine implementation based on containerEngine config
  • Register config reload and GPS config callbacks
  • Monitor EdgeletAPI listener health
  • Coordinate daemon restart requests (embedded containerd exit, engine recovery)

Dependencies​

Depends onReason
storeMust open DB before any module reads/writes
configActive config.yaml and reload callbacks
Prestarted containerdWhen containerEngine=edgelet, bootstrap starts containerd before Supervisor
Used byReason
cmd/edgelet daemon entryMain runtime bootstrap
EdgeletAPIPOST /v1/system/reload, POST /v1/system/stop invoke Supervisor paths

Lifecycle​

Start​

Entry: (*Supervisor).Start() in supervisor.go.

  1. store.Open(diskDirectory). Runs migrations, integrity check
  2. Seed default local registries if missing
  3. Start StatusReporter; set daemon STARTING
  4. Start Network → ResourceConsumption → FieldAgent
  5. Instantiate container engine (edgelet, docker, or podman)
    • External engines: retry with degraded mode + background recovery if socket unavailable
    • Edgelet engine: requires prestarted containerdSvc; starts socket watchdog goroutine
  6. processmanager.Start(engine, fieldAgent)
  7. Optional HealthcheckRunner when engine is edgelet
  8. GPS → EdgeletAPI (waits up to 15s for listeners)
  9. Pruning Manager (engine + microservice image list wired)
  10. Edge Guard Manager

Host hardware/USB inventory posting is not started. Edge Guard remains. 11. Set daemon RUNNING (or WARNING if external engine degraded)

Stop​

(*Supervisor).Stop() stops modules in reverse order, drains Process Manager tasks, stops EdgeletAPI, and calls store.Close() last (WAL truncate checkpoint).

Config reload​

ReloadConfig() is registered on config.SetReloadCallback. Successful reload propagates to Field Agent (Update()), engine URL changes, DNS resolver, and modules that subscribe to config change events. Failed reload leaves prior on-disk config authoritative.

Configuration​

Key config.yaml fields affecting Supervisor:

KeyEffect
containerEngineedgelet, docker, or podman
containerEngineUrlEngine socket/URL
diskDirectorySQLite path root (edgelet.db)
leaveRunningOnControlStopShutdown policy for workloads

With the embedded engine and a healthy event stream, an idle workload is not inspected every 5 seconds. If the event stream is down, inspection returns to every 5 seconds until the stream is healthy. Docker and Podman still check running-or-not every 5 seconds. A full compare runs about once a minute, and CPU and memory on status refresh about every 10 seconds. Those intervals are built in. See Process manager.

See Installation for install paths and Deployment for systemd unit edgelet.service.

Data and persistence​

Supervisor does not own tables directly. It ensures store is open and passes singletons (fieldagent, processmanager, edgeletapi) to each other:

  • Field Agent implements MicroserviceManagerInterface for Process Manager
  • Process Manager callbacks for local/control-plane deploy are registered during wiring

External APIs​

Supervisor does not expose HTTP routes. Operator-facing control:

EdgeletAPI routeAction
POST /v1/system/reloadConfig reload
POST /v1/system/stopGraceful daemon stop
GET /v1/system/statusModule status array

Observability​

  • Log module name: "Supervisor"
  • SupervisorStatus in status POST: daemonStatus, modulesStatus[], daemonLastStart, operationDuration, warningMessage
  • EdgeletAPI monitor ticker (10s): logs if local API unhealthy

Failure modes​

SymptomTypical cause
Daemon exits on startDB migration failure, containerd not prestarted for edgelet engine
WARNING daemon statusDocker/Podman socket unavailable after retry budget
Immediate restart (control edgelet.service)Embedded containerd unexpected exit while the supervisor owns the child (fail-fast handler)
Reload rejectedConfig validation failed; Field Agent skips fog config POST

See Troubleshooting.

Code map​

FileRole
supervisor.goStart/stop, module wiring, API monitor
engine_lifecycle.goEngine init, degraded recovery, containerd handlers
module.goModule interface (Start, Stop, GetName, GetModuleIndex)

Related modules: Field agent, Process manager, Edgelet API module, Store.

Group 3See anything wrong with the document? Help us improve it!