Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python hooks reloaded #747

Merged
merged 6 commits into from Aug 31, 2019
Merged

Python hooks reloaded #747

merged 6 commits into from Aug 31, 2019

Conversation

alexAubin
Copy link
Member

The problem

This is a rewrite of #535 because there were too many changes ... :

Python hooks are required for the new diagnosis system modularity / extendability, and more generally if we want to implement some hooks in python for some reason. This could be the case for example of the famous app ssowatconf command which should be a classical regen-conf thing but can't be so far because it has too many python calls and json stuff to be implemented in bash.

Solution

Split the behavior of the hook_exec function depending on the nature of the hook. Python hooks are to be modules loaded by yunohost and expected to have a main function.

PR Status

Tested and working

How to test

Create some hook with a main function (e.g. just displaying hello world) and call yunohost hook list your_hook_type and yunohost diagnosis callback your_hook_type

Validation

  • Principle agreement 0/2 :
  • Quick review 0/1 :
  • Simple test 0/1 :
  • Deep review 0/1 :

@alexAubin alexAubin added this to the 3.7.x milestone Jul 6, 2019
@alexAubin alexAubin mentioned this pull request Jul 6, 2019
4 tasks
src/yunohost/hook.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Josue-T Josue-T left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't tested, but look good to me.

@alexAubin
Copy link
Member Author

Merging soonish

src/yunohost/hook.py Outdated Show resolved Hide resolved
src/yunohost/hook.py Outdated Show resolved Hide resolved

# TODO : We might want to check here that it's a tuple
# containing an int + a dict ?
ret = module.main(args, env, loggers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we spawn a new python process that launch the python instead of calling it in the current python process? That would be better security and bug wise I think (but idk how hard would it be to do that)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I kinda chose to do this because that's supposedly less ressource expensive, considering that we're likely to import code from yunohost's in each of those (e.g. 10~15ish hooks in the context of diagnosis), each likely to do stuff like importing requests or other libs that take hell of time to load on RPi for example

@alexAubin
Copy link
Member Author

Proposing to merge soonish in 3.7 (not really needed or anything but at least that becomes stable code upon which the migration mechanism can be built and possibly other things)

@alexAubin alexAubin merged commit a208763 into stretch-unstable Aug 31, 2019
@alexAubin alexAubin deleted the python-hooks-reloaded branch August 31, 2019 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants