On 7/22/21 18:13, A. Klitzing wrote:
By the way... I receive this in my log if I create a new repository
with a clone:
   Fehler: Hook changegroup.kallithea_push_action löste eine Ausnahme
aus: Environment variable KALLITHEA_EXTRAS not found
But the repository works after that.


I have noticed that too.

The hook is called late and is not fatal that the hook fails fatally.

There are some implementation details that make it tricky to fix correctly.

KALLITHEA_EXTRAS is an environment variable used to provide context for Mercurial and Git hooks. It is essentially a global variable that is set in the Kallithea worker process. (That is one of the reasons that we can't use multiple worker threads but have to use separate worker processes.)

KALLITHEA_EXTRAS carry some context information (like username and IP) that most of the app shouldn't care about. It is thus generally set early on in the request processing, so it can be used many levels and fuction calls later.

For repository creation there are many code paths that lead to that code, and it depends on data and disk state whether the repo is created (in which case hooks are invoked and KALLITHEA_EXTRAS is relevant), or if it just use an existing repo (where KALLITHEA_EXTRAS isn't used).

Some ideas for refactorings that could help:

1. Make repository creation explicit. Move it out of MercurialRepository/GitRepository __init__ .... but it currently depends on support from the semi-initialized Repository instance.

2. Pass the hook environment as data through all the layers and avoid setting the environment variable in the worker process ... or set it as late as possible. (For Git, it could just be set in the git subprocess. Mercurial hooks run in the process and might use different tricks.)

But it is also possible that this particular code path can be fixed.

/Mads

_______________________________________________
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general

Reply via email to