Replies: 7 comments 8 replies
-
|
If you cancel a workflow, sleep doesn’t always exit immediately. (or maybe they just want to charge you more for CPU usage but shhhhh) |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
You’re right to call this out as a code smell, but the conclusion (“this script shouldn’t exist”) is too aggressive given how the runner operates in practice. 1. Why something like
|
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
This is a fair critique of the runner's helper. The busy-wait exists because the script must remain interruptible by signals across shells where sleep alone doesn't reliably forward SIGTERM to the parent during graceful shutdown - a plain sleep would delay cancellation. A cleaner approach is read -t < <(:) or trapping the signal and breaking the loop, which avoids the spin. If you want this fixed upstream, the actions/runner repo is the right place to open an issue with a proposed patch - happy to help draft the trap-based version. |
Beta Was this translation helpful? Give feedback.
-
|
I think the criticism is fair, but removing safe_sleep.sh outright feels a bit aggressive without knowing the runner scenarios it was meant to handle. |
Beta Was this translation helpful? Give feedback.
-
|
I created a PR with proposed changes 3 weeks ago: It doesn't appear to have gotten any traction at all so far. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Actions Runner
Discussion Details
There is a script that is part of the
actions/runnercodebase calledsafe_sleep.sh. Looking at the history, it was originally added as a function insiderun-helper.sh.templatewith no clear explanation, trying to use system commandssleepandpingbefore falling back on a busy wait, and then got refactored out to a separate file that was only the busy wait before later having a bug fix and then the alternatives readded.This script is a significant code smell, in my estimation. Anything that resorts to doing a busy wait is extremely questionable. Also, the script's "shebang" specifies that it should be run with
/bin/bash, and yet the script contains code that tests whether it is running in Bash. Furthermore, outside of that check, it contains bash-specific syntax for the busy wait.To summarize:
It is hard to evaluate what workable changes are because it isn't clearly documented what platforms the script is expected to run on. But, given that it is part of Git Actions, it's a reasonable assumption, I think, that it is the range of supported operating systems, which is documented to be Windows, Mac OS X 11+ and a range of modern Linux distributions.
I believe this support range should be documented in the
safe_sleep.shfile so that anybody working on it knows exactly what it is trying to support (specifically modern Linux distrubions and OS X 11+). Furthermore, where there are unusual cases that need to be handled, they should be explicitly called out.Given this specific range, though, it seems to me that the script is fundamentally unnecessary, because all modern Linux distributions and OS X 11+ have
/usr/bin/sleepto begin with. If there is, in fact, a supported environment that lacks/usr/bin/sleep, it needs to be documented insafe_sleep.sh(maybe there arechrootjails being set up that don't provide access tosleep??), and if there isn't, thensafe_sleep.shshouldn't exist and code should simply use/usr/bin/sleep(or,sleepwherever it is found on PATH).Beta Was this translation helpful? Give feedback.
All reactions