Skip to main content
Version: v3.9.0

Pruning

The pruning manager schedules image, unused-local-model, and unused-local-Knowledge prune operations for the active container engine. It protects images referenced by controller-managed and local-deployed microservices, plus images still in use by running containers, and delegates to ContainerEngine.PruneImages() for engine-neutral behavior.

Scheduled prune does not delete persistent VOLUME data under {diskDirectory}/volumes/data/ or {diskDirectory}/volumes/shared/. Reclaim those with edgelet volume prune. See Volumes.

Code: internal/pruning/

Purpose​

  • Threshold-based prune when disk usage crosses configured limit
  • Interval-based scheduled prune (frequencyInterval)
  • Protect controller-managed and local-deployed microservice images from the configured callback (running or stopped)
  • Protect images used by running containers (managed and unmanaged) and images with a known in-use count
  • Support docker, podman, and edgelet/containerd engines via injected engine
  • Never timer-delete persistent VOLUME directories

Dependencies​

Depends onReason
configThreshold, frequency, disk directory
statusreporterPruning status fields
ContainerEngineInjected by Supervisor
Used byReason
supervisorStarted after Process Manager; engine + MS callback wired
runtimeapiOn-demand POST /v1/system/prune, POST /v1/images:prune (persistent VOLUME reclaim is POST /v1/volumes:prune)

Lifecycle​

Start​

GetInstance().Start():

  1. Reset contexts (supports supervisor restart)
  2. Start threshold worker (main ctx). Watches disk usage
  3. Start frequency worker (separate ctx). Periodic prune at frequencyInterval

Start does not run an immediate frequency prune; the first scheduled image prune waits for the ticker. Disk-threshold prune still fires when usage crosses the limit.

SetEngine(engine) and SetGetMicroservicesCallback() must be set by Supervisor before or during start.

Config update​

ChangePruningFreqInterval() cancels only the frequency worker and restarts it with the new interval. Enabling or changing pruningFrequency does not prune immediately; the next run is the ticker. Disk-threshold prune and edgelet system prune stay on-demand.

Prune order (scheduled)​

When prune runs:

  1. Optional unmanaged-container prune hook (not desired-state workloads)
  2. Image prune via engine. excluding protected microservice images (controller and local) and images still referenced by running containers
  3. Dangling model prune (unused local model rows/trees plus unreferenced OCI blobs; managed fleet names are kept)
  4. Dangling Knowledge prune (unused local Knowledge rows/trees plus unreferenced knowledge/oci-store/ blobs; managed fleet names are kept)

Persistent VOLUME directories (volumes/data/ and volumes/shared/) are not in this job. edgelet system prune volumes does not destroy them either; use edgelet volume prune / POST /v1/volumes:prune. edgelet system prune does not prune Knowledge.

On-demand API prune follows similar engine delegation paths through runtimeapi.Facade.Prune(). Model prune: POST /v1/models:prune / edgelet model prune. See Models. Knowledge prune: POST /v1/knowledge:prune / edgelet knowledge prune. See Knowledge. Controller getChanges.prune runs dangling images, unused local models, and unused local Knowledge. Not volumes.

Configuration​

KeyEffect
thresholdDisk usage percentage triggering threshold prune
frequencyIntervalSeconds between scheduled prunes (0 disables frequency worker)

Legacy top-level edgelet prune removed. Use edgelet system prune or edgelet image prune (EdgeletAPI).

External APIs​

RouteRole
POST /v1/system/pruneSystem prune modes (images / optional unmanaged containers; not persistent VOLUME data)
POST /v1/images:pruneImage-focused prune
POST /v1/models:pruneDangling model artifacts
POST /v1/knowledge:pruneDangling Knowledge artifacts
POST /v1/volumes:prunePersistent VOLUME reclaim (dry-run default): see Volumes

Observability​

  • Log module: "Edgelet Pruning Manager"
  • Status fields on StatusReporter pruning section
  • isPruning mutex prevents concurrent prune runs

Failure modes​

SymptomTypical cause
No scheduled prunefrequencyInterval=0
Needed images removedMicroservice callback not wired; local deploy or running container image missing from keep-set
Prune errorsEngine socket unavailable

Code map​

FileRole
manager.goWorkers, threshold logic, engine delegation
manager_test.goUnit tests

Related: Engines, Supervisor, Runtime API, Volumes.

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