CI e installatore: commenti degli script in inglese (#43)
La regola del progetto è «codice e commenti in inglese; interfaccia, documenti e messaggi in italiano», e gli script di .gitea/ (script e flussi), di installer/ e docker/entrypoint.sh avevano ancora i commenti in italiano (decisione di Alberto del 29 novembre 2026). Cambiano solo i commenti: i messaggi che una persona legge (echo, ::warning::, ::error::, nomi dei passi, note della release) restano in italiano e nessun comando cambia. I programmi awk e gli script finti delle prove erano già in inglese. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f48384b7d4
commit
009e7d6710
18 files changed
+496
-495
No files matched your search
+158
-159
@@ -1,71 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pulizia del demone Docker del runner e del registro dei container. Il demone è lo stesso che costruisce Encelado,
|
||||
# Mimante e gli altri progetti di Alberto (e molto probabilmente quello delle applicazioni di Unraid), e ci può girare
|
||||
# anche un Febe vero. Dal 21 ottobre 2026 (decisione di Alberto) la pulizia toglie anche ciò che non serve più a
|
||||
# nessuno, di qualunque progetto: le immagini che nessun contenitore usa, la cache di costruzione, i resti di
|
||||
# act_runner. Mai un contenitore, un volume o una rete che non sia della CI.
|
||||
# Cleanup of the runner's Docker daemon and of the container registry. The daemon is the same one that builds
|
||||
# Encelado, Mimante and Alberto's other projects (and very probably the one of the Unraid applications), and a real
|
||||
# Febe may run on it too. Since 21 October 2026 (decision of Alberto) the cleanup also removes what nobody needs any
|
||||
# more, of any project: the images no container uses, the build cache, the leftovers of act_runner. Never a
|
||||
# container, a volume or a network that does not belong to the CI.
|
||||
#
|
||||
# Della CI di Febe si toglie ciò che si può provare suo. Le etichette febe.ci.workflow, febe.ci.run, febe.ci.ref e
|
||||
# febe.ci.commit dicono da dove viene un'immagine, ma NON scelgono che cosa togliere: stanno anche nelle immagini
|
||||
# pubblicate (:main, :sha-, :X.Y.Z, :latest), e Docker le copia in ogni contenitore creato da quelle, quindi le porta
|
||||
# anche un Febe vero. Ciò che si toglie si riconosce così:
|
||||
# - contenitori di prova: l'etichetta febe.ci.prova=<esecuzione>, che mette solo prova-immagine.sh con
|
||||
# «docker run --label» e che nessuna immagine porta (lo controlla PipelineTests), E il nome esatto
|
||||
# febe-prova-<la stessa esecuzione> (gli altri contenitori della prova, senza nome, girano con --rm e Docker li
|
||||
# toglie da sé appena finiscono);
|
||||
# - immagini provate: il nome locale febe-ci:<esecuzione>, tolto per nome, mai per identificativo e mai con -f. Se la
|
||||
# stessa immagine ha anche un nome del registro, si toglie solo febe-ci:<esecuzione>; se un contenitore la usa, resta;
|
||||
# - builder buildx: il contenitore buildx_buildkit_febe-ci-<esecuzione>0, con l'immagine moby/buildkit, e il suo
|
||||
# volume …_state, che contengono la cache di costruzione di quell'esecuzione;
|
||||
# - l'immagine febe:ci lasciata dal vecchio flusso di verifica (prima del 20 ottobre 2026), se nessuno la usa.
|
||||
# Di act_runner si tolgono i resti dei lavori: act_runner chiama tutto ciò che crea per un lavoro
|
||||
# GITEA-ACTIONS-TASK-<numero del compito>… (il contenitore del lavoro, i suoi volumi <nome> e <nome>-env, la sua rete
|
||||
# <nome>-<lavoro>-network). Solo i contenitori fermi e i volumi e le reti che nessun contenitore usa, più vecchi di 90
|
||||
# minuti: un lavoro che parte li crea e li usa subito. Il volume act-toolcache (la cache degli strumenti, condivisa fra
|
||||
# i lavori) resta.
|
||||
# Of the Febe CI, what can be proven to be its own is removed. The labels febe.ci.workflow, febe.ci.run, febe.ci.ref
|
||||
# and febe.ci.commit say where an image comes from, but they do NOT choose what to remove: they are also in the
|
||||
# published images (:main, :sha-, :X.Y.Z, :latest), and Docker copies them into every container created from those,
|
||||
# so a real Febe carries them too. What is removed is recognised like this:
|
||||
# - test containers: the label febe.ci.prova=<esecuzione>, which only prova-immagine.sh sets with
|
||||
# «docker run --label» and which no image carries (PipelineTests checks it), AND the exact name
|
||||
# febe-prova-<the same run> (the other test containers, without a name, run with --rm and Docker removes them by
|
||||
# itself as soon as they end);
|
||||
# - tested images: the local name febe-ci:<esecuzione>, removed by name, never by id and never with -f. If the same
|
||||
# image also has a registry name, only febe-ci:<esecuzione> is removed; if a container uses it, it stays;
|
||||
# - buildx builders: the container buildx_buildkit_febe-ci-<esecuzione>0, with the moby/buildkit image, and its
|
||||
# …_state volume, which hold the build cache of that run;
|
||||
# - the febe:ci image left by the old verification workflow (before 20 October 2026), if nobody uses it.
|
||||
# Of act_runner, the leftovers of the jobs are removed: act_runner names everything it creates for a job
|
||||
# GITEA-ACTIONS-TASK-<task number>… (the job container, its volumes <nome> and <nome>-env, its network
|
||||
# <nome>-<lavoro>-network). Only stopped containers, and volumes and networks no container uses, older than 90
|
||||
# minutes: a job that starts creates them and uses them at once. The act-toolcache volume (the tool cache, shared
|
||||
# among the jobs) stays.
|
||||
#
|
||||
# pulizia-docker.sh esecuzione <id> tutto ciò che ha creato l'esecuzione <id> (all'inizio e alla fine del suo
|
||||
# lavoro «immagine», sempre)
|
||||
# pulizia-docker.sh penzolanti le immagini senza nome che nessun contenitore usa e la cache di costruzione
|
||||
# penzolante del demone (quella che nessuna immagine condivide) non usata da
|
||||
# 24 ore, di tutti i progetti (alla fine di ogni lavoro «immagine», dopo
|
||||
# «esecuzione»)
|
||||
# pulizia-docker.sh residui [minuti] i resti di esecuzioni interrotte, più vecchi di N minuti (predefinito 90: un
|
||||
# lavoro dura al massimo 60 minuti, quindi nessuno di essi è ancora vivo)
|
||||
# pulizia-docker.sh settimanale residui, febe:ci, immagini senza nome più vecchie di 72 ore: la pulizia
|
||||
# stretta di prima del 21 ottobre 2026, ora solo a mano
|
||||
# pulizia-docker.sh completa residui, febe:ci, resti di act_runner, le immagini che nessun contenitore
|
||||
# usa create più di 24 ore fa, la cache di costruzione non usata da 24 ore e,
|
||||
# con REGISTRY_TOKEN, le etichette sha- del registro oltre le 10 più recenti e
|
||||
# gli artefatti della CI (febe-ci) di più di 14 giorni (flusso «pulizia», ogni
|
||||
# lunedì e a mano)
|
||||
# pulizia-docker.sh <modo> --prova elenca che cosa toglierebbe e non toglie nulla: solo comandi che leggono
|
||||
# (sul registro solo GET)
|
||||
# pulizia-docker.sh esecuzione <id> everything the run <id> created (at the start and at the end of its
|
||||
# «immagine» job, always)
|
||||
# pulizia-docker.sh penzolanti the unnamed images no container uses and the daemon's dangling build cache
|
||||
# (the part no image shares) unused for 24 hours, of all projects (at the end
|
||||
# of every «immagine» job, after «esecuzione»)
|
||||
# pulizia-docker.sh residui [minuti] the leftovers of interrupted runs, older than N minutes (default 90: a job
|
||||
# lasts at most 60 minutes, so none of them is still alive)
|
||||
# pulizia-docker.sh settimanale residui, febe:ci, unnamed images older than 72 hours: the narrow cleanup of
|
||||
# before 21 October 2026, now only by hand
|
||||
# pulizia-docker.sh completa residui, febe:ci, act_runner leftovers, the images no container uses
|
||||
# created more than 24 hours ago, the build cache unused for 24 hours and,
|
||||
# with REGISTRY_TOKEN, the registry's sha- tags beyond the 10 most recent and
|
||||
# the CI artifacts (febe-ci) older than 14 days («pulizia» workflow, every
|
||||
# Monday and by hand)
|
||||
# pulizia-docker.sh <modo> --prova lists what it would remove and removes nothing: only commands that read
|
||||
# (on the registry only GET)
|
||||
#
|
||||
# Gli argomenti si controllano tutti prima di toccare Docker: un'opzione diversa da --prova (--dry-run, -n, --Prova) o
|
||||
# un argomento in più (prova senza trattini) fermano tutto con codice 2, invece di far partire la pulizia vera al posto
|
||||
# della prova.
|
||||
# All the arguments are checked before touching Docker: an option other than --prova (--dry-run, -n, --Prova) or an
|
||||
# extra argument (prova without dashes) stops everything with code 2, instead of starting the real cleanup in place
|
||||
# of the dry run.
|
||||
#
|
||||
# Mai docker system prune, container prune, volume prune o network prune; mai image prune -a o builder prune -a senza
|
||||
# il filtro delle 24 ore; mai un contenitore, un volume o una rete che non sia della CI. Le immagini le toglie Docker
|
||||
# stesso (image prune), che non toglie mai un'immagine usata da un contenitore, nemmeno fermo; con -a, però, le toglie i
|
||||
# nomi in più, e lo script li scrive (nella prova li stima, secondo lo store). Sul registro mai main, latest o una
|
||||
# versione X.Y.Z: solo le etichette sha-<esadecimale> della verifica e gli artefatti <x.y.z>-ci.<n> e
|
||||
# <x.y.z>-rilascio.<n> del pacchetto generico febe-ci.
|
||||
# Never docker system prune, container prune, volume prune or network prune; never image prune -a or builder prune -a
|
||||
# without the 24-hour filter; never a container, a volume or a network that does not belong to the CI. The images are
|
||||
# removed by Docker itself (image prune), which never removes an image used by a container, not even a stopped one;
|
||||
# with -a, though, it removes their extra names, and the script writes them out (in the dry run it estimates them,
|
||||
# depending on the store). On the registry never main, latest or an X.Y.Z version: only the sha-<hexadecimal> tags of
|
||||
# the verification and the <x.y.z>-ci.<n> and <x.y.z>-rilascio.<n> artifacts of the generic febe-ci package.
|
||||
#
|
||||
# Nei modi «residui», «settimanale» e «completa» un contenitore di prova si toglie solo se è fermo. Uno ancora acceso
|
||||
# dopo 90 minuti (il suo lavoro è stato ucciso proprio durante la prova del contenitore) resta dov'è: lo si segnala, con
|
||||
# il comando per toglierlo a mano. I builder sono l'eccezione: sono sempre accesi e la loro cache se ne va solo
|
||||
# togliendo il contenitore; si riconoscono dal nome esatto e dall'immagine di buildkit, mai da un'etichetta.
|
||||
# In the «residui», «settimanale» and «completa» modes a test container is removed only if it is stopped. One still
|
||||
# running after 90 minutes (its job was killed right during the container test) stays where it is: it is reported,
|
||||
# with the command to remove it by hand. The builders are the exception: they are always running and their cache goes
|
||||
# away only by removing the container; they are recognised by the exact name and the buildkit image, never by a label.
|
||||
#
|
||||
# Un oggetto già sparito non è un errore: la pulizia si può ripetere. Nei modi «esecuzione», «penzolanti» e «residui»
|
||||
# un problema diventa un avviso (un lavoro verde non diventa rosso per la pulizia, che il flusso del lunedì ripete); nei
|
||||
# modi «settimanale» e «completa» fa fallire il lavoro, perché qualcuno lo guardi. Il registro è l'eccezione: un
|
||||
# rifiuto della sua API è solo un avviso, e il lunedì dopo si riprova.
|
||||
# An object already gone is not an error: the cleanup can be repeated. In the «esecuzione», «penzolanti» and «residui»
|
||||
# modes a problem becomes a warning (a green job does not turn red because of the cleanup, which the Monday workflow
|
||||
# repeats); in the «settimanale» and «completa» modes it fails the job, so that someone looks at it. The registry is
|
||||
# the exception: a refusal by its API is only a warning, and the following Monday it is tried again.
|
||||
#
|
||||
# Variabili per il registro (modo «completa»): REGISTRY_TOKEN (token con «package: read and write», mai stampato),
|
||||
# GITEA_API (l'API del server, per esempio https://gitea.example/api/v1) e PROPRIETARIO (il proprietario del pacchetto
|
||||
# febe). La scelta delle versioni da togliere sta in versioni-registro.sh, accanto a questo script.
|
||||
# Variables for the registry («completa» mode): REGISTRY_TOKEN (token with «package: read and write», never printed),
|
||||
# GITEA_API (the server's API, for example https://gitea.example/api/v1) and PROPRIETARIO (the owner of the febe
|
||||
# package). The choice of the versions to remove lives in versioni-registro.sh, next to this script.
|
||||
set -uo pipefail
|
||||
|
||||
uso() {
|
||||
@@ -93,21 +92,21 @@ esac
|
||||
cartella_script="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
problemi=0
|
||||
|
||||
# In prova: i contenitori (identificativo e nome) e i nomi di immagine che la pulizia vera toglierebbe, perché gli
|
||||
# elenchi che seguono li trattino come già tolti (un volume usato solo da un contenitore che se ne andrebbe, per
|
||||
# esempio, se ne andrebbe anche lui).
|
||||
# In a dry run: the containers (id and name) and the image names the real cleanup would remove, so that the lists
|
||||
# that follow treat them as already removed (a volume used only by a container that would go away, for example,
|
||||
# would go away too).
|
||||
previsti=()
|
||||
nomi_previsti=()
|
||||
|
||||
# Per il riepilogo: quanti oggetti per tipo, nell'ordine in cui compaiono, e lo spazio recuperato da Docker.
|
||||
# For the summary: how many objects per kind, in the order they appear, and the space reclaimed by Docker.
|
||||
declare -A conteggi=()
|
||||
tipi=()
|
||||
note=()
|
||||
|
||||
# La cache di costruzione che si pota è quella del builder del demone, «default». docker builder è un alias di docker
|
||||
# buildx quando c'è il plugin, e buildx lavora sul builder corrente: se qualcuno avesse reso corrente il builder
|
||||
# dell'esecuzione (costruisci-immagine.sh builder non lo fa), il modo «esecuzione» l'avrebbe appena tolto. Gli altri
|
||||
# comandi buildx di questo script indicano il builder per nome.
|
||||
# The build cache that is pruned is the one of the daemon's builder, «default». docker builder is an alias of docker
|
||||
# buildx when the plugin is there, and buildx works on the current builder: if someone had made the run's builder
|
||||
# current (costruisci-immagine.sh builder does not), the «esecuzione» mode would have just removed it. The other
|
||||
# buildx commands of this script name the builder explicitly.
|
||||
export BUILDX_BUILDER=default
|
||||
|
||||
avviso() {
|
||||
@@ -115,7 +114,7 @@ avviso() {
|
||||
problemi=$((problemi + 1))
|
||||
}
|
||||
|
||||
# Un avviso che non fa diventare rosso il lavoro: per il registro.
|
||||
# A warning that does not turn the job red: for the registry.
|
||||
segnala() {
|
||||
echo "::warning::$*"
|
||||
}
|
||||
@@ -125,7 +124,7 @@ conta() {
|
||||
conteggi[$1]=$((${conteggi[$1]:-0} + 1))
|
||||
}
|
||||
|
||||
# Vero se la prima parola è fra quelle che seguono.
|
||||
# True if the first word is among the ones that follow.
|
||||
fra() {
|
||||
local cercata="$1" voce
|
||||
shift
|
||||
@@ -135,9 +134,9 @@ fra() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Minuti trascorsi da un istante RFC 3339 come lo scrive Docker (Created di un contenitore o di un'immagine, CreatedAt
|
||||
# di un volume, {{json .Created}} di una rete, fra virgolette), con o senza frazioni di secondo, con «Z» o con lo scarto
|
||||
# dall'ora universale (+02:00). Se non si legge, 0: nel dubbio l'oggetto è giovane e resta.
|
||||
# Minutes elapsed since an RFC 3339 instant as Docker writes it (Created of a container or an image, CreatedAt of a
|
||||
# volume, {{json .Created}} of a network, in quotes), with or without fractions of a second, with «Z» or with the
|
||||
# offset from universal time (+02:00). If it cannot be read, 0: when in doubt the object is young and stays.
|
||||
eta_minuti() {
|
||||
local creato="${1:-}" secondi
|
||||
creato="${creato//\"/}"
|
||||
@@ -158,8 +157,8 @@ durata() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Fra i contenitori dati (identificativi, uno per riga), quelli che restano dopo questa pulizia: in prova senza quelli
|
||||
# che la pulizia vera toglierebbe.
|
||||
# Among the given containers (ids, one per line), those that remain after this cleanup: in a dry run without the ones
|
||||
# the real cleanup would remove.
|
||||
restanti() {
|
||||
local id
|
||||
while read -r id; do
|
||||
@@ -168,9 +167,9 @@ restanti() {
|
||||
done <<< "${1:-}"
|
||||
}
|
||||
|
||||
# I contenitori di prova della CI, uno per riga «id nome»: l'etichetta febe.ci.prova (dell'esecuzione indicata, o di
|
||||
# qualunque se il primo argomento è vuoto) e il nome esatto febe-prova-<valore dell'etichetta>. Gli stati che seguono
|
||||
# restringono la scelta (Docker li unisce in OR). Esce con 1 se Docker non risponde.
|
||||
# The CI test containers, one per line «id name»: the label febe.ci.prova (of the given run, or of any run if the
|
||||
# first argument is empty) and the exact name febe-prova-<label value>. The states that follow narrow the choice
|
||||
# (Docker joins them with OR). Exits with 1 if Docker does not answer.
|
||||
contenitori_di_prova() {
|
||||
local run="$1"
|
||||
shift
|
||||
@@ -185,8 +184,8 @@ contenitori_di_prova() {
|
||||
done <<< "$elenco"
|
||||
}
|
||||
|
||||
# Toglie un contenitore con i suoi volumi anonimi (in prova lo elenca soltanto). Con «forza» anche se è acceso: solo
|
||||
# per quelli dell'esecuzione stessa e per i builder. Esce con 0 se il contenitore se ne va (o se ne andrebbe).
|
||||
# Removes a container with its anonymous volumes (in a dry run it only lists it). With «forza» even if it is running:
|
||||
# only for those of the run itself and for the builders. Exits with 0 if the container goes away (or would).
|
||||
togli_contenitore() {
|
||||
local id="$1" nome="$2" opzioni=(-v)
|
||||
[[ "${3:-}" == forza ]] && opzioni=(-f -v)
|
||||
@@ -203,8 +202,8 @@ togli_contenitore() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Toglie il nome locale febe-ci:<esecuzione> (o febe:ci), mai l'immagine per identificativo e mai con -f: se l'immagine
|
||||
# ha anche un altro nome (del registro, per esempio) quello resta; se un contenitore la usa, resta tutto.
|
||||
# Removes the local name febe-ci:<esecuzione> (or febe:ci), never the image by id and never with -f: if the image also
|
||||
# has another name (a registry one, for example) that one stays; if a container uses it, everything stays.
|
||||
togli_immagine() {
|
||||
local riferimento="$1" nomi
|
||||
[[ "$riferimento" =~ ^febe-ci:[0-9]+$ ]] || [[ "$riferimento" == febe:ci ]] \
|
||||
@@ -227,9 +226,9 @@ togli_immagine() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Un builder buildx della CI: prima con buildx (se questo client lo conosce), poi contenitore e volume per nome, perché
|
||||
# un lavoro diverso da quello che l'ha creato non ne ha la configurazione. Il contenitore si toglie solo se gira
|
||||
# l'immagine di buildkit, e il volume solo quando il contenitore non c'è più.
|
||||
# A CI buildx builder: first with buildx (if this client knows it), then container and volume by name, because a job
|
||||
# other than the one that created it does not have its configuration. The container is removed only if it runs the
|
||||
# buildkit image, and the volume only when the container is gone.
|
||||
togli_builder() {
|
||||
local builder="$1"
|
||||
[[ "$builder" =~ ^febe-ci-[0-9]+$ ]] || { avviso "Nome di builder inatteso: «$builder»."; return 1; }
|
||||
@@ -262,8 +261,8 @@ togli_builder() {
|
||||
return "$esito"
|
||||
}
|
||||
|
||||
# Un volume o una rete di act_runner. Docker stesso non toglie un volume che un contenitore usa, né una rete con un
|
||||
# contenitore acceso collegato.
|
||||
# A volume or a network of act_runner. Docker itself does not remove a volume a container uses, nor a network with a
|
||||
# running container attached.
|
||||
togli_volume() {
|
||||
local nome="$1"
|
||||
if ((prova)); then
|
||||
@@ -292,8 +291,8 @@ togli_rete() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Vero se nessun contenitore, acceso o fermo, usa il volume o la rete (in prova: nessuno che la pulizia vera
|
||||
# lascerebbe). Nel dubbio (Docker non risponde) falso: resta.
|
||||
# True if no container, running or stopped, uses the volume or the network (in a dry run: none that the real cleanup
|
||||
# would leave). When in doubt (Docker does not answer) false: it stays.
|
||||
nessuno_usa() {
|
||||
local tipo="$1" nome="$2" utenti
|
||||
if [[ "$tipo" == volume ]]; then
|
||||
@@ -326,7 +325,7 @@ residui() {
|
||||
echo "== Resti di esecuzioni interrotte della CI di Febe, più vecchi di $minuti minuti"
|
||||
local elenco id nome eta riferimento builder
|
||||
|
||||
# Contenitori di prova fermi: si tolgono. Senza -f: se nel frattempo uno ripartisse, Docker lo lascia stare.
|
||||
# Stopped test containers: they are removed. Without -f: if one started again in the meantime, Docker leaves it alone.
|
||||
if elenco=$(contenitori_di_prova "" exited created dead); then
|
||||
while read -r id nome; do
|
||||
[[ -n "${id:-}" ]] || continue
|
||||
@@ -337,7 +336,7 @@ residui() {
|
||||
avviso "Non riesco a elencare i contenitori di prova fermi."
|
||||
fi
|
||||
|
||||
# Contenitori di prova ancora accesi: non si toccano, si segnalano.
|
||||
# Test containers still running: they are not touched, they are reported.
|
||||
if elenco=$(contenitori_di_prova "" running restarting paused); then
|
||||
while read -r id nome; do
|
||||
[[ -n "${id:-}" ]] || continue
|
||||
@@ -350,7 +349,7 @@ residui() {
|
||||
avviso "Non riesco a elencare i contenitori di prova accesi."
|
||||
fi
|
||||
|
||||
# Immagini provate: solo i nomi febe-ci:<esecuzione>.
|
||||
# Tested images: only the febe-ci:<esecuzione> names.
|
||||
if elenco=$(docker image ls --filter "reference=febe-ci" --format '{{.Repository}}:{{.Tag}}'); then
|
||||
while read -r riferimento; do
|
||||
[[ "${riferimento:-}" =~ ^febe-ci:[0-9]+$ ]] || continue
|
||||
@@ -361,7 +360,7 @@ residui() {
|
||||
avviso "Non riesco a elencare le immagini febe-ci."
|
||||
fi
|
||||
|
||||
# Builder buildx. Il filtro per nome di Docker cerca una parte del nome: il nome esatto si controlla qui.
|
||||
# buildx builders. Docker's name filter matches part of the name: the exact name is checked here.
|
||||
if elenco=$(docker ps -a --no-trunc --filter "name=buildx_buildkit_febe-ci-" --format '{{.ID}} {{.Names}}'); then
|
||||
while read -r id nome; do
|
||||
[[ -n "${id:-}" ]] || continue
|
||||
@@ -376,7 +375,7 @@ residui() {
|
||||
fi
|
||||
}
|
||||
|
||||
# I resti della CI di Febe e l'immagine febe:ci del vecchio flusso (modi «settimanale» e «completa»).
|
||||
# The leftovers of the Febe CI and the febe:ci image of the old workflow («settimanale» and «completa» modes).
|
||||
resti_della_ci() {
|
||||
residui 90
|
||||
echo "== Immagine febe:ci del vecchio flusso di verifica"
|
||||
@@ -385,16 +384,16 @@ resti_della_ci() {
|
||||
fi
|
||||
}
|
||||
|
||||
# act_runner chiama i suoi oggetti GITEA-ACTIONS-TASK-<numero del compito>, seguito da «_WORKFLOW-…» o, nelle versioni
|
||||
# più vecchie, da «-WORKFLOW-…» con un'impronta in fondo.
|
||||
# act_runner names its objects GITEA-ACTIONS-TASK-<task number>, followed by «_WORKFLOW-…» or, in older versions, by
|
||||
# «-WORKFLOW-…» with a hash at the end.
|
||||
nome_act='^GITEA-ACTIONS-TASK-[0-9]+[-_]'
|
||||
|
||||
resti_di_act_runner() {
|
||||
local minuti="$1" elenco id nome eta
|
||||
echo "== Resti di act_runner (GITEA-ACTIONS-TASK-…) più vecchi di $minuti minuti: contenitori fermi, volumi e reti che nessun contenitore usa"
|
||||
|
||||
# Contenitori fermi. Il filtro per nome di Docker cerca una parte del nome: l'inizio esatto si controlla qui. Senza
|
||||
# -f: Docker non toglie un contenitore acceso.
|
||||
# Stopped containers. Docker's name filter matches part of the name: the exact start is checked here. Without -f:
|
||||
# Docker does not remove a running container.
|
||||
if elenco=$(docker ps -a --no-trunc --filter "name=GITEA-ACTIONS-TASK-" --filter "status=exited" \
|
||||
--filter "status=created" --filter "status=dead" --format '{{.ID}} {{.Names}}'); then
|
||||
while read -r id nome; do
|
||||
@@ -408,7 +407,7 @@ resti_di_act_runner() {
|
||||
avviso "Non riesco a elencare i contenitori di act_runner."
|
||||
fi
|
||||
|
||||
# Volumi che nessun contenitore usa, nemmeno fermo.
|
||||
# Volumes no container uses, not even a stopped one.
|
||||
if elenco=$(docker volume ls -q --filter "name=GITEA-ACTIONS-TASK-"); then
|
||||
while read -r nome; do
|
||||
[[ -n "${nome:-}" && "$nome" =~ $nome_act ]] || continue
|
||||
@@ -420,8 +419,8 @@ resti_di_act_runner() {
|
||||
avviso "Non riesco a elencare i volumi di act_runner."
|
||||
fi
|
||||
|
||||
# Reti a cui nessun contenitore è collegato, nemmeno fermo. Created di una rete è un istante di Go, che il modello
|
||||
# stampa come «2026-10-21 06:17:03 +0200 CEST»: in JSON è RFC 3339.
|
||||
# Networks no container is attached to, not even a stopped one. Created of a network is a Go time, which the template
|
||||
# prints as «2026-10-21 06:17:03 +0200 CEST»: in JSON it is RFC 3339.
|
||||
if elenco=$(docker network ls --no-trunc --filter "name=GITEA-ACTIONS-TASK-" --format '{{.ID}} {{.Name}}'); then
|
||||
while read -r id nome; do
|
||||
[[ -n "${id:-}" && "${nome:-}" =~ $nome_act ]] || continue
|
||||
@@ -434,9 +433,8 @@ resti_di_act_runner() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Le immagini dei contenitori, accesi o fermi, tranne quelli che la pulizia toglierebbe: «identificativo immagine» una
|
||||
# per riga, l'immagine come la si è data a docker run (un nome o un identificativo). Solo lettura: serve all'elenco
|
||||
# della prova.
|
||||
# The images of the containers, running or stopped, except those the cleanup would remove: «id image» one per line,
|
||||
# the image as it was given to docker run (a name or an id). Read only: it serves the dry-run listing.
|
||||
immagini_in_uso() {
|
||||
local elenco id nome
|
||||
elenco=$(docker ps -a --no-trunc --format '{{.ID}} {{.Names}}') || return 1
|
||||
@@ -449,8 +447,8 @@ immagini_in_uso() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Il nome completo di un nome d'immagine, come lo ordina Docker: docker.io/library/ o docker.io/ davanti ai nomi di
|
||||
# Docker Hub scritti senza dominio, :latest se manca l'etichetta.
|
||||
# The full name of an image name, as Docker sorts it: docker.io/library/ or docker.io/ in front of Docker Hub names
|
||||
# written without a domain, :latest if the tag is missing.
|
||||
nome_completo() {
|
||||
local nome="$1" primo
|
||||
[[ "${nome##*/}" == *:* ]] || nome="$nome:latest"
|
||||
@@ -466,13 +464,13 @@ nome_completo() {
|
||||
fi
|
||||
}
|
||||
|
||||
# In prova: i nomi che «image prune -a» toglierebbe a un'immagine che un contenitore usa (i nomi e le immagini dei
|
||||
# contenitori, come li scrivono docker image ls e docker container inspect), uno per riga. L'immagine resta, ma i nomi
|
||||
# in più no (moby). Con lo store classico Docker toglie i nomi in ordine alfabetico del nome completo e si ferma
|
||||
# all'ultimo, l'unico che rifiuta di togliere perché un contenitore usa l'immagine (daemon/images/image_prune.go e
|
||||
# image_delete.go, isSingleReference): può andarsene anche il nome da cui il contenitore è stato creato. Con containerd
|
||||
# restano i nomi da cui i contenitori sono stati creati e, se uno la usa per identificativo e nessun nome resterebbe,
|
||||
# l'ultimo in ordine alfabetico (daemon/containerd/image_prune.go).
|
||||
# In a dry run: the names «image prune -a» would remove from an image a container uses (the names and the images of
|
||||
# the containers, as docker image ls and docker container inspect write them), one per line. The image stays, but the
|
||||
# extra names do not (moby). With the classic store Docker removes the names in alphabetical order of the full name
|
||||
# and stops at the last one, the only one it refuses to remove because a container uses the image
|
||||
# (daemon/images/image_prune.go and image_delete.go, isSingleReference): even the name the container was created from
|
||||
# may go. With containerd the names the containers were created from stay and, if one uses it by id and no name would
|
||||
# stay, the last one in alphabetical order (daemon/containerd/image_prune.go).
|
||||
nomi_che_perde() {
|
||||
local id="$1" nomi="$2" configurazioni="$3" nome completo configurazione resto per_id=0 ordinati quanti
|
||||
local -A protetti=()
|
||||
@@ -508,10 +506,10 @@ nomi_che_perde() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# In prova: le immagini che la potatura toglierebbe, con dimensione ed età. Nessun contenitore le usa (a parte quelli
|
||||
# che questa pulizia toglierebbe) e sono state create più di N minuti fa; con «senza-nome» solo quelle senza nome. Con
|
||||
# «tutte», di un'immagine che un contenitore usa, i nomi in più che Docker le toglierebbe. È una stima fatta qui: nella
|
||||
# pulizia vera decide Docker (image prune).
|
||||
# In a dry run: the images the pruning would remove, with size and age. No container uses them (apart from those this
|
||||
# cleanup would remove) and they were created more than N minutes ago; with «senza-nome» only the unnamed ones. With
|
||||
# «tutte», for an image a container uses, the extra names Docker would remove from it. It is an estimate made here: in
|
||||
# the real cleanup Docker decides (image prune).
|
||||
elenca_immagini() {
|
||||
local minimo="$1" quali="$2" usate elenco id nome breve dimensione eta quante=0 configurazione
|
||||
local -A nomi=() elenco_nomi=() dimensioni=() aveva_nomi=() usata_da=()
|
||||
@@ -543,11 +541,11 @@ elenca_immagini() {
|
||||
[[ "$nome" == *":<none>" ]] || elenco_nomi[$id]+="$nome"$'\n'
|
||||
done <<< "$elenco"
|
||||
for id in "${ordine[@]}"; do
|
||||
# Un'immagine i cui nomi la pulizia toglie qui sopra se ne va già con l'ultimo.
|
||||
# An image whose names the cleanup removes above already goes away with the last one.
|
||||
[[ -n "${aveva_nomi[$id]:-}" && -z "${nomi[$id]}" ]] && continue
|
||||
breve="${id#sha256:}"
|
||||
if [[ -n "${usata_da[$id]+x}" ]]; then
|
||||
# Un contenitore la usa: resta. Con -a, però, Docker le toglie i nomi in più.
|
||||
# A container uses it: it stays. With -a, though, Docker removes its extra names.
|
||||
[[ "$quali" == tutte && -n "${elenco_nomi[$id]}" ]] || continue
|
||||
eta=$(eta_minuti "$(docker image inspect -f '{{.Created}}' "$id" 2> /dev/null)")
|
||||
((eta >= minimo)) || continue
|
||||
@@ -575,8 +573,8 @@ elenca_immagini() {
|
||||
((quante > 0)) || echo " nessuna"
|
||||
}
|
||||
|
||||
# In prova: quanta cache di costruzione ha il demone. Quanta ne toglierebbe la potatura Docker non lo dice senza
|
||||
# toglierla: al più quella che nessuno sta usando («RECLAIMABLE» di docker system df).
|
||||
# In a dry run: how much build cache the daemon has. How much of it the pruning would remove Docker does not say
|
||||
# without removing it: at most the part nobody is using («RECLAIMABLE» of docker system df).
|
||||
elenca_cache() {
|
||||
local riga tipo dimensione recuperabile
|
||||
riga=$(docker system df --format '{{.Type}}|{{.Size}}|{{.Reclaimable}}' 2> /dev/null | grep '^Build Cache|')
|
||||
@@ -589,11 +587,11 @@ elenca_cache() {
|
||||
note+=("cache di costruzione: $dimensione in tutto, al più $recuperabile da togliere")
|
||||
}
|
||||
|
||||
# Lo store delle immagini del demone: «containerd» (io.containerd.snapshotter.v1, predefinito nelle installazioni nuove
|
||||
# di Docker Engine dalla 29) o «classico» (overlay2 e gli altri driver di prima). Ne dipende da quando contano le 24 ore
|
||||
# di image prune --filter until: con lo store classico dalla costruzione dell'immagine (Created della configurazione),
|
||||
# con containerd da quando il nome è arrivato sul demone (CreatedAt del suo record, che un nuovo pull dello stesso nome
|
||||
# non cambia).
|
||||
# The daemon's image store: «containerd» (io.containerd.snapshotter.v1, the default in new Docker Engine installations
|
||||
# since 29) or «classico» (overlay2 and the other earlier drivers). It decides from when the 24 hours of image prune
|
||||
# --filter until count: with the classic store from the image build (Created of the configuration), with containerd
|
||||
# from when the name arrived on the daemon (CreatedAt of its record, which a new pull of the same name does not
|
||||
# change).
|
||||
store=""
|
||||
rileva_store() {
|
||||
local stato
|
||||
@@ -611,21 +609,21 @@ rileva_store() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Ogni immagine con ciascuno dei suoi nomi, «identificativo nome» una per riga (<none>:<none> se non ne ha).
|
||||
# Every image with each of its names, «id name» one per line (<none>:<none> if it has none).
|
||||
immagini_e_nomi() {
|
||||
docker image ls --no-trunc --format '{{.ID}} {{.Repository}}:{{.Tag}}' 2> /dev/null
|
||||
}
|
||||
|
||||
# Lo spazio recuperato secondo Docker: «Total reclaimed space: 1.2GB» (docker) o «Total: 1.2GB» (buildx).
|
||||
# The space reclaimed according to Docker: «Total reclaimed space: 1.2GB» (docker) or «Total: 1.2GB» (buildx).
|
||||
spazio_recuperato() {
|
||||
local riga
|
||||
riga=$(grep -E '^Total' <<< "$1" | tail -n 1 | sed -E 's/^Total( reclaimed space)?:[[:space:]]*//')
|
||||
echo "${riga:-0B}"
|
||||
}
|
||||
|
||||
# Una potatura di immagini di Docker: i nomi tolti, quante immagini e quanto spazio. Un errore è un avviso. I nomi si
|
||||
# confrontano prima e dopo: con -a Docker toglie anche i nomi in più di un'immagine che un contenitore usa e che resta,
|
||||
# e il registro del lavoro lo dice.
|
||||
# A Docker image pruning: the names removed, how many images and how much space. An error is a warning. The names are
|
||||
# compared before and after: with -a Docker also removes the extra names of an image a container uses and that stays,
|
||||
# and the job log says so.
|
||||
pota_immagini() {
|
||||
local cosa="$1" uscita prima dopo recuperato prima_nomi dopo_nomi dopo_id id nome breve
|
||||
shift
|
||||
@@ -659,7 +657,7 @@ pota_immagini() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Una potatura della cache di costruzione: quanto spazio. Un errore è un avviso.
|
||||
# A build cache pruning: how much space. An error is a warning.
|
||||
pota_cache() {
|
||||
local cosa="$1" uscita recuperato
|
||||
shift
|
||||
@@ -672,8 +670,8 @@ pota_cache() {
|
||||
note+=("$cosa: $recuperato recuperati")
|
||||
}
|
||||
|
||||
# Una chiamata all'API di Gitea con il token del registro, che sta solo nell'intestazione di curl e mai nel registro
|
||||
# del lavoro. Stampa il codice HTTP: 000 se Gitea non risponde.
|
||||
# A call to the Gitea API with the registry token, which is only in the curl header and never in the job log. Prints
|
||||
# the HTTP code: 000 if Gitea does not answer.
|
||||
chiedi() {
|
||||
local metodo="$1" indirizzo="$2" uscita="$3" codice
|
||||
codice=$(curl -sS --max-time 30 -X "$metodo" -H "Authorization: token $REGISTRY_TOKEN" -H "Accept: application/json" \
|
||||
@@ -690,21 +688,22 @@ spiega() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Le etichette sha- del pacchetto febe oltre le 10 più recenti, con l'API dei pacchetti di Gitea 28:
|
||||
# GET /api/v1/packages/{proprietario}/container/febe?page=N&limit=50 le versioni, una pagina alla volta finché
|
||||
# ne arriva una vuota (il server può darne
|
||||
# meno di 50 per pagina)
|
||||
# DELETE /api/v1/packages/{proprietario}/container/febe/{versione} una versione (risponde 204)
|
||||
# Quali togliere lo sceglie versioni-registro.sh (awk POSIX con json.awk: niente Node, niente jq); qui si ricontrolla
|
||||
# la forma sha-<esadecimale> prima di ogni DELETE. Ogni rifiuto dell'API è un avviso che non fa diventare rosso il
|
||||
# lavoro, e dopo un rifiuto il registro non si tocca più (il token è lo stesso). Le versioni sha256:… senza etichetta (i
|
||||
# manifest figli di un indice, con gli strati) non si toccano mai: l'API non dice se un'etichetta le usa ancora. Si
|
||||
# dice solo quante sono; la CI pubblica manifest semplici (costruisci-immagine.sh), quindi non dovrebbero essercene, e
|
||||
# quelle che nessuna etichetta usa le toglie una regola di pulizia di Gitea (docs/processo.md, «Registro dei container»).
|
||||
# Poi gli artefatti della CI (artefatti.sh): le versioni del pacchetto generico febe-ci create più di 14 giorni fa,
|
||||
# The sha- tags of the febe package beyond the 10 most recent, with the package API of Gitea 28:
|
||||
# GET /api/v1/packages/{proprietario}/container/febe?page=N&limit=50 the versions, one page at a time until an
|
||||
# empty one arrives (the server may give
|
||||
# fewer than 50 per page)
|
||||
# DELETE /api/v1/packages/{proprietario}/container/febe/{versione} one version (answers 204)
|
||||
# Which ones to remove is chosen by versioni-registro.sh (POSIX awk with json.awk: no Node, no jq); here the
|
||||
# sha-<hexadecimal> form is checked again before every DELETE. Every refusal by the API is a warning that does not
|
||||
# turn the job red, and after a refusal the registry is not touched any more (the token is the same). The sha256:…
|
||||
# versions without a tag (the child manifests of an index, with the layers) are never touched: the API does not say
|
||||
# whether a tag still uses them. Only their number is reported; the CI publishes plain manifests
|
||||
# (costruisci-immagine.sh), so there should be none, and those no tag uses are removed by a Gitea cleanup rule
|
||||
# (docs/processo.md, «Registro dei container»).
|
||||
# Then the CI artifacts (artefatti.sh): the versions of the generic febe-ci package created more than 14 days ago,
|
||||
# GET /api/v1/packages/{proprietario}/generic/febe-ci?page=N&limit=50
|
||||
# DELETE /api/v1/packages/{proprietario}/generic/febe-ci/{versione} la versione con i suoi file (204)
|
||||
# solo con la forma <x.y.z>-ci.<n> o <x.y.z>-rilascio.<n>, ricontrollata prima di ogni DELETE.
|
||||
# DELETE /api/v1/packages/{proprietario}/generic/febe-ci/{versione} the version with its files (204)
|
||||
# only with the form <x.y.z>-ci.<n> or <x.y.z>-rilascio.<n>, checked again before every DELETE.
|
||||
registro() {
|
||||
local tenere=10
|
||||
echo "== Registro: le etichette sha- del pacchetto febe oltre le $tenere più recenti"
|
||||
@@ -737,9 +736,9 @@ registro() {
|
||||
artefatti_della_ci
|
||||
}
|
||||
|
||||
# Le pagine delle versioni di un pacchetto nella cartella, pagina-<n>.json, fino alla prima vuota (il server può darne
|
||||
# meno di 50 per pagina). Esce con 0 se le ha lette, 1 se il pacchetto non c'è (404 alla prima pagina), 2 se l'API
|
||||
# rifiuta (e lo segnala).
|
||||
# The pages of the versions of a package in the folder, pagina-<n>.json, up to the first empty one (the server may give
|
||||
# fewer than 50 per page). Exits with 0 if it read them, 1 if the package is not there (404 on the first page), 2 if
|
||||
# the API refuses (and reports it).
|
||||
pagine() {
|
||||
local base="$1" cartella="$2" nome="$3" pagina codice
|
||||
for ((pagina = 1; ; pagina++)); do
|
||||
@@ -761,7 +760,7 @@ pagine() {
|
||||
done
|
||||
}
|
||||
|
||||
# Le etichette sha- del contenitore febe, dalle pagine già lette.
|
||||
# The sha- tags of the febe container, from the pages already read.
|
||||
contenitore() {
|
||||
local base="$1" cartella="$2" scelte senza_etichetta quante codice
|
||||
if ! scelte=$(bash "$cartella_script/versioni-registro.sh" "$tenere" "$cartella"/pagina-*.json) \
|
||||
@@ -800,8 +799,8 @@ contenitore() {
|
||||
done <<< "$scelte"
|
||||
}
|
||||
|
||||
# Gli artefatti della CI (artefatti.sh): le versioni del pacchetto generico febe-ci create più di 14 giorni fa, come la
|
||||
# scadenza degli artefatti di una volta.
|
||||
# The CI artifacts (artefatti.sh): the versions of the generic febe-ci package created more than 14 days ago, like the
|
||||
# artifact expiry of the old days.
|
||||
artefatti_della_ci() {
|
||||
local giorni=14 base="${GITEA_API%/}/packages/$PROPRIETARIO/generic/febe-ci" cartella esito scelte versione creata codice
|
||||
echo "== Registro: gli artefatti della CI (pacchetto febe-ci) creati più di $giorni giorni fa"
|
||||
@@ -841,8 +840,8 @@ artefatti_della_ci() {
|
||||
done <<< "$scelte"
|
||||
}
|
||||
|
||||
# La cache con lo stesso limite del lunedì: senza, a ogni push di ogni ramo se ne andrebbero gli strati intermedi e le
|
||||
# cache montate (RUN --mount=type=cache) che le costruzioni degli altri progetti hanno appena usato.
|
||||
# The cache with the same limit as on Monday: without it, every push of every branch would remove the intermediate
|
||||
# layers and the mounted caches (RUN --mount=type=cache) that the builds of the other projects have just used.
|
||||
penzolanti() {
|
||||
echo "== Immagini senza nome che nessun contenitore usa e cache di costruzione penzolante non usata da 24 ore, di tutti i progetti"
|
||||
if ((prova)); then
|
||||
@@ -864,9 +863,9 @@ settimanale() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Tutto ciò che fa «settimanale» (le immagini senza nome più vecchie di 72 ore sono fra quelle che nessun contenitore
|
||||
# usa create più di 24 ore fa) e in più i resti di act_runner, le immagini e la cache di tutti e il registro. Prima i
|
||||
# contenitori, così le loro immagini, i loro volumi e le loro reti restano senza nessuno che li usi.
|
||||
# Everything «settimanale» does (the unnamed images older than 72 hours are among those no container uses created
|
||||
# more than 24 hours ago) plus the act_runner leftovers, everyone's images and cache, and the registry. Containers
|
||||
# first, so that their images, volumes and networks are left with nobody using them.
|
||||
completa() {
|
||||
resti_della_ci
|
||||
resti_di_act_runner 90
|
||||
|
||||
Reference in new issue
Block a user