views: fix http error 500 on invalid product link
When the /products/product/variant/branch/ URL does not exist, accessing
/products/product/variant/branch/latest resulted in an HTTP Internal
Error:
Traceback (most recent call last):
...
File "dlrepo/views/product.py", line 178, in get
version = _get_version(
File "dlrepo/views/product.py", line 249, in _get_version
repo.get_product(match_info["product"])
File "dlrepo/fs/product.py", line 79, in get_version
raise FileNotFoundError(name)
FileNotFoundError: latest
Catch the exception to return a 404 error instead.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
fs: fix duplicated user repository objects
Because UserRepository objects contain stateful data (eg disk_usage),
the instances must be created and accessed via the
ArtifactRepository.get_user_repo() method, which handles a persistent
UserRepository dict.
Before this patch however, the UserRepository.all() class method used
to create loose UserRepository objects on demand.
As a consequence, the disk_usage_refresh() method (called by the
periodic fs cleanup) was working on a temporary object, thus the
disk_usage parameter was not properly reset in the "real"
UserRepository object, creating inconsistencies between the content of
".disk_usage" and the value displayed on the web UI.
Fix UserRepository.all() to access the right instances.
Fixes: bd1c23893882 ("server: add filesystem api")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
fs: fix stable info for product version
The ".stable" file is located in the _tag_ related to the product
version, not the job.
Fixes: 880c5ac4b502 ("tag: decorrelate stable and released statuses")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
tar: set members time
In the archives generated by dlrepo, we did not set the modification
time of the tar members, so it was 0 by default. After downloading and
extracting an archive, we could see that the files date was 1970-01-01.
Depending on the time zone, tar may also issue a warning like this:
tar: [...]: implausibly old time stamp 1969-12-31 18:00:00
To keep archives reproducible, let's set the members mtime to the mtime
of the files on the server, or by default to the timestamp of the parent
object (job, version, or format, depending on the requested URL).
Signed-off-by: Robin Jarry <robin@jarry.cc>
Signed-off-by: Julien Floret <julien.floret@6wind.com>
tag: add oldstable alias
Being able to reference the oldstable tag can be handy, for example when
testing upgrade procedures between the old and the new stable versions.
When an URL references the "oldstable" tag keyword, redirect it to the
latest but one stable tag.
"oldstable" links are also added to the HTML templates.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
tag: decorrelate stable and released statuses
Before this patch, an URL referencing the "stable" tag was automatically
redirected to the released tag whose creation date is the most recent.
However, the latest released tag does not necessarily mean it is stable.
It could be a debug version, or a prototype... On the other hand, we may
want to set the next stable version internally before actually releasing
it.
This patchs decorrelates the "released" and "stable" statuses. The
"stable" status can now be set on a tag via the HTTP PUT method, whether
it is released or not, and an URL referencing the "stable" tag is
redirected to the latest stable tag.
The "stable" link in the HTML templates is changed to use the "stable"
status.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
views: use ACLs when resolving tag aliases
Before this patch, when an HTTP request URL was using the
"latest" or "stable" dynamic aliases for tag/versions, the
redirected URL was determined without taking the access rights into
account. Consequently, the request could be redirected to a version not
accessible by the user, who could get an "Authentication Required" in
response.
Ensure the ACLs are checked when determining the candidate tags for
these aliases.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
cli: print target url
Print the target URL before dumping the related info requested.
It can help users navigate between the CLI and the web UI, and prevent
login mistakes too.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
ci: fix deb deliver command
Signed-off-by: Robin Jarry <robin@jarry.cc>
cli: add command to flush user space
It can be tedious for an user to delete all branches in its space.
Let's add a flush command for that. For obvious reasons, flushing the
root database is not allowed.
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
doc: add deb package install procedure
Signed-off-by: Robin Jarry <robin@jarry.cc>
ci: build & deliver packages on official release tags
Generate deb and python packages when the build runs on an official
signed release tag.
Check the deb package with lintian.
Upload the packages on both pypi.org and on the official repo.
Signed-off-by: Robin Jarry <robin@jarry.cc>