Task Scheduler never sends failure notifications: scheduler-monitor waits for messages that exit code 90 prevents

When a scheduled task fails, Houston never creates a notification or sends an email, even with the scheduler task failure notification level set to critical. Success notifications work normally. Perhaps it is a configuration issue on my end resulting from an upgrade to Rocky 9.9 and rollback to 9.8, but after investigating w/ Claude, the cause appears to be a mismatch between scheduler-monitor.py and task_retry.py.
We’ve had our HL15 2.0 for a couple weeks and have otherwise been happy with it and HoustonUI, but we did not test this particular case of a failed scheduled task until it came up naturally. So, unfortunately I cannot provide an environment for which this was working.

Environment

  • HL15 2.0, Rocky Linux release 9.8 (Blue Onyx)
  • cockpit-scheduler-1.9.9-1.el9 (scheduler-monitor.py, task_retry.py)
  • cockpit-alerts-4.0.25-2.el9
  • houston-broadcaster-2.5.5-1.el9
  • cockpit 329.1.2

How to reproduce

  1. In Task Scheduler, create a Custom Task with the command exit 1.
  2. Click Run Now.
  3. The task shows as failed, but nothing appears in Notifications and no email is sent.

houston-scheduler-monitor logs nothing for this failure. It does log Notification sent: scheduler_task_success for successful tasks on the same system.

Cause
Relative to /opt/45drives/houston/scheduler:

  • templates/Task.service line 19 sets RestartPreventExitStatus=90 on every task unit.
  • scripts/task_retry.py (lines 18, 89–105) makes the final attempt, and any permanent failure, exit with NO_RETRY_EXIT_CODE = 90. Its docstring says this is intended so the unit “settles into failed” and systemd stops restarting.
  • scripts/scheduler-monitor.py lines 337–347: on Failed with result, the unit is only added to _pending_failures.
  • scripts/scheduler-monitor.py lines 363–378: the final scheduler_task_failure notification is only sent on Start request repeated too quickly or Failed to start. Exit code 90 prevents the first, and the second can’t occur once the task has sent READY=1 (e.g. run-custom-task.py line 187, before the command runs).
  • So every failed run, on its last attempt or with retries set to 1, stays in _pending_failures and no failure notification or email is ever sent. This applies to all task types, since they all use the same template and retry policy.

Possible fix

Finalize when the unit fails with the no-retry exit code, for example in the Failed with result branch in schedule-monitor.py, append

if unit not in _pending_failures:
    _pending_failures[unit] = {"retrying_notified": False, "retry_count": 0}
continue

such that

if unit not in _pending_failures:
    _pending_failures[unit] = {"retrying_notified": False, "retry_count": 0}
if get_service_result(unit).get("ExecMainStatus") == "90":
    retry_count = _pending_failures.pop(unit).get("retry_count", 0)
    _recently_finalized[unit] = time.monotonic()
    try:
        send_final_notification(unit, retry_count=retry_count)
    except Exception as e:
        print(f"[scheduler-monitor] Error handling final failure {unit}: {e}",
              file=sys.stderr, flush=True)
continue

Earlier attempts exit with 1, so they still go through the existing retry path. We’ve tested this patch and it seems to work (task failure is recorded in the Notifications tab and I receive an email), but in the meantime we are using the unmodified code and have a watchdog email-me-if-existing-task-failed task, in case this patch has undesirable secondary effects (it seems benign but I’d rather not risk further headache or downtime for our office).

Impact

Several tasks failed on our system after a kernel update left the ZFS module unloaded, and we got no alert at all. For now we run a separate Custom Task every 30 minutes that checks systemctl list-units --state=failed and emails us, but it would be good to have the built-in notifications working.

Happy to provide logs or test a different fix.

Thank you for this detailed information. I have passed this off to the RnD team so they can have a look.