Bug 29238 - Cataloging cron jobs are not logged
Summary: Cataloging cron jobs are not logged
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Eric Phetteplace
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-13 21:50 UTC by Eric Phetteplace
Modified: 2024-09-30 21:46 UTC (History)
4 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 29238 - Cataloging cron jobs are not logged (2.80 KB, patch)
2021-10-14 00:03 UTC, Eric Phetteplace
Details | Diff | Splinter Review
Screenshot of the logs (113.02 KB, image/png)
2021-10-14 00:03 UTC, Eric Phetteplace
Details
Bug 29238 - Cataloging cron jobs are not logged (2.53 KB, patch)
2024-09-30 21:45 UTC, Eric Phetteplace
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Phetteplace 2021-10-13 21:50:25 UTC
After a few cron jobs related to authority records (misc/migration_tools/remove_unused_authorities.pl, misc/link_bibs_to_authorities.pl) were set up to run on our instance, I went to check the Log Viewer tool but couldn't tell that they were configured. I was told that only newer cron jobs actually appear in the logs, and on inspecting those two I saw that they lacked the call to `cronlogaction()` which our circulation-related cronjobs have. It'd be helpful to know if/when these jobs ran.

I realize this is a bit debatable because those two scripts don't reside in misc/cronjobs and right now the only scripts that call `cronlogaction()` are in that directory. Is it appropriate to add that logging to these scripts? We do run them on a schedule, it's important to our authority records workflow. This is the complete list of ones I'd like to add logging to:

- misc/link_bibs_to_authorities.pl
- misc/cronjobs/merge_authorities.pl
- misc/migration_tools/remove_unused_authorities.pl

A side note: there are several scripts in misc/cronjobs, like merge_authorities.pl, that are not logged and probably should be, but that is a larger bug and I'd like to focus on these first since they're relevant to us.
Comment 1 Eric Phetteplace 2021-10-14 00:03:01 UTC
Created attachment 126242 [details] [review]
Bug 29238 - Cataloging cron jobs are not logged

Here's an example patch. Is misc/migration_tools/remove_unused_authorities.pl maybe broken on master? Perl complained that DelAuthority() on line 102 was undefined, so I changed the "use" statement. But otherwise, the patch just adds a cronlogaction import and call when the script is run.

Generally, `cronlogaction()` is called during dry runs like `remove_unused_authorities.pl --test` but not if the script is printing its usage information (e.g. `remove_unused_authorities.pl --help`). It'd be much more complicated to only log when data actually changes.

Testing plan:

1. set CronjobLog to "Log"
2. Run the three cron jobs
   `perl misc/link_bibs_to_authorities.pl; perl misc/cronjobs/merge_authorities.pl -b; perl misc/migration_tools/remove_unused_authorities.pl --confirm`
3. Visit the log viewer /cgi-bin/koha/tools/viewlog.pl, select the "Cron jobs" module, & note it's empty
4. apply the patch
5. Repeat steps 2 & 3 but note the cron logs aren't empty
Comment 2 Eric Phetteplace 2021-10-14 00:03:45 UTC
Created attachment 126243 [details]
Screenshot of the logs
Comment 3 Sarah Cornell 2022-07-07 15:00:43 UTC
We'd appreciate this tiny enhancement.  I thought our linker cron wasn't running today because it wasn't in the log.  Can we bump this up?  Thanks!
Comment 4 Andrew Fuerste-Henry 2024-09-13 14:49:10 UTC
Eric, should this be at needs signoff?
Comment 5 Eric Phetteplace 2024-09-13 15:03:03 UTC
Yes, sorry, I'm not super familiar with Bugzilla.
Comment 6 Sukhmandeep 2024-09-26 20:23:29 UTC
The patch doesn't apply anymore. There seems to be a couple of conflicts.

Error while trying to run git bz apply 29238:

Using index info to reconstruct a base tree...
M	misc/link_bibs_to_authorities.pl
M	misc/migration_tools/remove_unused_authorities.pl
Falling back to patching base and 3-way merge...
Auto-merging misc/migration_tools/remove_unused_authorities.pl
CONFLICT (content): Merge conflict in misc/migration_tools/remove_unused_authorities.pl
Auto-merging misc/link_bibs_to_authorities.pl
CONFLICT (content): Merge conflict in misc/link_bibs_to_authorities.pl
error: Failed to merge in the changes.
Patch failed at 0001 Bug 29238 - Cataloging cron jobs are not logged
Comment 7 Eric Phetteplace 2024-09-30 21:45:19 UTC
Created attachment 172240 [details] [review]
Bug 29238 - Cataloging cron jobs are not logged

Updated patch based off master. The files were just touched in between, this patch doesn't do anything different. Weird that git merge wouldn't have been able to work through it.