Pulizia: dice quale store delle immagini usa il demone, da cui dipendono le 24 ore

I documenti dicevano che le 24 ore di «image prune --filter until»
contano sempre dalla costruzione dell'immagine. Vale solo con lo store
classico; con quello di containerd, predefinito nelle installazioni
nuove di Docker Engine dalla 29, Docker confronta il momento in cui il
nome è arrivato sul demone, che un nuovo pull dello stesso nome non
cambia. La prova invece calcola l'età dalla costruzione, quindi con
containerd prova e pulizia vera possono non coincidere, nei due sensi
(rilievo della revisione, controllato sul codice di moby).

Nei modi «settimanale» e «completa» la pulizia legge lo store con
docker info e lo scrive all'inizio; con containerd, o se docker info non
risponde, la prova avverte che le età che elenca sono solo indicative.
docs/processo.md dice come vanno le cose con l'uno e con l'altro, anche
per le immagini costruite con una data fissa. Il demone finto delle
prove sa rispondere come l'uno e come l'altro.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-21 11:45:43 +02:00
1 parent 483d57b89a
commit e24ebd24f0
5 files changed
+78 -3

No files matched your search

@@ -329,9 +329,11 @@ public sealed partial class PipelineTests
Assert.DoesNotContain(RegistryToken, tried.Output + tried.Errors, "the token never reaches the log");
// What it lists, with size and age: also what becomes unused once the leftovers it lists are gone.
Assert.DoesNotContain("solo indicativo", tried.Output, "with the classic store the ages are those «until» uses");
foreach (var expected in new[]
{
"Prova: elenco che cosa toglierei, senza togliere nulla.",
"== Store delle immagini del demone: classico (le 24 ore contano dalla costruzione dell'immagine)\n",
" toglierei il contenitore febe-prova-555\n",
" toglierei il contenitore GITEA-ACTIONS-TASK-53_WORKFLOW-verifica_JOB-prove\n",
" toglierei il volume GITEA-ACTIONS-TASK-53_WORKFLOW-verifica_JOB-prove-env\n",
@@ -362,6 +364,20 @@ public sealed partial class PipelineTests
}
}
[TestMethod]
[Timeout(300_000, CooperativeCancellation = true)]
public async Task OnTheContainerdStoreTheCleanupSaysSoAndTheAgesOfTheDryRunAreOnlyIndicative()
{
// With the containerd image store «until» counts from when a name reached the daemon, which no command shows;
// the dry run can only give the age of the image and must say so.
var bash = RequireBash();
var tried = await RunCleanupAsync(bash, SharedDaemon.World with { Store = "containerd" }, "completa", "--prova");
Assert.AreEqual(0, tried.Code, tried.Report);
StringAssert.Contains(tried.Output, "== Store delle immagini del demone: containerd (le 24 ore contano da quando un nome è arrivato sul demone)\n", tried.Report);
StringAssert.Contains(tried.Output, "l'elenco è solo indicativo)", tried.Report);
CollectionAssert.Contains(tried.Calls, "BUILDX_BUILDER=default docker info --format {{json .DriverStatus}}", "the store is read, never changed");
}
[TestMethod]
public void TheImageIsAPlainManifestSoRemovingATagFromTheRegistryFreesItsLayers()
{
@@ -660,6 +676,9 @@ public sealed partial class PipelineTests
/// <summary>The registry; without it the cleanup runs with no REGISTRY_TOKEN.</summary>
public FakeRegistry? Registry { get; init; }
/// <summary>«containerd» for the containerd image store; null for the classic one.</summary>
public string? Store { get; init; }
}
/// <summary>
@@ -727,6 +746,11 @@ public sealed partial class PipelineTests
await WriteLinesAsync(folder.Combine("broken"), world.Broken);
}
if (world.Store is { } store)
{
await WriteLinesAsync(folder.Combine("store"), [store]);
}
if (world.Registry is { } fake)
{
InstallFake("fake-curl.sh", Path.Combine(bin, "curl"));
+18
View File
@@ -25,6 +25,8 @@
# $FAKE_DOCKER_WORLD/images id|names (comma separated; empty: dangling)|minutes ago|labels|size
# $FAKE_DOCKER_WORLD/volumes name|minutes ago (missing: just created)
# $FAKE_DOCKER_WORLD/networks id|name|minutes ago
# $FAKE_DOCKER_WORLD/store optional: «containerd» for the containerd image store (what «docker info» says);
# otherwise the classic store of overlay2
# $FAKE_DOCKER_WORLD/broken optional: commands («image prune», «builder prune») that fail as if the daemon refused
# $FAKE_DOCKER_WORLD/calls every call, one per line (written here), after BUILDX_BUILDER=<value> when it is set
set -uo pipefail
@@ -463,6 +465,21 @@ network_rm() {
drop "$world/networks" "$id"
}
store() {
if [[ "$(cat "$world/store" 2> /dev/null)" == containerd ]]; then echo containerd; else echo classic; fi
}
# The DriverStatus of «docker info» as Docker prints it: with the containerd image store the snapshotter, with the
# classic one the details of overlay2.
info_command() {
[[ "$*" == "--format {{json .DriverStatus}}" ]] || unexpected "info $*"
if [[ "$(store)" == containerd ]]; then
echo '[["driver-type","io.containerd.snapshotter.v1"]]'
else
echo '[["Backing Filesystem","extfs"],["Supports d_type","true"],["Using metacopy","false"],["Native Overlay Diff","true"],["userxattr","false"]]'
fi
}
system_df() {
case "$*" in
"") echo "TYPE TOTAL ACTIVE SIZE RECLAIMABLE" ;;
@@ -511,5 +528,6 @@ case "${1:-}" in
esac
;;
system) [[ "${2:-}" == df ]] || unexpected "$*"; shift 2; system_df "$@" ;;
info) shift; info_command "$@" ;;
*) unexpected "$*" ;;
esac