-
Notifications
You must be signed in to change notification settings - Fork 138
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
Account for empty meta in reboot_shutdown.py #2514 #2518
Account for empty meta in reboot_shutdown.py #2514 #2518
Conversation
We currently assume a taskdefinition meta is always filled with information when running the reboot_shutdown.py script. While this is the case for tasks of type shutdown and suspend, tasks of type reboot only have an empty Dict as meta. This commit thus first checks for an empty meta before trying to extract information from it. Add unit tests coverage for reboot_shutdown.py.
@phillxnet, I realized I forgot to update some text and names in the new tests so I've pushed an additional commit (82acd08). My apologies for the extra commit :(. Let me know if you'd like me to redo the PR with only the |
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.
@FroggyFlox Thanks for finding and seeing to this one. Much appreciated.
Test rpm build OK with the following test results:
cd src/rockstor/
- poetry run django-admin test
..........................................................................................................................................................................................................................................................
Ran 250 tests in 26.534s
Thanks also for upping our testing in this area.
From a local console of a 4.5.8-2518 rpm build scheduled to shutdown at 17:30 we have:
Broadcast message from root@rleap15-4 (Mon 2023-03-20 17:32:02 WET):
The system is going down for reboot at Mon 2023-03-20 17:33:02 WET!
Broadcast message from root@rleap15-4 (Mon 2023-03-20 17:33:02 WET):
The system is going down for reboot NOW!
As a follow-up to the review I also tested (in KVM) a shutdown task to be successfully:
|
Fixes #2514
@phillxnet, @Hooverdan96, ready for review.
As detailed in #2514, a scheduled task of type reboot fails due to a omission to account for an empty taskdefinition meta as it is the case for reboot tasks. This pull request thus simply adds a check for an empty meta before trying to extract information from it.
Demonstration
A scheduled task of type reboot was created. When it was time, the reboot command is indeed issued:
To verify other tasks using the reboot_shutdown.py script are still functional, a task of type shutdown was created. When it was time, the shutdown command is indeed triggered:
Unit tests
Three new unit tests are added to cover the reboot_shutdown.py script. Note, however, that the part of
main()
dealing with rtc wake-up time is not covered as I'm not that familiar with working with time data in Python. I'm not sure I want to risk messing users' tasks scheduling as a result.Testing