Skip to content

[Feature:System] Restart Local/Remote Autograding Daemons#11707

Merged
bmcutler merged 23 commits into
mainfrom
restart-autograding-cron-job
Jul 18, 2025
Merged

[Feature:System] Restart Local/Remote Autograding Daemons#11707
bmcutler merged 23 commits into
mainfrom
restart-autograding-cron-job

Conversation

@jeffrey-cordero

@jeffrey-cordero jeffrey-cordero commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements:

  • Tests for the changes have been added/updated (if possible)
  • Documentation has been updated/added if relevant
  • Screenshots are attached to Github PR if visual/UI changes were made

What is the current behavior?

The existing repair services cron job, originally introduced in #11566, only restarts local auto-grading shippers/worker daemons via systemctl, but this doesn't restart remote machine auto-grading components, which can be crucial for production environments.

What is the new behavior?

Now, when the local autograding shipper status is not active, the cron job will invoke the script to restart all local and remote autograding shippers/workers.

root@ubuntu:/usr/local/submitty# sudo sbin/repair_services.sh 
2025-07-16:08:42:35: Autograding Shipper

Failure detected within the Autograding Shipper

shipper daemon is inactive

shipper daemon is inactive
worker daemon is inactive
shipper daemon is active
worker daemon is active
Stopping the local shipper daemon...
Stopping all local worker daemon...
Stopping all remote worker daemons...
Delaying 5 seconds to allow the system to stabilize...
Starting the local shipper daemon...
Starting the local worker daemon...
Starting all worker daemons...
Delaying 5 seconds to allow the system to stablize...
Verifying all worker daemons...

Finished!

