~rjarry/dlrepo

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
9 3

[PATCH dlrepo 0/3] fmt: rework set/delete restrictions

Details
Message ID
<20240124133918.1855533-1-julien.floret@6wind.com>
DKIM signature
pass
Download raw message
Patches 1 and 2 add missing restrictions on deleting a job format.
Patch 3 is for allowing modification of an internal format even when the
job is locked.

Julien Floret (3):
  fmt: refuse deletion in product view
  fmt: refuse deletion if job is locked
  fmt: allow modifying internal format in locked job

 dlrepo/views/artifact.py |  2 +-
 dlrepo/views/fmt.py      | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.39.2

[PATCH dlrepo 1/3] fmt: refuse deletion in product view

Details
Message ID
<20240124133918.1855533-2-julien.floret@6wind.com>
In-Reply-To
<20240124133918.1855533-1-julien.floret@6wind.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +4 -2
Deleting product formats is not supported.

Fixes: 6de1f15cfcf8 ("format: add delete method")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
---
 dlrepo/views/fmt.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlrepo/views/fmt.py b/dlrepo/views/fmt.py
index 33876764141c..fca4ae4cdc8b 100644
--- a/dlrepo/views/fmt.py
+++ b/dlrepo/views/fmt.py
@@ -78,7 +78,7 @@ class FormatDirView(BaseView):
        """
        loop = asyncio.get_running_loop()
        try:
            fmt = _get_format(self.repo(), self.request.match_info)
            fmt = _get_format(self.repo(), self.request.match_info, delete=True)
            await loop.run_in_executor(None, fmt.delete)
            self.repo().schedule_cleanup_orphans()
        except FileNotFoundError as e:
@@ -175,9 +175,11 @@ class FormatFileView(BaseView):


# --------------------------------------------------------------------------------------
def _get_format(repo, match_info, access_cb: Callable[[str], bool] = None):
def _get_format(repo, match_info, access_cb: Callable[[str], bool] = None, delete=False):
    try:
        if "product" in match_info:
            if delete:
                raise web.HTTPBadRequest(reason="Deleting product formats is not supported")
            fmt = (
                repo.get_product(match_info["product"])
                .get_variant(match_info["variant"])
-- 
2.39.2

[PATCH dlrepo 2/3] fmt: refuse deletion if job is locked

Details
Message ID
<20240124133918.1855533-3-julien.floret@6wind.com>
In-Reply-To
<20240124133918.1855533-1-julien.floret@6wind.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +4 -2
A format should not be deleted in a locked job.

Fixes: 6de1f15cfcf8 ("format: add delete method")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
---
 dlrepo/views/fmt.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlrepo/views/fmt.py b/dlrepo/views/fmt.py
index fca4ae4cdc8b..654d30468f77 100644
--- a/dlrepo/views/fmt.py
+++ b/dlrepo/views/fmt.py
@@ -188,12 +188,14 @@ def _get_format(repo, match_info, access_cb: Callable[[str], bool] = None, delet
                .get_format(match_info["format"])
            )
        else:
            fmt = (
            job = (
                repo.get_branch(match_info["branch"])
                .get_tag(match_info["tag"], access_cb)
                .get_job(match_info["job"])
                .get_format(match_info["format"])
            )
            fmt = job.get_format(match_info["format"])
            if delete and job.is_locked():
                raise web.HTTPBadRequest(reason="Cannot delete format: job is locked")
    except FileNotFoundError as e:
        raise web.HTTPNotFound() from e
    if not fmt.exists():
-- 
2.39.2

[PATCH dlrepo 3/3] fmt: allow modifying internal format in locked job

Details
Message ID
<20240124133918.1855533-4-julien.floret@6wind.com>
In-Reply-To
<20240124133918.1855533-1-julien.floret@6wind.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +2 -2
Internal formats are not released and are not included in the
calculation of the job digest.
They can then be safely added to or deleted from a locked job, without
needing to unlock it prior, so the uploader will not need the "update"
access, only the "add" access.

It is useful to add extra info after a job has been released, like
test results, or transient data like CVE scans updated daily with an
up-to-date vulnerability database, without giving too many permissions
to the uploader.

Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
---
 dlrepo/views/artifact.py | 2 +-
 dlrepo/views/fmt.py      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlrepo/views/artifact.py b/dlrepo/views/artifact.py
index a6bf70a99442..dcd40ca992d2 100644
--- a/dlrepo/views/artifact.py
+++ b/dlrepo/views/artifact.py
@@ -61,7 +61,7 @@ class ArtifactView(BaseView):
                        raise web.HTTPBadRequest(
                            reason="Uploading container images must be done with docker push"
                        )
                if job.is_locked():
                if job.is_locked() and not fmt.is_internal():
                    raise web.HTTPBadRequest(
                        reason="Cannot upload files in locked jobs"
                    )
diff --git a/dlrepo/views/fmt.py b/dlrepo/views/fmt.py
index 654d30468f77..c4bba26488ec 100644
--- a/dlrepo/views/fmt.py
+++ b/dlrepo/views/fmt.py
@@ -194,7 +194,7 @@ def _get_format(repo, match_info, access_cb: Callable[[str], bool] = None, delet
                .get_job(match_info["job"])
            )
            fmt = job.get_format(match_info["format"])
            if delete and job.is_locked():
            if delete and job.is_locked() and not fmt.is_internal():
                raise web.HTTPBadRequest(reason="Cannot delete format: job is locked")
    except FileNotFoundError as e:
        raise web.HTTPNotFound() from e
-- 
2.39.2

[dlrepo/patches/.build.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CYMZ94VG7R8C.MOR51SWMMX77@fra01>
In-Reply-To
<20240124133918.1855533-4-julien.floret@6wind.com> (view parent)
DKIM signature
missing
Download raw message
dlrepo/patches/.build.yml: FAILED in 32s

[fmt: rework set/delete restrictions][0] from [Julien Floret][1]

[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/48858
[1]: julien.floret@6wind.com

✗ #1137027 FAILED dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/1137027

Re: [PATCH dlrepo 1/3] fmt: refuse deletion in product view

Details
Message ID
<CAHfJR7jOGsh8KHHeorz1PaC_-UGfssC_Q1=fU8gYJQfXX_a7WA@mail.gmail.com>
In-Reply-To
<20240124133918.1855533-2-julien.floret@6wind.com> (view parent)
DKIM signature
pass
Download raw message
Hi,

Oops, I forgot to run "make lint". The changes made by black are
trivial formatting of long lines in patch 1.
Robin, do you want me to send a v2 of this series?

Julien


Le mer. 24 janv. 2024 à 14:39, Julien Floret <julien.floret@6wind.com> a écrit :
>
> Deleting product formats is not supported.
>
> Fixes: 6de1f15cfcf8 ("format: add delete method")
> Signed-off-by: Julien Floret <julien.floret@6wind.com>
> Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
> ---
>  dlrepo/views/fmt.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/dlrepo/views/fmt.py b/dlrepo/views/fmt.py
> index 33876764141c..fca4ae4cdc8b 100644
> --- a/dlrepo/views/fmt.py
> +++ b/dlrepo/views/fmt.py
> @@ -78,7 +78,7 @@ class FormatDirView(BaseView):
>          """
>          loop = asyncio.get_running_loop()
>          try:
> -            fmt = _get_format(self.repo(), self.request.match_info)
> +            fmt = _get_format(self.repo(), self.request.match_info, delete=True)
>              await loop.run_in_executor(None, fmt.delete)
>              self.repo().schedule_cleanup_orphans()
>          except FileNotFoundError as e:
> @@ -175,9 +175,11 @@ class FormatFileView(BaseView):
>
>
>  # --------------------------------------------------------------------------------------
> -def _get_format(repo, match_info, access_cb: Callable[[str], bool] = None):
> +def _get_format(repo, match_info, access_cb: Callable[[str], bool] = None, delete=False):
>      try:
>          if "product" in match_info:
> +            if delete:
> +                raise web.HTTPBadRequest(reason="Deleting product formats is not supported")
>              fmt = (
>                  repo.get_product(match_info["product"])
>                  .get_variant(match_info["variant"])
> --
> 2.39.2
>

Re: [PATCH dlrepo 1/3] fmt: refuse deletion in product view

Details
Message ID
<CYN7F337I5XE.13YYL6ENSC62K@ringo>
In-Reply-To
<CAHfJR7jOGsh8KHHeorz1PaC_-UGfssC_Q1=fU8gYJQfXX_a7WA@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Julien Floret, Jan 24, 2024 at 14:55:
> Oops, I forgot to run "make lint". The changes made by black are
> trivial formatting of long lines in patch 1.
> Robin, do you want me to send a v2 of this series?

Hi :)

