#4381 Support deployments where git hook have a read-only access to the db
Merged by pingou. Opened by pingou.
git_hook_db_ro  into  master

Download 4381.patch

As the update to the documentation in this commit explain, some pagure
deployment are not using the standard gitolite deployment method and
thus for security reasons, the git hook are only given a read-only
access to the database.
This new configuration allows for pagure to behave differently if the
database access is read-only or read-write.

In this case, the default hook which clears the cache status of all
the open PRs of a project upon push to its git repo requires read-
write access (otherwise it can't clear the cache status). So if the
hook as read-only access to the DB, this action is proceed by a
worker, asynchronously instead of being done in the same process as
the push.
This could lead to some race conditions but there isn't much we can
do with these constraints.

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

@fbo this may interest you

@smooge this will allow us to drop our hotfix for the default hook from ansible (in 5.5)

:thumbsup:

rebased onto 5c0786e222656d1f47cdd1474e9965cdeb3b5436

I'm surprising that you can access the delay function like this:

>>> def boum():
...     print("boum")
... 
>>> def bam():
...     print("bam")
...     bam.boum()
... 
>>> bam.boum()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'boum'

but maybe I'm wrong

@hberaud it's the mechanism that turns the function into an async celery task :)

Which means, instead of executing the task in the same process as the git push, it'll be executed by a worker in a different process (one that will have read/write access to the DB)

Pull-Request has been merged by pingou

:thumbsup:

Metadata