-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
CheckEnv - Give new installs a grace period before 'Cron Not Running' msg #17800
Conversation
(Standard links)
|
@kcristiano I thought you'd appreciate this. Also, while I was working on this I noticed some oddities in the StatusPreference BAO and cleaned it up: #17801 |
@colemanw Thank You. Great improvement.
No red, just lists of what to do. |
*/ | ||
public function checkLastCron() { | ||
$messages = []; | ||
|
||
$statusPreference = new CRM_Core_DAO_StatusPreference(); | ||
$statusPreference->domain_id = CRM_Core_Config::domainID(); | ||
$statusPreference->name = 'checkLastCron'; | ||
$statusPreference->name = __FUNCTION__; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why this change? The JobManager still refers to it as 'checkLastCron', so while it's unlikely somebody will change this function name, that would then get out of sync. Should it be a class constant which could then be used in both places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@demeritcowboy the are actually the same thing, as the function name is "checkLastCron".
I had previously gotten confused about the relationship between the statusPreference and the function, and so I made this change to un-confuse myself. It's more consistent this way because the statusMessage generated below uses __FUNCTION__
and not the string literal.
@kcristiano thanks for the review. I've just made one additional change which is to switch from INFO to NOTICE when cron has not been set up. That seems more fitting, and will still not generate a popup warning. |
I like the direction of this. However, I am a little concerned that this creates a statusPreference, since if someone wanted to pre-hush the cron check (i.e. they know they'll never have cron running and they want to be sure the message doesn't pop up) they'd insert a statusPreference right after install. I think this would undo their work. |
@agh1 this confused me at first too, but creating a statusPreference is actually not new to this PR. The way the system currently works, a statusPreference with the name So all this PR does in addition to that is create (or update) a statusPreference with the current timestamp and the designation |
One thought is to just make the message a "notice" if no cron has ever run and no scheduled jobs (besides |
@colemanw gotcha--I haven't looked at this in years and I think that used to be stored in a setting. |
Rereading this my only thought is that the message during that grace period is a "notice", which is appropriate but means that nobody will see it unless they open up the status page. We set up this check in the first place to replace a more ad hoc popup that appeared upon install. My concern is that we will really need to emphasize in some other way that an admin should configure cron. Otherwise, we're just deferring the shock and confusion of seeing "cron not running" until a day later. |
@agh1 ok I've downgraded the message from ERROR to WARNING in cases where cron has not ever run. |
@colemanw yeah I think that's fair: it's more severe if you thought things were running than if you never thought it would. Re: my prior comment about increasing visibility, I think a natural thing to do would be to have a message on the scheduled jobs page if cron isn't running, similar to what's there in a non-production environment: civicrm-core/CRM/Admin/Page/Job.php Lines 142 to 144 in 64aa560
I'd write it now, but I'd end up duplicating a lot of the code here in terms of logic. Do you think it would make sense to abstract out some of this code so it's available as a sanity check elsewhere in CiviCRM? |
@agh1 Regarding
I tested using this snippet:
This hides the cron notice after the patch is applied. I agree adding a notice to the scheduled jobs page would be a big improvement. |
@agh1 are your concerns address (ie do you consider this mergeable now) |
@eileenmcnaughton Yeah I think this is good to merge. In reading the code again I think there's not too much that would be duplicated in producing a warning for the scheduled jobs page, so you can ignore that last question in my previous comment. |
OK - I read @kcristiano as being in favour too - thanks |
See #17819 which adds a message at the top of the Scheduled Jobs page. |
Overview
Don't bug site admins with "Cron Not Running" error messages right after install. Instead, give them a day's grace period in which to set it up.
Inspired by discussion at https://lab.civicrm.org/dev/core/-/issues/1863#note_39918
Before
"Cron Not Running" error pops up immediately after installing CiviCRM.
After
The error is suppressed for 24 hrs.
Technical Details
The last cron run is recorded as a status preference. That's a little odd, but I'll go with it.
Now if a cron run isn't recorded, we create one with
prefs = 'new'
to distinguish it from normal cron runs.I'm honestly not sure what the 'prefs' column is supposed to be used for; grepping turns up nothing. But it seems to work for this purpose.