Immagine: un manifest semplice, così togliere una :sha- libera gli strati
Con il builder docker-container buildx aggiunge da sé l'attestazione di provenienza, e l'immagine spinta sul registro è un indice. Gitea tiene ogni manifest figlio come una versione a sé, sha256:… senza etichetta, con la configurazione e gli strati: la pulizia del lunedì toglieva solo l'indice delle :sha- vecchie e gli strati restavano per sempre, mentre i documenti dicevano che il registro si alleggeriva (rilievo della revisione, controllato sul codice di Gitea release/v28). costruisci-immagine.sh costruisce con --provenance=false --sbom=false, sia l'archivio provato sia l'immagine spinta: ogni etichetta è un manifest semplice che tiene i suoi strati, e quando nessuna versione li usa più li cancella la pulizia notturna dei pacchetti di Gitea. Le versioni sha256:… lo script non le tocca mai, perché l'API non dice se un indice le rimanda, ma ne scrive il numero, anche nella prova (versioni-registro.js senza-etichetta); docs/processo.md dice quale regola di pulizia di Gitea le toglie se compaiono. La CI non ha ancora pubblicato nulla, perché manca REGISTRY_TOKEN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46d780c826
commit
086b603801
7 files changed
+120
-25
No files matched your search
@@ -26,6 +26,14 @@ public sealed partial class PipelineTests
|
||||
/// <summary>The tags versioni-registro.json leaves to the cleanup once the ten newest sha- are kept, oldest first.</summary>
|
||||
private static readonly string[] OldShaTags = ["sha-0a1b2c3", "sha-1b2c3d4", "sha-2c3d4e5", "sha-4e5f6a7"];
|
||||
|
||||
/// <summary>The untagged versions of the container febe in versioni-registro.json (manifests of an index), oldest first.</summary>
|
||||
private static readonly string[] UntaggedDigests =
|
||||
[
|
||||
"sha256:4f3c2b1a0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b",
|
||||
"sha256:7c39e42c6e919ae17c7dfa17bd5fcf8cd38fa29c02be97e2b0134947b4674f3c",
|
||||
"sha256:d0e666bf0a465af6218c1825f3fd72143e2f9ddfc038a8cda19b0504656e0647",
|
||||
];
|
||||
|
||||
[TestMethod]
|
||||
public void TheCleanupNeverPrunesBlindlyAndChoosesOnlyByTheMarksOfTheCiOrByUse()
|
||||
{
|
||||
@@ -332,6 +340,7 @@ public sealed partial class PipelineTests
|
||||
" toglierei un'immagine senza nome (img-plex-pre) · 300MB · creata 69 giorni fa\n",
|
||||
"la cache di costruzione del demone occupa 5.3GB",
|
||||
" toglierei sha-4e5f6a7 (pubblicata il 2026-10-05T01:00:00+02:00)\n",
|
||||
$" {UntaggedDigests.Length} versioni senza etichetta (sha256:…",
|
||||
"== Riepilogo della prova",
|
||||
})
|
||||
{
|
||||
@@ -352,6 +361,23 @@ public sealed partial class PipelineTests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TheImageIsAPlainManifestSoRemovingATagFromTheRegistryFreesItsLayers()
|
||||
{
|
||||
// With attestations, which buildx adds by itself, the image is an index: Gitea keeps each child manifest as an
|
||||
// untagged sha256: version holding the configuration and the layers, and deleting the tag deletes only the
|
||||
// index. Both builds (the tried archive and the push) share these arguments, so they stay the same image.
|
||||
var build = Code(Script("costruisci-immagine.sh"));
|
||||
var start = build.IndexOf("comuni=(", StringComparison.Ordinal);
|
||||
Assert.IsGreaterThanOrEqualTo(0, start, "costruisci-immagine.sh has no common arguments");
|
||||
var common = build[start..build.IndexOf(')', start)];
|
||||
StringAssert.Contains(common, "--provenance=false");
|
||||
StringAssert.Contains(common, "--sbom=false");
|
||||
Assert.AreEqual(2, Regex.Count(build, @"docker buildx build ""\$\{comuni\[@\]\}"""), "every build uses the common arguments");
|
||||
Assert.DoesNotContain("--platform", build, "more platforms would make an index again");
|
||||
Assert.DoesNotContain("--attest", build);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task TheRegistryKeepsMainLatestTheReleasesAndTheTenNewestShaTags()
|
||||
@@ -377,6 +403,12 @@ public sealed partial class PipelineTests
|
||||
Assert.IsTrue(ShaTagLine().IsMatch(line), line);
|
||||
}
|
||||
|
||||
// The untagged versions, the manifests of an index with their layers: listed only to be counted, oldest first,
|
||||
// those of the container febe and no other package.
|
||||
var untagged = await RunProcessAsync(node, [script, "senza-etichetta", .. pages]);
|
||||
Assert.AreEqual(0, untagged.Code, untagged.Errors);
|
||||
CollectionAssert.AreEqual(UntaggedDigests, Lines(untagged.Output).Select(l => l.Split('\t')[0]).ToList(), untagged.Output);
|
||||
|
||||
// Keeping more than there are: nothing. An empty page of Gitea is fine; a page that is not a list stops
|
||||
// everything, so in doubt nothing goes.
|
||||
var empty = Path.Combine(folder.Path, "vuota.json");
|
||||
@@ -410,6 +442,11 @@ public sealed partial class PipelineTests
|
||||
Assert.DoesNotContain(RegistryToken, run.Output + run.Errors, "the token never reaches the log");
|
||||
Assert.AreEqual("4", SummaryCount(run.Output, "etichette sha- sul registro"), run.Report);
|
||||
|
||||
// The untagged versions stay, and the log says how many there are: their layers are freed only by a cleanup
|
||||
// rule of Gitea, which knows whether a tag still uses them.
|
||||
Assert.IsFalse(run.RegistryCalls.Any(c => c.Contains("sha256:", StringComparison.Ordinal)), run.Report);
|
||||
StringAssert.Contains(run.Output, $" {UntaggedDigests.Length} versioni senza etichetta (sha256:…, i manifest di un indice con i loro strati): restano", run.Report);
|
||||
|
||||
// The API refuses (a token without the permission) or does not know the token: a warning, nothing deleted,
|
||||
// and the weekly job stays green.
|
||||
foreach (var registry in new[] { new FakeRegistry(RegistryToken, Refuse: true), new FakeRegistry(RegistryToken, Sent: "un-altro-gettone-finto") })
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
[
|
||||
[
|
||||
{"id": 140, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "main", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/main", "created_at": "2026-10-20T19:42:15+02:00"},
|
||||
{"id": 142, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "sha256:d0e666bf0a465af6218c1825f3fd72143e2f9ddfc038a8cda19b0504656e0647", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/sha256:d0e666bf0a465af6218c1825f3fd72143e2f9ddfc038a8cda19b0504656e0647", "created_at": "2026-10-20T19:42:09+02:00"},
|
||||
{"id": 141, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "sha256:7c39e42c6e919ae17c7dfa17bd5fcf8cd38fa29c02be97e2b0134947b4674f3c", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/sha256:7c39e42c6e919ae17c7dfa17bd5fcf8cd38fa29c02be97e2b0134947b4674f3c", "created_at": "2026-10-20T19:42:09+02:00"},
|
||||
{"id": 139, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "sha-d0a3b4c5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/sha-d0a3b4c5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1", "created_at": "2026-10-20T19:42:11+02:00"},
|
||||
{"id": 138, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "0.1.1", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/0.1.1", "created_at": "2026-10-20T18:05:00+02:00"},
|
||||
{"id": 137, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "latest", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/latest", "created_at": "2026-10-14T10:00:00+02:00"},
|
||||
@@ -28,6 +30,7 @@
|
||||
{"id": 95, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "sha-ABCDEF0", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/sha-ABCDEF0", "created_at": "2026-09-01T09:00:00+02:00"},
|
||||
{"id": 94, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe", "version": "sha-e1f2a3b4", "html_url": "https://gitea.example/Alby96/-/packages/container/febe/sha-e1f2a3b4"},
|
||||
{"id": 93, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe-strumenti", "version": "sha-0000000", "html_url": "https://gitea.example/Alby96/-/packages/container/febe-strumenti/sha-0000000", "created_at": "2026-08-01T09:00:00+02:00"},
|
||||
{"id": 91, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "container", "name": "febe-strumenti", "version": "sha256:48f76e113cd23ae3e60a2657cf0f84618fce331ef675e8ea39527ba0937b34d0", "html_url": "https://gitea.example/Alby96/-/packages/container/febe-strumenti/sha256:48f76e113cd23ae3e60a2657cf0f84618fce331ef675e8ea39527ba0937b34d0", "created_at": "2026-08-01T09:00:00+02:00"},
|
||||
{"id": 92, "owner": {"id": 1, "login": "Alby96"}, "repository": null, "creator": {"id": 1, "login": "Alby96"}, "type": "generic", "name": "febe", "version": "sha-1111111", "html_url": "https://gitea.example/Alby96/-/packages/generic/febe/sha-1111111", "created_at": "2026-08-01T09:00:00+02:00"}
|
||||
]
|
||||
]
|
||||
Reference in new issue
Block a user