docs: add B1–B4 closeout docs and rewrite B5-closeout as completed
B1: Linux Mint + VMware Workstation + setup-host-linux.sh (Python 3.12 note)
B2: rsync template transfer, VMX registration, smoke tests; keyrings.alt choice
B3: SSH key perms, BuildVMGuest + GiteaPAT via PlaintextKeyring (D-Bus-free)
B4: act-runner.service, config.yaml labels/envs fix, smoke job PASS
B5: rewritten — Python-only timers (no pwsh), 7z compression, --service-name
act-runner fix, prerequisite dirs, root service for backup
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+64
-62
@@ -1,76 +1,78 @@
|
||||
# B5 — Closeout (parziale: artefatti repo)
|
||||
# B5 — Closeout
|
||||
|
||||
Fase B5 di `plans/implementation-plan-A-B.md`: conversione scheduled task
|
||||
Passo B5 di `plans/PhaseB-user-checklist.md`: conversione scheduled task
|
||||
Windows in coppie `*.service` + `*.timer` systemd su Linux.
|
||||
|
||||
## Cosa è stato fatto in questa sessione (su host Windows dev)
|
||||
## Stato
|
||||
|
||||
- [x] Inventario dei 4 task in `scripts/Register-CIScheduledTasks.ps1` (cadenze + comandi)
|
||||
- [x] 5 coppie `*.service` + `*.timer` create in `deploy/systemd/`:
|
||||
- `ci-cleanup-orphans.{service,timer}` — every 6h + at boot → `python -m ci_orchestrator vm cleanup --max-age-hours 6`
|
||||
- `ci-retention-policy.{service,timer}` — daily 03:00 + 30min jitter → `pwsh Invoke-RetentionPolicy.ps1`
|
||||
- `ci-watch-disk-space.{service,timer}` — every 15min → `python -m ci_orchestrator monitor disk`
|
||||
- `ci-watch-runner-health.{service,timer}` — every 15min → `python -m ci_orchestrator monitor runner`
|
||||
- `ci-backup-template.{service,timer}` — weekly Sun 02:00 + 1h jitter → `pwsh Backup-CITemplate.ps1` (NEW, non era in Register-CIScheduledTasks.ps1)
|
||||
- [x] `deploy/systemd/README.md` con: tabella mapping, prerequisiti (utente, venv, env file), istruzioni install/test/rollback, nota PowerShell Core su Linux
|
||||
✅ **COMPLETATO** — 5 timer attivi, tutti e 5 i service PASS al trigger
|
||||
manuale.
|
||||
|
||||
## Note sulle cadenze
|
||||
## Cosa è stato fatto
|
||||
|
||||
Le cadenze del piano (`OnCalendar=hourly`, `*:0/15`, ecc.) sono state
|
||||
adattate per fedeltà semantica all'originale Windows:
|
||||
- [x] Inventario dei 4 task in `scripts/Register-CIScheduledTasks.ps1`
|
||||
(cadenze + comandi) + aggiunta `ci-backup-template` (non era in PS).
|
||||
- [x] `Invoke-RetentionPolicy.ps1` portato in Python come sub-comando
|
||||
`retention run` (`src/ci_orchestrator/commands/retention.py`).
|
||||
- [x] `Backup-CITemplate.ps1` portato in Python come sub-comando
|
||||
`template backup` (`src/ci_orchestrator/commands/template.py`) con
|
||||
compressione `7z a -mx=1 -mmt=on` → archivi `.7z` in
|
||||
`/var/lib/ci/backups/`.
|
||||
- [x] 5 coppie `*.service` + `*.timer` deployate in
|
||||
`/etc/systemd/system/`:
|
||||
|
||||
| Task | Original Windows | systemd timer scelto |
|
||||
| --------------------- | --------------------------------------------- | ----------------------------------------------------- |
|
||||
| cleanup-orphans | every 6h + at startup | `OnBootSec=2min, OnUnitActiveSec=6h, Persistent` |
|
||||
| retention-policy | daily 03:00 + 30min random delay | `OnCalendar=*-*-* 03:00:00, RandomizedDelaySec=30min` |
|
||||
| watch-disk-space | every 15min | `OnBootSec=5min, OnUnitActiveSec=15min` |
|
||||
| watch-runner-health | every 15min | `OnBootSec=3min, OnUnitActiveSec=15min` |
|
||||
| backup-template | *(non in Register-CIScheduledTasks.ps1)* | `OnCalendar=Sun *-*-* 02:00:00, RandomizedDelaySec=1h`|
|
||||
| Unit | Cadenza | Comando |
|
||||
| --------------------------- | ---------------------------------------- | ------------------------------------------------------- |
|
||||
| `ci-cleanup-orphans` | ogni 6h + al boot | `ci_orchestrator vm cleanup --max-age-hours 6` |
|
||||
| `ci-retention-policy` | daily 03:00 + 30min jitter | `ci_orchestrator retention run` |
|
||||
| `ci-watch-disk-space` | ogni 15min | `ci_orchestrator monitor disk` |
|
||||
| `ci-watch-runner-health` | ogni 15min | `ci_orchestrator monitor runner --service-name act-runner` |
|
||||
| `ci-backup-template` | domenica 02:00 + 1h jitter | `ci_orchestrator template backup --all-templates` |
|
||||
|
||||
`Persistent=true` ovunque per non perdere esecuzioni se la macchina è
|
||||
spenta al momento del trigger.
|
||||
- [x] Prerequisiti creati sull'host prima del deploy:
|
||||
```bash
|
||||
sudo mkdir -p /var/log/ci /var/lib/ci/backups
|
||||
sudo chown ci-runner:ci-runner /var/log/ci
|
||||
```
|
||||
- [x] `systemctl list-timers --all 'ci-*'` → 5 timer `active`. ✅ PASS
|
||||
- [x] Trigger manuale di tutti e 5 i service → ✅ tutti PASS.
|
||||
- [x] `deploy/systemd/README.md` aggiornato: tabella mapping, prerequisiti,
|
||||
istruzioni install/test/rollback — senza riferimenti a PowerShell.
|
||||
|
||||
## Decisione — script che restano in PowerShell
|
||||
## Deviazioni / gotcha
|
||||
|
||||
`Invoke-RetentionPolicy.ps1` e `Backup-CITemplate.ps1` non sono stati
|
||||
portati a Python (resta scelta documentata in `AGENTS.md` "Mappatura").
|
||||
Su Linux quindi le rispettive `.service` invocano `pwsh` (PowerShell
|
||||
Core). Il README documenta l'installazione `apt install powershell` da
|
||||
repo Microsoft. Se in futuro si deciderà di portarli a Python (sub-comandi
|
||||
`retention run` / `template backup`), basterà sostituire `ExecStart=`
|
||||
nelle due unit senza toccare il timer.
|
||||
- **pwsh non richiesto**: `Invoke-RetentionPolicy.ps1` e
|
||||
`Backup-CITemplate.ps1` sono stati portati integralmente a Python in
|
||||
questa fase, eliminando la dipendenza da PowerShell Core per tutti e 5
|
||||
i timer. Questo è il primo passo verso la Fase C
|
||||
(`plans/idea-3-powershell-removal.md`).
|
||||
- **`--service-name act-runner`**: il default del comando `monitor runner`
|
||||
era `act_runner` (nome Windows). Il service Linux si chiama `act-runner`
|
||||
(trattino). Il fix è nel parametro `ExecStart` di
|
||||
`ci-watch-runner-health.service`.
|
||||
- **`ci-backup-template` gira come root**: il backup richiede
|
||||
`systemctl stop/start act-runner.service` (gestito con try/finally in
|
||||
Python). Gli altri 4 service girano come `ci-runner`.
|
||||
- **Prerequisiti directory**: `ReadWritePaths` in `ProtectSystem=strict`
|
||||
richiede che le directory esistano *prima* che la unit venga avviata.
|
||||
`ci-watch-runner-health` e `ci-cleanup-orphans` usano `/var/log/ci`;
|
||||
`ci-backup-template` usa `/var/lib/ci/backups`. Entrambe vanno create
|
||||
prima del deploy (vedi sopra).
|
||||
- **Bug pre-esistente in `vm.py`** (`_list_orphans`): `is_dir()` era
|
||||
chiamato fuori dal blocco `try/except OSError`, causando un'eccezione
|
||||
su symlink rotti. Corretto spostando `is_dir()` all'interno del try.
|
||||
|
||||
## Definizione di "fatto" B5 (dal piano)
|
||||
## Cadenze systemd (vs Windows originale)
|
||||
|
||||
| Criterio | Stato |
|
||||
| --------------------------------------------------- | ------------------------------------ |
|
||||
| Tutti i task periodici come timer systemd attivi | ⏳ unit pronti; install richiede host Linux |
|
||||
| Trigger manuale di ognuno PASS | ⏳ richiede host Linux |
|
||||
| Mapping documentato | ✅ `deploy/systemd/README.md` |
|
||||
| Task | Windows originale | systemd timer |
|
||||
| --------------------- | -------------------------- | ----------------------------------------------------- |
|
||||
| cleanup-orphans | ogni 6h + al boot | `OnBootSec=2min, OnUnitActiveSec=6h, Persistent` |
|
||||
| retention-policy | daily 03:00 + 30min delay | `OnCalendar=*-*-* 03:00:00, RandomizedDelaySec=30min` |
|
||||
| watch-disk-space | ogni 15min | `OnBootSec=5min, OnUnitActiveSec=15min` |
|
||||
| watch-runner-health | ogni 15min | `OnBootSec=3min, OnUnitActiveSec=15min` |
|
||||
| backup-template | *(non era in PS)* | `OnCalendar=Sun *-*-* 02:00:00, RandomizedDelaySec=1h`|
|
||||
|
||||
## Cosa resta a carico utente (sul nuovo host Linux)
|
||||
## Riferimenti commit
|
||||
|
||||
Tutti i passi B1–B4 e B6–B8 sono operazioni hardware/host non eseguibili
|
||||
da questa sessione. Per chiudere B5 una volta sull'host Linux:
|
||||
|
||||
```bash
|
||||
# Prerequisito: aver completato B1 (ci-runner user, /opt/ci/venv, /etc/ci/environment)
|
||||
sudo cp deploy/systemd/ci-*.service deploy/systemd/ci-*.timer /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
for t in ci-cleanup-orphans ci-retention-policy ci-watch-disk-space \
|
||||
ci-watch-runner-health ci-backup-template; do
|
||||
sudo systemctl enable --now "${t}.timer"
|
||||
done
|
||||
systemctl list-timers --all 'ci-*'
|
||||
|
||||
# Trigger manuale di smoke
|
||||
sudo systemctl start ci-cleanup-orphans.service
|
||||
journalctl -u ci-cleanup-orphans.service -n 50 --no-pager
|
||||
```
|
||||
|
||||
## Riferimenti
|
||||
|
||||
- Spec systemd timer: `man systemd.timer`, `man systemd.time`
|
||||
- Original PS task scheduler: `scripts/Register-CIScheduledTasks.ps1`
|
||||
- Mapping completo: `deploy/systemd/README.md`
|
||||
- Piano: `plans/implementation-plan-A-B.md` sezione B5
|
||||
- `43a69b8` — feat: B5 — port retention/template-backup to Python, deploy
|
||||
systemd timers
|
||||
|
||||
Reference in New Issue
Block a user