bitbake: Add task timeout support
PATCH 1/1 bitbake: Add task timeout support
By setting BB_TASK_TIMEOUT you can control timeout of for tasks. Using flags BB_TASK_TIMEOUT[do_mytask] you can override timeout settings for specific tasks.
This is especially useful when some server doesn't work properly and do_fetch task takes too long. We may want to kill it early instead of waiting for a fetch that won't happen.
--- .../bitbake-user-manual-ref-variables.rst | 7 +++ bitbake/lib/bb/build.py | 43 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-)
bitbake/doc/bitbake-user-manual/bitbake-user-manual-ref-variables.rst +7 -0
@@ -686,6 +686,13 @@ overview of their function and contents. in images is given a higher priority as compared to build tasks to ensure that images do not suffer timeouts on loaded systems. + :term:`BB_TASK_TIMEOUT` + Specifies time after which still running tasks will be terminated. + + Time is provided as an integer number of seconds. + You can set timeout for specific task using ``BB_TASK_TIMEOUT[do_mytask]``. + To remove timeout use an empty value ``BB_TASK_TIMEOUT = ""``. + :term:`BB_TASKHASH` Within an executing task, this variable holds the hash of the task as returned by the currently enabled signature generator.
bitbake/lib/bb/build.py +42 -1
61 lines not on this page · raw message
Signature · 1 line
2.40.1
Hi,
Quoted 7 lines · Michal Sieron
By setting
BB_TASK_TIMEOUTyou can control timeout of for tasks. Using flagsBB_TASK_TIMEOUT[do_mytask]you can override timeout settings for specific tasks.This is especially useful when some server doesn't work properly and
do_fetchtask takes too long. We may want to kill it early instead of waiting for a fetch that won't happen.
Is the problem related some tools and network protocols? Which?
An alternative would be to configure the tool (git, svn, curl etc) specific settings, or even the default socket timeouts on the running system.
I've seen this kind of problems too, but I'm not sure this task timeout is the correct way to solve it. Time is too relative :)
Cheers,
-Mikko
I tend to agree, if the problem is that some server is too slow, or unresponsive, this does not solve the problem. If you want to forcibly terminate stuff (which is still not a good idea - you should look into why something 'doesn't work properly', not work around it), you can terminate the whole bitbake process instead.
Alex
Quoted 32 lines · Mikko Rapeli
Hi,
Quoted 7 lines · Michal Sieron
By setting
BB_TASK_TIMEOUTyou can control timeout of for tasks. Using flagsBB_TASK_TIMEOUT[do_mytask]you can override timeout settings for specific tasks.This is especially useful when some server doesn't work properly and
do_fetchtask takes too long. We may want to kill it early instead of waiting for a fetch that won't happen.Is the problem related some tools and network protocols? Which?
An alternative would be to configure the tool (git, svn, curl etc) specific settings, or even the default socket timeouts on the running system.
I've seen this kind of problems too, but I'm not sure this task timeout is the correct way to solve it. Time is too relative :)
Cheers,
-Mikko
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14807): https://lists.openembedded.org/g/bitbake-devel/message/14807
Mute This Topic: https://lists.openembedded.org/mt/99127010/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Hello,
let me give some more context on the patch. We use self hosted gerrit and artifactory (with git-lfs content and tarballs with source code) instances which tend to be slow sometimes due to some overloads and other reasons. We have a 3h timeout for the whole build. Now let's assume do_fetch tasks take already 60 hours instead of 10 minutes. With the timeout solution proposed by Michał we can detect it quite fast and stop the build job and unblock the jenkins nodes for other builds or just retry the build in case the fetch on the second run would take less time. Now without that and with timeout on the whole bitbake process we're still holding the jenkins node for another 2-3 hours even though we know this build has no future.
Best regards,
Tomasz Dziendzielski
Yocto has a download cache mechanism, so you should not have to fetch more than once. Are you throwing away that cache between builds?
Again, the actual problem is slow gerrit/artifactory instances, not stuck fetch tasks. The idea of 'retrying' the fetch so that it maybe works better on second try is especially off-putting.
Alex
Quoted 6 lines · Tomasz Dziendzielski
Hello,
let me give some more context on the patch. We use self hosted gerrit and artifactory (with git-lfs content and tarballs with source code) instances which tend to be slow sometimes due to some overloads and other reasons. We have a 3h timeout for the whole build. Now let's assumedo_fetchtasks take already 60 hours instead of 10 minutes. With the timeout solution proposed by Michał we can detect it quite fast and stop the build job and unblock the jenkins nodes for other builds or just retry the build in case the fetch on the second run would take less time. Now without that and with timeout on the whole bitbake process we're still holding the jenkins node for another 2-3 hours even though we know this build has no future.Best regards,
Tomasz Dziendzielski
Quoted 2 lines
Yocto has a download cache mechanism, so you should not have to fetch more than once. Are you throwing away that cache between builds?
Do you mean the DL_DIR or something else as cache mechanism? We do keep DL_DIR between builds, but we're talking about cases where there was a change in the repository.
Quoted 2 lines
the actual problem is slow gerrit/artifactory instances, not stuck fetch tasks
Totally agree, but we're not able to fix the slow gerrit/artifactory in a short term.
Quoted 1 line
The idea of 'retrying' the fetch
Well, it's not like I'm saying this as a solution, usually we just disable jobs until the slowness is gone. But isn't that what we already do with wget in bitbake?
"wget -t 2 -T 30" from bitbake/lib/bb/fetch2/wget.py, where -t is tries, and -T is timeout
Problem is that we get the slowness for git repositories and git does not support such a thing.
Best regards,
Tomasz Dziendzielski
Quoted 3 lines · Tomasz Dziendzielski
Well, it's not like I'm saying this as a solution, usually we just disable jobs until the slowness is gone. But isn't that what we already do with wget in bitbake? "wget -t 2 -T 30" from
bitbake/lib/bb/fetch2/wget.py, where -t is tries, and -T is timeout
Problem is that we get the slowness for git repositories and git does not support such a thing.
But then you can simply wrap git with a timeout command.
https://man7.org/linux/man-pages/man1/timeout.1.html
No?
Alex
Quoted 2 lines
But then you can simply wrap git with a timeout command.
https://man7.org/linux/man-pages/man1/timeout.1.html
Well, this is a good point. I don't know how we could not come up with that idea :D We can just simply use the FETCHCMD_git variable with timeout. Please disregard this patch then.
Best regards,
Tomasz Dziendzielski
Hi,
Quoted 12 lines · Tomasz Dziendzielski
Quoted 2 lines
Yocto has a download cache mechanism, so you should not have to fetch more than once. Are you throwing away that cache between builds?
Do you mean the
DL_DIRor something else as cache mechanism? We do keepDL_DIRbetween builds, but we're talking about cases where there was a change in the repository.Quoted 2 lines
the actual problem is slow gerrit/artifactory instances, not stuck fetch tasks
Totally agree, but we're not able to fix the slow gerrit/artifactory in a short term.
Quoted 8 lines
Quoted 1 line
The idea of 'retrying' the fetch
Well, it's not like I'm saying this as a solution, usually we just disable jobs until the slowness is gone. But isn't that what we already do with wget in bitbake?
"wget -t 2 -T 30" frombitbake/lib/bb/fetch2/wget.py, where -t is tries, and -T is timeout
Problem is that we get the slowness for git repositories and git does not support such a thing.
git uses curl, can't we shorten the timeouts or even add retries there? Maybe even specific ones for the lfs support?
I've also seen a lot of problematic artifactory and gerrit instances, in addition to maven, npm etc...
Cheers,
-Mikko
Hi,
Quoted 5 lines · On Thu, 25 May 2023 15:57:12 +0300 Mikko Rapeli <[email protected]> wrote:
git uses curl, can't we shorten the timeouts or even add retries there? Maybe even specific ones for the lfs support?
I've also seen a lot of problematic artifactory and gerrit instances, in addition to maven, npm etc...
I checked this and couldn't find any environment variables that would control timeout for the whole operation.
The only solution I found (which doesn't require patching/recompiling) was using previously mentioned timeout command like so:
```
FETCHCMD_git = "git \
-c core.fsyncobjectfiles=0 \
-c filter.lfs.clean='/usr/bin/timeout 300 git-lfs clean -- %f' \
-c filter.lfs.smudge='/usr/bin/timeout 300 git-lfs smudge -- %f' \
-c filter.lfs.process='/usr/bin/timeout 300 git-lfs filter-process' \
"
```You can of course put those settings in your gitconfig file instead.
However, this method is not so nice, as when the fetch task ends, and prints error message from git, we get "fatal: the remote end hung up unexpectedly", which doesn't really explain what went wrong.
Michal