Commit fe4cf5d
committed
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.1 parent 4b3a11b commit fe4cf5d
File tree
5 files changed
+150
-38
lines changed- pkg
- builder
- proto/runner
5 files changed
+150
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
246 | 254 | | |
247 | 255 | | |
248 | 256 | | |
| |||
268 | 276 | | |
269 | 277 | | |
270 | 278 | | |
| 279 | + | |
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
| |||
317 | 326 | | |
318 | 327 | | |
319 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
320 | 338 | | |
321 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| 377 | + | |
377 | 378 | | |
378 | 379 | | |
379 | 380 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
| 387 | + | |
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
| |||
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
398 | 404 | | |
399 | 405 | | |
400 | 406 | | |
| |||
573 | 579 | | |
574 | 580 | | |
575 | 581 | | |
| 582 | + | |
576 | 583 | | |
577 | 584 | | |
578 | 585 | | |
| |||
593 | 600 | | |
594 | 601 | | |
595 | 602 | | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
601 | 609 | | |
602 | 610 | | |
603 | 611 | | |
604 | 612 | | |
605 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
606 | 618 | | |
607 | 619 | | |
608 | 620 | | |
| |||
764 | 776 | | |
765 | 777 | | |
766 | 778 | | |
| 779 | + | |
767 | 780 | | |
768 | 781 | | |
769 | 782 | | |
| |||
777 | 790 | | |
778 | 791 | | |
779 | 792 | | |
| 793 | + | |
780 | 794 | | |
781 | 795 | | |
782 | 796 | | |
783 | 797 | | |
784 | 798 | | |
785 | 799 | | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
786 | 804 | | |
787 | 805 | | |
788 | 806 | | |
| |||
871 | 889 | | |
872 | 890 | | |
873 | 891 | | |
| 892 | + | |
874 | 893 | | |
875 | 894 | | |
876 | 895 | | |
| |||
883 | 902 | | |
884 | 903 | | |
885 | 904 | | |
| 905 | + | |
886 | 906 | | |
887 | 907 | | |
888 | 908 | | |
889 | 909 | | |
890 | 910 | | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
891 | 923 | | |
892 | 924 | | |
893 | 925 | | |
| |||
931 | 963 | | |
932 | 964 | | |
933 | 965 | | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
934 | 974 | | |
935 | 975 | | |
936 | 976 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
0 commit comments