Bug 51790 - Execute custom hook scripts after app install/update/remove
Execute custom hook scripts after app install/update/remove
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: App Center
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-5-errata
Assigned To: Max Pohle
Felix Botner
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-08-07 21:35 CEST by Max Pohle
Modified: 2020-09-14 12:42 CEST (History)
5 users (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Max Pohle univentionstaff 2020-08-07 21:35:53 CEST
In order to automate several repeating administrative tasks this feature was requested.
Comment 1 Max Pohle univentionstaff 2020-08-07 21:41:36 CEST
A first solution can be found in commit d9ad58e8cd and is ready for QA. Thanks to everyone!
Comment 2 Julia Bremer univentionstaff 2020-08-08 19:20:55 CEST
Package: ucs-test
Version: 9.0.4-35A~4.4.0.202008081905
Branch: ucs_4.4-0
Scope: errata4.4-5
User: jbremer

Successful build
Package: univention-appcenter
Version: 8.0.11-133A~4.4.0.202008072223
Branch: ucs_4.4-0
Scope: errata4.4-5
User: jbremer

---------------------------
What I tested: 

Hook scripts get executed on:
install : OK
upgrade : OK
remove : OK

Code review: OK
Docu: Easy to follow and to understand: OK

Test case:
I made some changes because some imports were missing and the test failed on upgrade:

ea76aad99c Bug #51790: 69_app_install_update_remove_hooks - fix error on upgrade
d4209f7d45 Bug #51790: Test-case: Fix indentation, import error and example hook files.

I also added the advisory:
3e598b8ce4 Bug #51690: yaml
------------------------------

TODO: Wait for nightly test result and final QA from someone who knows the appcenter well.
Comment 3 Felix Botner univentionstaff 2020-08-09 14:12:49 CEST
* please use run-parts for the hook-directory
* rename call_all_hooks to call_post_hooks, maybe we add other hooks in the future
* remove the line
 from subprocess import call  # `call` with python3.5 should be replaced with `run`
 ("call" is unused)
* you added "_call_all_hooks" to the base class, isn't it now the case that the hook is called for every action, not just install/remove/upgrade?
Comment 4 Florian Best univentionstaff 2020-08-10 06:57:31 CEST
REOPEN:
management/univention-appcenter/python/appcenter/actions/install_base.py|194 col 16 error| undefined name 'action' [F821]
Comment 5 Max Pohle univentionstaff 2020-08-24 10:53:16 CEST
Changes integrated in 4cee03d480 (after a revert of the previous version)
Comment 6 Julia Bremer univentionstaff 2020-08-24 12:17:25 CEST
Hook scripts are executed after install/upgrade/remove action: OK

Test: FAIL
ucs-test was not built since the addition of the new test case. The test has 
not been run in jenkins for that reason.
Executing the test manually leads to 

File "69_app_install_update_remove_hooks_orig", line 83
    with app as App(
SyntaxError: can't assign to function call

so the test needs to be fixed and ucs-test should be built.


Documentation: FAIL
Since run-parts is used, only files with certain names are executed. E.g test.sh will not be executed. 
This should be well documented and/or a warning should be displayed/logged.

-> reopen
Comment 7 Philipp Hahn univentionstaff 2020-08-29 13:57:30 CEST
[4.4-5] bff63ba6e3 Bug #51790 doc: Fix spelling mistakes
 doc/manual/software-de.xml | 14 +++++++-------
 doc/manual/software-en.xml |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

Please check for spelling mistakes too next time: <https://hutten.knut.univention.de/mediawiki/index.php/Docbook#Rechtschreibpr.C3.BCfung>

Please use a separate branch as this change blocks other changes now: <https://jenkins.knut.univention.de:8181/view/Doku/job/BuildDocBookBranch/>
Comment 8 Max Pohle univentionstaff 2020-09-01 13:37:43 CEST
product: ucs
release: "4.4"
version: [5]
scope: ucs_4.4-0-errata4.4-5
src: ucs-test
fix: 9.0.4-50A~4.4.5.202009011049


@Philipp: Further improved documentation, used the docker image for spell checks. Works great. Thanks!
Comment 9 Felix Botner univentionstaff 2020-09-01 13:51:50 CEST
Please add something like this to the documentation

 Die Skripte müssen ausführbar sein und werden über "run-parts" gestartet 
 (Dateinamen dürfen nur aus Kleinbuchst ...)
Comment 10 Max Pohle univentionstaff 2020-09-01 14:17:13 CEST
@Felix: done.
Comment 11 Max Pohle univentionstaff 2020-09-01 15:26:13 CEST
Fixed test description and made the calling logic for script hooks more generic after a qa suggestion. Thanks to Felix.

Latest version is now:

ucs-test: 9.0.4-51A~4.4.5.202009011518
univention-appcenter: 8.0.11-136A~4.4.5.202009011518
Comment 12 Felix Botner univentionstaff 2020-09-01 15:35:57 CEST
OK - univention-appcenter (hooks)
OK - yaml
OK - documentation
OK - test
TODO - Jenkins
Comment 13 Felix Botner univentionstaff 2020-09-02 09:54:14 CEST
OK - Jenkins