dlrepo: container: fix push over an existing tag v1 APPLIED

Robin Jarry: 1
 container: fix push over an existing tag

 1 files changed, 4 insertions(+), 1 deletions(-)
#966193 .build.yml success
Julien Floret, Apr 04, 2023 at 14:19:
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rjarry/dlrepo/patches/40109/mbox | git am -3
Learn more about email & git

[PATCH dlrepo] container: fix push over an existing tag Export this patch

When pushing a different manifest (different sha256) over an existing
tag and trying to pull from it afterwards the client gets an error:

  Unknown manifest in registry.

Even if pushing over an existing tag seems like a bad idea, it is
supported by the official docker registry.

The issue is that leftovers from the previous manifest are still present
in the container format folder which causes dlrepo to return an error
(two files matching container/manifests/*/*/*). This was never expected
to happen.

When uploading a new manifest, make sure to delete everything related to
it (manifest, layers and config) so that only the new files are present
in the container format.
Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
 dlrepo/fs/container.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlrepo/fs/container.py b/dlrepo/fs/container.py
index 4a6dde01e6d9..fa79aa6b7423 100644
--- a/dlrepo/fs/container.py
+++ b/dlrepo/fs/container.py
@@ -67,7 +67,7 @@ class ContainerRegistry:
        if not parent_path.is_dir():
            raise FileNotFoundError()
        files = list(parent_path.glob("container/manifests/*/*/*"))
        if len(files) != 1:
        if not files:
            raise FileNotFoundError()
        if not files[0].is_file():
            raise FileNotFoundError()
@@ -100,6 +100,9 @@ class ContainerRegistry:

        # link config blob into the job folder
        fmt_dir = job.path() / "container"
        if fmt_dir.is_dir():
        config = manifest.get("config", {})
        config["size"] = self._link_blob_to_job(config.get("digest"), job)

dlrepo/patches/.build.yml: SUCCESS in 1m35s

[container: fix push over an existing tag][0] from [Robin Jarry][1]

[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/40109
[1]: mailto:robin@jarry.cc

✓ #966193 SUCCESS dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/966193

Le sam. 1 avr. 2023 à 00:41, Robin Jarry <robin@jarry.cc> a écrit :