○ submitty_autograding_shipper.service - Submitty Autograding Shipper
     Loaded: loaded (/etc/systemd/system/submitty_autograding_shipper.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2025-07-16 08:42:02 EDT; 21s ago
       Docs: http://submitty.org
    Process: 122666 ExecStart=/usr/local/submitty/autograder/submitty_autograding_shipper.py (code=killed, signal=TERM)
   Main PID: 122666 (code=killed, signal=TERM)
        CPU: 3min 41.173s

Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 682 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__schaeb__1
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 683 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__schusa__1
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 684 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__sengea__1
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 685 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__sengea__2
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 686 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__sengea__3
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 687 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__ta__1
Jul 16 08:42:02 ubuntu systemd[1]: Stopping Submitty Autograding Shipper...
Jul 16 08:42:02 ubuntu systemd[1]: submitty_autograding_shipper.service: Deactivated successfully.
Jul 16 08:42:02 ubuntu systemd[1]: Stopped Submitty Autograding Shipper.
Jul 16 08:42:02 ubuntu systemd[1]: submitty_autograding_shipper.service: Consumed 3min 41.173s CPU time.
----------------------------------------

Additionally, the cron job script has been refactored to include timestamps in messages and provide clearer service identifiers.

2025-07-16:08:46:51: WebSocket Server

Failure detected within the WebSocket Server

○ submitty_websocket_server.service - Submitty WebSocket Server
     Loaded: loaded (/etc/systemd/system/submitty_websocket_server.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2025-07-16 08:46:47 EDT; 3s ago
       Docs: http://submitty.org
    Process: 106708 ExecStart=/usr/bin/env php /usr/local/submitty/site/socket/index.php (code=killed, signal=TERM)
   Main PID: 106708 (code=killed, signal=TERM)
        CPU: 49ms

Jul 16 08:36:34 ubuntu systemd[1]: Started Submitty WebSocket Server.
Jul 16 08:46:47 ubuntu systemd[1]: Stopping Submitty WebSocket Server...
Jul 16 08:46:47 ubuntu systemd[1]: submitty_websocket_server.service: Deactivated successfully.
Jul 16 08:46:47 ubuntu systemd[1]: Stopped Submitty WebSocket Server.
----------------------------------------

Other information?

To test, run submitty_install for the migration, run sudo systemctl stop submitty_autograding_shipper, and finally run sudo sbin/repair_services.sh to get the output above. This makes progress on #11622.

@codecov

codecov Bot commented Jun 4, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 20.67%. Comparing base (cf469ac) to head (0531cac).
Report is 20 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #11707      +/-   ##
============================================
- Coverage     20.70%   20.67%   -0.03%     
- Complexity     9194     9214      +20     
============================================
  Files           265      265              
  Lines         35220    35276      +56     
  Branches        458      456       -2     
============================================
+ Hits           7292     7295       +3     
- Misses        27474    27529      +55     
+ Partials        454      452       -2     
Flag Coverage Δ
autograder 21.34% <ø> (ø)
js 2.11% <ø> (-0.03%) ⬇️
migrator 100.00% <ø> (ø)
php 19.34% <ø> (-0.04%) ⬇️
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 88.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Jun 24, 2025
@jeffrey-cordero jeffrey-cordero removed the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Jun 24, 2025
@github-actions github-actions Bot added the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Jul 9, 2025

@bmcutler bmcutler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production log before installing this PR:

As I noted, we are failing to restart the nullsmtpd that doesn't exist on production:

Screenshot 2025-07-09 at 11 41 05 PM

But also, there are lots of blank lines -- why?
And let's add a timestamp to these restarts.

Comment thread sbin/repair_services.sh Outdated
Comment thread sbin/repair_services.sh Outdated
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Jul 10, 2025
@jeffrey-cordero
jeffrey-cordero requested a review from bmcutler July 10, 2025 15:11
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jul 10, 2025
@jeffrey-cordero jeffrey-cordero removed the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Jul 10, 2025
Comment thread sbin/repair_services.sh
echo -e "----------------------------------------" | sudo tee -a "${log_file}"
}

repair_autograding() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than duplicate logic... I would rather just call the existing script:

sbin/restart_shipper_and_all_workers.py

If any problems are detected with the shippers or workers on the primary machine.
This halts all all the shippers on the primary machine AND the workers on the primary machine AND the workers processes on worker machines AND brings up all the shippers & workers in the proper order. If we change anything in the future about how these work, we don't want to have to (remember to) make the update in 2 places.

@bmcutler bmcutler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for making the other updates... but we've got (unneccesary?) code duplication...

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Jul 15, 2025
@bmcutler

Copy link
Copy Markdown
Member

Sorry if I've misread the code, but I'm worried about automating this reset if something goes wrong with a remote worker.
We regularly have some remote workers that are offline for long periods of time. We don't want to call the restart script just because we lose contact with a worker -- that breaks all autograding and really should wait for a sysadmin to do this manually -- something may need to be fixed or rebooted or removed from the worker list manually.

@jeffrey-cordero jeffrey-cordero moved this from Work in Progress to In Review in Submitty Development Jul 15, 2025
@jeffrey-cordero
jeffrey-cordero requested a review from bmcutler July 16, 2025 12:57
Comment thread sbin/repair_services.sh Outdated
}

repair_autograding() {
local status_script="/usr/local/submitty/sbin/shipper_utils/systemctl_wrapper.py"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you still need this? since we are only checking the primary machine, i don't think we should need this script... right? can't it look like the other systemctl status checks below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can, but I forgot to convert back to the direct systemctl call instead of calling the wrapper script during the refactor.

@jeffrey-cordero
jeffrey-cordero requested a review from bmcutler July 17, 2025 12:58
@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Jul 18, 2025
@bmcutler
bmcutler merged commit 51c5831 into main Jul 18, 2025
26 checks passed
@bmcutler
bmcutler deleted the restart-autograding-cron-job branch July 18, 2025 15:37
williamschen23 pushed a commit that referenced this pull request Jul 18, 2025
### Please check if the PR fulfills these requirements:

* [ ] Tests for the changes have been added/updated (if possible)
* [ ] Documentation has been updated/added if relevant
* [ ] Screenshots are attached to Github PR if visual/UI changes were
made

### What is the current behavior?
<!-- List issue if it fixes/closes/implements one using the "Fixes
#<number>" or "Closes #<number>" syntax -->

The existing repair services cron job, originally introduced in #11566,
only restarts local auto-grading shippers/worker daemons via
`systemctl`, but this doesn't restart remote machine auto-grading
components, which can be crucial for production environments.

### What is the new behavior?

Now, when the local autograding shipper status is not active, the cron
job will invoke the script to restart all local and remote autograding
shippers/workers.


```bash
root@ubuntu:/usr/local/submitty# sudo sbin/repair_services.sh 
2025-07-16:08:42:35: Autograding Shipper

Failure detected within the Autograding Shipper

shipper daemon is inactive

shipper daemon is inactive
worker daemon is inactive
shipper daemon is active
worker daemon is active
Stopping the local shipper daemon...
Stopping all local worker daemon...
Stopping all remote worker daemons...
Delaying 5 seconds to allow the system to stabilize...
Starting the local shipper daemon...
Starting the local worker daemon...
Starting all worker daemons...
Delaying 5 seconds to allow the system to stablize...
Verifying all worker daemons...

Finished!

○ submitty_autograding_shipper.service - Submitty Autograding Shipper
     Loaded: loaded (/etc/systemd/system/submitty_autograding_shipper.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2025-07-16 08:42:02 EDT; 21s ago
       Docs: http://submitty.org
    Process: 122666 ExecStart=/usr/local/submitty/autograder/submitty_autograding_shipper.py (code=killed, signal=TERM)
   Main PID: 122666 (code=killed, signal=TERM)
        CPU: 3min 41.173s

Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 682 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__schaeb__1
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 683 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__schusa__1
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 684 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__sengea__1
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 685 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__sengea__2
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 686 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__sengea__3
Jul 16 08:42:01 ubuntu submitty_autograding_shipper.py[122666]: JOB 687 True 2025-07-15 14:27:09-0400 /var/local/submitty/to_be_graded_queue/f25__testing__locked_homework__ta__1
Jul 16 08:42:02 ubuntu systemd[1]: Stopping Submitty Autograding Shipper...
Jul 16 08:42:02 ubuntu systemd[1]: submitty_autograding_shipper.service: Deactivated successfully.
Jul 16 08:42:02 ubuntu systemd[1]: Stopped Submitty Autograding Shipper.
Jul 16 08:42:02 ubuntu systemd[1]: submitty_autograding_shipper.service: Consumed 3min 41.173s CPU time.
----------------------------------------
```

Additionally, the cron job script has been refactored to include
timestamps in messages and provide clearer service identifiers.

```bash
2025-07-16:08:46:51: WebSocket Server

Failure detected within the WebSocket Server

○ submitty_websocket_server.service - Submitty WebSocket Server
     Loaded: loaded (/etc/systemd/system/submitty_websocket_server.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2025-07-16 08:46:47 EDT; 3s ago
       Docs: http://submitty.org
    Process: 106708 ExecStart=/usr/bin/env php /usr/local/submitty/site/socket/index.php (code=killed, signal=TERM)
   Main PID: 106708 (code=killed, signal=TERM)
        CPU: 49ms

Jul 16 08:36:34 ubuntu systemd[1]: Started Submitty WebSocket Server.
Jul 16 08:46:47 ubuntu systemd[1]: Stopping Submitty WebSocket Server...
Jul 16 08:46:47 ubuntu systemd[1]: submitty_websocket_server.service: Deactivated successfully.
Jul 16 08:46:47 ubuntu systemd[1]: Stopped Submitty WebSocket Server.
----------------------------------------
```

### Other information?
<!-- Is this a breaking change? -->
<!-- How did you test -->

To test, run `submitty_install` for the migration, run `sudo systemctl
stop submitty_autograding_shipper`, and finally run `sudo
sbin/repair_services.sh` to get the output above. This makes progress on
#11622.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants