feat: B5 — port retention/template-backup to Python, deploy systemd timers
- Add `retention run` command (ports Invoke-RetentionPolicy.ps1): purges old artifact/log dirs with aggressive mode when disk space is low. - Add `template backup` command (ports Backup-CITemplate.ps1): 7z -mx=1 compressed archives in /var/lib/ci/backups/, prunes to keep-count=3, stops/restarts act-runner.service around the copy. - Update ci-retention-policy.service and ci-backup-template.service to use Python; pwsh is no longer required on the Linux host. - Fix ci-watch-runner-health.service: pass --service-name act-runner (Linux service name, not Windows act_runner default). - Fix _list_orphans in vm.py: wrap is_dir() inside the OSError try block so a stat() failure on an entry is silently skipped rather than raised. - Mark B5 complete in PhaseB-user-checklist.md. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,33 +10,10 @@ installate su un host Linux Mint / Ubuntu LTS, con il package
|
||||
| Windows Task Scheduler | systemd unit | Cadenza | Comando |
|
||||
| ----------------------- | ---------------------------------- | ----------------------- | --------------------------------------------------------------- |
|
||||
| `CI-CleanupOrphans` | `ci-cleanup-orphans.timer` | every 6h + at boot | `python -m ci_orchestrator vm cleanup --max-age-hours 6` |
|
||||
| `CI-RetentionPolicy` | `ci-retention-policy.timer` | daily 03:00 + at boot | `pwsh Invoke-RetentionPolicy.ps1` (vedi nota PowerShell) |
|
||||
| `CI-RetentionPolicy` | `ci-retention-policy.timer` | daily 03:00 + at boot | `python -m ci_orchestrator retention run` |
|
||||
| `CI-DiskSpaceAlert` | `ci-watch-disk-space.timer` | every 15 min | `python -m ci_orchestrator monitor disk` |
|
||||
| `CI-RunnerHealth` | `ci-watch-runner-health.timer` | every 15 min | `python -m ci_orchestrator monitor runner` |
|
||||
| *(nuovo)* | `ci-backup-template.timer` | weekly Sun 02:00 | `pwsh Backup-CITemplate.ps1` (vedi nota PowerShell) |
|
||||
|
||||
## Nota PowerShell su Linux
|
||||
|
||||
Due unit (`ci-retention-policy`, `ci-backup-template`) invocano script
|
||||
PowerShell che, per scelta documentata in `AGENTS.md` ("Mappatura script
|
||||
PowerShell → Python"), restano in PowerShell. Su Linux questo richiede
|
||||
**PowerShell Core (`pwsh`)**:
|
||||
|
||||
```bash
|
||||
# Ubuntu / Mint LTS
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y wget apt-transport-https software-properties-common
|
||||
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb
|
||||
sudo dpkg -i packages-microsoft-prod.deb
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y powershell
|
||||
pwsh --version # verifica
|
||||
```
|
||||
|
||||
Se preferisci non installare `pwsh`, porta `Invoke-RetentionPolicy.ps1` e
|
||||
`Backup-CITemplate.ps1` come sub-comandi `python -m ci_orchestrator
|
||||
retention run` / `template backup` (out of scope B5 per il piano corrente
|
||||
— vedi `plans/implementation-plan-A-B.md`).
|
||||
| *(nuovo)* | `ci-backup-template.timer` | weekly Sun 02:00 | `python -m ci_orchestrator template backup --all-templates` |
|
||||
|
||||
## Prerequisiti
|
||||
|
||||
@@ -55,8 +32,12 @@ retention run` / `template backup` (out of scope B5 per il piano corrente
|
||||
CI_KEYS=/etc/ci/keys
|
||||
PYTHONIOENCODING=utf-8
|
||||
```
|
||||
4. `Invoke-RetentionPolicy.ps1` e `Backup-CITemplate.ps1` presenti in
|
||||
`/opt/ci/local-ci-cd-system/scripts/` (clone del repo).
|
||||
4. `ci_orchestrator` installato nel venv (punto 2) — nessuna dipendenza PowerShell
|
||||
richiesta; `retention run` e `template backup` sono comandi Python puri.
|
||||
|
||||
> **Nota**: `ci-backup-template.service` gira come `root` (non `ci-runner`)
|
||||
> perché chiama `systemctl stop/start act-runner.service` prima e dopo il
|
||||
> backup. Tutti gli altri service girano come `ci-runner`.
|
||||
|
||||
## Installazione
|
||||
|
||||
|
||||
Reference in New Issue
Block a user