-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for capturing server logs
REv2's ExecuteResponse provides a field named server_logs. This is a place where the execution environment can attach things like log files that are generated by the remote execution environment, so that they can be passed back to the client. I think that in addition to log files, it's a fairly useful place for storing core dumps of actions that crashed. This change extends bb_worker to give every action its own server_logs directory. We pass the path of this directory on to the runner. bb_runner doesn't do anything with it yet, but if you end up writing your own runner, this is where it can dump its own logs if the needs arises. With regards to writing core dumps into this directory, this is where it gets a bit tricky. On Linux, you'd ideally want to set /proc/sys/kernel/core_pattern to something like this: /worker/build/???/server_logs/coredump.timestamp=%t.pid=%p.executable=%e But what should you fill in for the question marks? That part happens to be dynamic. If you're making use of bb_runner's symlink_temporary_directories option to symlink /tmp to the per-action temporary directory, you're in luck. You can just use a pattern like this: /tmp/../server_logs/coredump.timestamp=%t.pid=%p.executable=%e This is guaranteed to work, because the server_logs directory always lives right next to the per-action temporary directory. Unfortunately, when using FUSE you're still not there. It turns out that the kernel isn't willing to write core dumps to file systems that don't track accurate file ownership and permissions. Fortunately, you can proc_pattern's pipe feature to work around that: |/usr/bin/dd conv=excl of=/tmp/../server_logs/coredump.timestamp=%t.pid=%p.executable=%e You do need to keep in mind such a helper process is always run in the root namespace, and also runs as root. So instead of doing that, I'd recommend using a command line the one below: |/usr/bin/nsenter -t %P -S %u -G %g -m /usr/bin/dd conv=excl of=/tmp/../server_logs/coredump.timestamp=%t.pid=%p.executable=%e That way it runs dd inside the container of the crashing process, and also runs as the same (non-root) user.
- Loading branch information
1 parent
4b3a11b
commit fe4cf5d
Showing
5 changed files
with
150 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters