openwrt / asu

An image on demand server for OpenWrt based distributions
https://sysupgrade.openwrt.org
GNU General Public License v2.0
321 stars 80 forks source link

api: add preliminary builder statistics #969

Closed efahl closed 5 days ago

efahl commented 2 weeks ago

Give clients the ability to check how busy the server is, so they can give diagnostics and/or refuse to queue up a job if there are too many build requests in the queue.

@aparcar , what do you think of this one? I want to be able to check if there are too many jobs already in process and then say "sorry, you'll be waiting three hours for this build, not gonna do it..."

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.45%. Comparing base (5e65dec) to head (faf0c51). Report is 104 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #969 +/- ## ========================================== + Coverage 80.75% 89.45% +8.70% ========================================== Files 15 14 -1 Lines 977 1034 +57 ========================================== + Hits 789 925 +136 + Misses 188 109 -79 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

aparcar commented 2 weeks ago

Issue here was Podman to "die" on the server and no longer do anything meaningful, i.e. not starting new containers which actually work on jobs. Normally I've never seen queues longer than 10. This fix (even though best intentions) don't fix the underlying issue...

efahl commented 2 weeks ago

Right, my logic is: 1) Client (owut, FS) requests queue length before submitting build. 2) If not 200, then something is wrong and supply some diagnostics: "ASU server down blah blah". 3) If 200, then 4) If queue_length < say 10, then just go ahead. 5) If queue_length too big (it was 104 this morning), then tell user "it will be 3*queue_length minutes before your job starts" and abort submission of job.

My hope is to warn users that something is wrong, so they don't just start posting new issues when it's obvious that there is something going on... It doesn't fix root causes, but it lets users know they shouldn't expect things to be working.

efahl commented 2 weeks ago

Oh, and also would be nice for FS/owut/LuCI to say "The server is currently building N jobs..." Instantaneous status when you want to request a build.

aparcar commented 5 days ago

Can't merge this as is, please rebase

aparcar commented 5 days ago

https://sysupgrade.openwrt.org/api/v1/stats