Idle shutdown: periodic sweep job to stop idle containers

Aperta
#527 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend, devops

Direzione di ricerca

Start by reading bin/create-container.js and the existing job-runner and JobStatus paths to see how scripts are enqueued and their output is stored. Then inspect the container model, provider stop APIs, and systemd files under create-a-container/contrib/systemd/; the issue also depends on the idleTime resource request. Done means an hourly job enqueues the sweep, applies the idle and grace-period rules, records stop state and per-owner results, and supports --dry-run while continuing after failures.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement idle-shutdown

Part of the Idle Container Shutdown epic. Depends on the idleTime resource request.

Summary

A job script (like bin/create-container.js) that finds containers idle longer than their effective idleTime and stops them, run periodically via a systemd timer.

Idle rule

A container is idle when now - (max(service.lastAccessedAt) ?? container.createdAt) > idleTime hours.

  • idleTime = 0 → skip.
  • Grace period after creation: never stop a container younger than its idleTime, even if never accessed.
  • Activity is proxy access only (HTTP + TCP/UDP services via the nginx accounting module). SSH, direct-IP, SRV-only, and service-less containers will appear idle; this is intentional and must be documented (owners can request idleTime = 0).

Stop behavior

  • Keep it simple: call the node provider's existing stop API (stopLxc for Proxmox/Docker/dummy).
  • Timeouts or failures are logged and skipped; the sweep continues with the next container.
  • Only consider containers that are currently running.

Idle state / audit trail

Persist enough state to tell an idle-stop apart from a manual stop (required by wake-on-request):

  • On the container: stoppedReason (idle | manual | null), stoppedAt, stoppedBy. Cleared when started.
  • Sweep output (containers evaluated, stopped, failed, skipped + reason) captured in the Job output.

Scheduling

  • New bin/idle-sweep.js (name TBD).
  • systemd .timer + .service under create-a-container/contrib/systemd/ that enqueues a Job row running the script, so output is visible through the existing job-runner / JobStatus.
  • --dry-run flag that reports without stopping.

Acceptance criteria

  • Script stops idle containers using the provider stop API, logs and skips failures.
  • Respects idleTime, 0 exemption, and creation grace period.
  • Stop reason/time/actor persisted; cleared on start.
  • Timer enqueues a Job on an interval (e.g. hourly).
  • --dry-run supported.
  • Emits per-owner results for the notification hook.
Lingua principale
JavaScript
Stelle
10
Fork
6
Merge medio
5g 14h
PR unite (30g)
5

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mieweb/opensource-server

Tutte le issue di mieweb/opensource-server

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.