Bug 47591 - Send mails in case of errors
Send mails in case of errors
Status: RESOLVED WONTFIX
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.3
Other All
: P5 normal (vote)
: ---
Assigned To: UCS@school maintainers
:
Depends on: 47302
Blocks:
  Show dependency treegraph
 
Reported: 2018-08-15 09:48 CEST by Michael Grandjean
Modified: 2023-06-23 13:15 CEST (History)
3 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?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2018081421000075
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 Michael Grandjean univentionstaff 2018-08-15 09:48:42 CEST
Based on customer feedback:
It should be possible for the UCS@school user import to send an email that lists all errors that occured during the last import run. This would be helpful in scenarios where the import is automated (via cronjob, e.g.).
Comment 1 Daniel Tröder univentionstaff 2018-08-15 10:48:15 CEST

*** This bug has been marked as a duplicate of bug 47302 ***
Comment 2 Sönke Schwardt-Krummrich univentionstaff 2018-08-15 14:45:03 CEST
I'm reopening the bug because the requirements are much higher than what was done with Bug 47302:
1) some tracebacks/exceptions are not caught by the importer and therefore land directly on the command line
2) Tracebacks in hooks are usually not counted as errors and therefore do not appear in the result hook.
Comment 3 Daniel Tröder univentionstaff 2018-08-15 15:17:12 CEST
→ count errors in hooks + pyhooks
→ catch "Exception" and reraise as UcsSchoolImportFatalError
→ add example ResultPyHook that sends an email (UCRV address) in case of exit != 0

Btw: you can achieve that already by creating a cronjob:

/usr/share/ucs-school-import/scripts/ucs-school-user-import args args > /tmp/import.log 2>&1 || uuencode /tmp/import.log | mail -s "import eror" admin@example.com
Comment 4 Daniel Tröder univentionstaff 2018-08-20 10:24:16 CEST
Postponed until prioritized.
Comment 5 Daniel Tröder univentionstaff 2018-08-20 18:07:55 CEST
(In reply to Daniel Tröder from comment #3)
> → add example ResultPyHook that sends an email (UCRV address) in case of
> exit != 0
That's not really possible, as the result hook runs before sys.exit :D
Anyway - an example result hook, generating an email message, has been added to the ucs-school-import package: /usr/share/doc/ucs-school-import/result_hook_example.py
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2018-09-27 10:01:39 CEST
(In reply to Daniel Tröder from comment #5)
> (In reply to Daniel Tröder from comment #3)
> > → add example ResultPyHook that sends an email (UCRV address) in case of
> > exit != 0
> That's not really possible, as the result hook runs before sys.exit :D

What about using a with-statement and a context manager (→ that calls the resultPyHook)?
Comment 7 Daniel Tröder univentionstaff 2018-09-28 14:48:18 CEST
That is not necessary. The result hook has all the data to decide if the import was successful or not (len(errors)>0).
The only errors that are not in 'errors' are unhandled exceptions, but that can easily be fixed.
Comment 8 Jan-Luca Kiok univentionstaff 2023-06-23 13:15:50 CEST
This issue has been filed against UCS 4.3.

UCS 4.3 is out of maintenance and UCS components may have vastly changed in later releases. Thus, this issue is now being closed.

If this issue still occurs in newer UCS versions, please use "Clone this bug" or reopen this issue. In this case please provide detailed information on how this issue is affecting you.