No need, I'll reformat when applying.

Thanks!

Applied: [PATCH dlrepo 0/3] fmt: rework set/delete restrictions

Details
Message ID
<170612661415.37491.10007273497012137058@ringo>
In-Reply-To
<20240124133918.1855533-1-julien.floret@6wind.com> (view parent)
DKIM signature
pass
Download raw message
Julien Floret <julien.floret@6wind.com> wrote:
> Patches 1 and 2 add missing restrictions on deleting a job format.
> Patch 3 is for allowing modification of an internal format even when the
> job is locked.
>
> Julien Floret (3):
>   fmt: refuse deletion in product view
>   fmt: refuse deletion if job is locked
>   fmt: allow modifying internal format in locked job

Acked-by: Robin Jarry <robin@jarry.cc>

Applied, thanks.

To git@git.sr.ht:~rjarry/dlrepo
   978cf6f1da6a..32cafdf9c378  main -> main

Re: Applied: [PATCH dlrepo 0/3] fmt: rework set/delete restrictions

Details
Message ID
<CAHfJR7inw-5-f8WJ0nwcudP9R24FuXhVCA_8tM5-s-4K73467A@mail.gmail.com>
In-Reply-To
<170612661415.37491.10007273497012137058@ringo> (view parent)
DKIM signature
pass
Download raw message
Le mer. 24 janv. 2024 à 21:08, Robin Jarry <robin@jarry.cc> a écrit :
>
> Julien Floret <julien.floret@6wind.com> wrote:
> > Patches 1 and 2 add missing restrictions on deleting a job format.
> > Patch 3 is for allowing modification of an internal format even when the
> > job is locked.
> >
> > Julien Floret (3):
> >   fmt: refuse deletion in product view
> >   fmt: refuse deletion if job is locked
> >   fmt: allow modifying internal format in locked job
>
> Acked-by: Robin Jarry <robin@jarry.cc>
>
> Applied, thanks.

Thanks a lot!
Do you plan to release a v0.38 after this series?

Re: Applied: [PATCH dlrepo 0/3] fmt: rework set/delete restrictions

Details
Message ID
<CYOPB1HA9HJ8.CKME3BWWHCEA@ringo>
In-Reply-To
<CAHfJR7inw-5-f8WJ0nwcudP9R24FuXhVCA_8tM5-s-4K73467A@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Julien Floret, Jan 26, 2024 at 14:33:
> Thanks a lot!
> Do you plan to release a v0.38 after this series?

Damn, I had forgotten to tag. This is now done.

https://lists.sr.ht/~rjarry/dlrepo/%3C20240126141639.Y6Q3BTOT7P7Y%40build%3E
Reply to thread Export thread (mbox)