Scheduled Tasks not working at all

Hello, maybe someone can help me here,

Brief description of the problem

Created Schedules Tasks on a new installation are not working

Detailed step by step instructions to reproduce the problem

When I create a scheduled task, no matter which one, in System -> scheduled tasks, it will be registered correctly, but it will not run. - Tried with Scrub, automated Reboot, Snapshots

Error Traceback provided on the Web-UI

None, even the Logs show no error

  • I recently reinstalled the Server due to this issue.

Hello Kuro,

Try upgrading to a newer version. The bug was fixed with v4.5.5.

1 Like

I am running 4.5.7 and it is still not runningā€¦

Interesting. I should check if they are working for me.

@Kuro, I checked it on my 4.5.7 instance, and a scheduled task for scrub started automatically and completed fine. In my case, I created the task from scratch (since mine was a fresh install). Not sure, if that helps here.

2 Likes

Hello,

No this does not really helpā€¦ since it is not working for meā€¦

Hi @Kuro,

Sorry you seem to be having an issue unrelated to our recent updates. In this case, we will need to have a bit more information on what you are experiencing:

  • does any type of scheduled task fail or is it just one? Pool scrub, Snapshot, etcā€¦
  • do you see any error somewhere?
  • can you successfully create a new scheduled task from Rockstorā€™s webUI?

Letā€™s try to see where things go south for you so that we can better understand what is wrong.

2 Likes

Hi,

sorry for my late reply.

  • does any type of scheduled task fail or is it just one? Pool scrub, Snapshot, etcā€¦
    Yes, Scrub and Snapshots seem to work meanwhile. But Reboot doesnā€™t

  • do you see any error somewhere?
    No, I also checked the Logs.

  • can you successfully create a new scheduled task from Rockstorā€™s webUI?
    No, I created every Task using the WebUI and also deleted and recereated the Task multiple times.
    Mentioned Reboot Task is not working. -> Anyways, At least Snapshots and Scubs are working for now.

2 Likes

Hi @Kuro,

Thanks a lot for the additional information.
If reboot is not working but snapshots and scrubs are, my guess is that we need to update our apo endpoint for the former tasks following our recent Django update. I thus presume a Shutdown task is also not working.

Iā€™ll try to have a look soon but feel free to open an issue in our GitHub repository so that we can rightfully attribute this bug report to you. No worries if you canā€™t, of course.

1 Like

@Kuro,

I could reproduce the failure of the ā€œRebootā€ task, but it turns out not to be related to the API endpoint as I incorrectly stated above. Could you, by any chance, confirm that you see the same error as I do?
The error should be visible in the email sent to you by the system. If you have the email alerts set up, then it should be in the email you received. If you do not, then you should be able to read it in the following:

# cat /var/spool/mail/root
From root@localhost  Thu Mar  2 10:20:02 2023
Return-Path: <root@localhost>
X-Original-To: root
Delivered-To: root@localhost
Received: by localhost (Postfix, from userid 0)
        id 42F79F551; Thu,  2 Mar 2023 10:20:02 -0500 (EST)
From: "(Cron Daemon)" <root@localhost>
To: root@localhost
Subject: Cron <root@radmin> /opt/rockstor/.venv/bin/st-system-power 6 \*-*-*-*-*-*
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20230302152002.42F79F551@localhost>
Date: Thu,  2 Mar 2023 10:20:02 -0500 (EST)

Traceback (most recent call last):
  File "/opt/rockstor/.venv/bin/st-system-power", line 5, in <module>
    main()
  File "/opt/rockstor/src/rockstor/scripts/scheduled_tasks/reboot_shutdown.py", line 109, in main
    if not run_conditions_met(meta):
  File "/opt/rockstor/src/rockstor/scripts/scheduled_tasks/reboot_shutdown.py", line 50, in run_conditions_met
    if meta["ping_scan"]:
KeyError: 'ping_scan'

The error I see is thus the following:

Traceback (most recent call last):
  File "/opt/rockstor/.venv/bin/st-system-power", line 5, in <module>
    main()
  File "/opt/rockstor/src/rockstor/scripts/scheduled_tasks/reboot_shutdown.py", line 109, in main
    if not run_conditions_met(meta):
  File "/opt/rockstor/src/rockstor/scripts/scheduled_tasks/reboot_shutdown.py", line 50, in run_conditions_met
    if meta["ping_scan"]:
KeyError: 'ping_scan'
2 Likes

Hi, yes, I can confirm getting this Message.

2 Likes

Thanks a lot for having a look and the confirmation, @Kuro!

Hereā€™s a quick explanation.
When a scheduled task is created, its metadata (pool/share affected, etcā€¦) are saved in the database in a json_meta object. When the task is run, we used that meta json object as a Python Dict to get all these settings. Now, for a ā€œrebootā€ task, there is no such metadata (as that task is very straightforward), which means that this Python Dict is empty. Unfortunately, so far, we fail to account for the fact that this can be the case (it is indeed filled with information for the ā€œsistersā€ tasks of type shutdown and suspend).

To fix it, we can thus simply ensure the Python Dict is not empty before starting fetching the required information. If you want to try a quick fix before it is released in a Rockstor rpm, you can try the following one liner:

sed -i 's:if meta\[:if meta and meta\[:g' /opt/rockstor/src/rockstor/scripts/scheduled_tasks/reboot_shutdown.py

This affects the relevant line of code:

After this fix, it should read:

    if meta and meta["ping_scan"]:

I have now created an issue for this and I will work on it shortly:

Thanks for the report and do please let us know if you give that one-liner above a try.

2 Likes

Hi, I am trying this. Might have an Update by tomorrow.

3 Likes

Sorry for my late reply, I was sickt. But, I can now agree, this solution is working fine!

4 Likes