Skip to content

Commit

Permalink
Issue #138: Do not perform legacy check for branch 403 and lower its …
Browse files Browse the repository at this point in the history
…priority
  • Loading branch information
daledavies authored and brendanheywood committed Sep 15, 2023
1 parent be024ef commit 49f4e08
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions croncheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,11 @@
$delay = '';
$maxdelay = 0;
$tasks = core\task\manager::get_all_scheduled_tasks();
$legacylastrun = null;
foreach ($tasks as $task) {
if ($task->get_disabled()) {
continue;
}
$faildelay = $task->get_fail_delay();
if (get_class($task) == 'core\task\legacy_plugin_cron_task') {
$legacylastrun = $task->get_last_run_time();
}
if ($faildelay == 0) {
continue;
}
Expand All @@ -255,20 +251,6 @@
$delay .= "ADHOC TASK: " .get_class($task) . " Delay: $faildelay\n";
}

if ( empty($legacylastrun) ) {
send_warning("Moodle legacy task isn't running (ie disabled)\n");
}
$minsincelegacylastrun = floor((time() - $legacylastrun) / 60); // In minutes.
$when = userdate($legacylastrun);

if ( $minsincelegacylastrun > $options['legacyerror']) {
send_critical("Moodle legacy task last run $minsincelegacylastrun "
. "mins ago > {$options['legacyerror']} mins\nLast run at $when");
}
if ( $minsincelegacylastrun > $options['legacywarn']) {
send_warning("Moodle legacy task last run $minsincelegacylastrun mins ago > {$options['legacywarn']} mins\nLast run at $when");
}

$maxminsdelay = $maxdelay / 60;
if ( $maxminsdelay > $options['delayerror'] ) {
send_critical("Moodle task faildelay > {$options['delayerror']} mins\n$delay");
Expand All @@ -277,6 +259,23 @@
send_warning("Moodle task faildelay > {$options['delaywarn']} mins\n$delay");
}

if ($CFG->branch < 403) {
$legacytask = \core\task\manager::get_scheduled_task('core\task\legacy_plugin_cron_task');
$legacylastrun = $legacytask->get_last_run_time();
if (!$legacylastrun) {
send_warning("Moodle legacy task isn't running (ie disabled)\n");
}
$minsincelegacylastrun = floor((time() - $legacylastrun) / 60); // In minutes.
$when = userdate($legacylastrun);
if ( $minsincelegacylastrun > $options['legacyerror']) {
send_critical("Moodle legacy task last run $minsincelegacylastrun "
. "mins ago > {$options['legacyerror']} mins\nLast run at $when");
}
if ( $minsincelegacylastrun > $options['legacywarn']) {
send_warning("Moodle legacy task last run $minsincelegacylastrun mins ago > {$options['legacywarn']} mins\nLast run at $when");
}
}

// If the Check API from 3.9 exists then call those as well.
if (class_exists('\core\check\manager')) {

Expand Down

0 comments on commit 49f4e08

Please sign in to comment.