Don't stop the agent when journald is stopped or crashes#2416
Conversation
|
This issue also affects the trace agent, we should fix it for this one too. The process agent is not affected since it doesn't output anything to |
|
Hey! Thanks for this @remicalixte It seems I'm currently hitting this issue in one of my environments. In my case it seems like its the Trace Agent thats experiencing the issue. Would it be possible to extend this to Trace and Process as well? |
|
On APM side, we're waiting for your review before merging DataDog/datadog-trace-agent#486 |
d6fbcf0 to
3fa214a
Compare
arbll
left a comment
There was a problem hiding this comment.
LGTM. Just a question by curiosity: why don't just ignore SIGPIPE by default ?
|
Good question. Do we need the flag? |
|
I wanted to change the default behavior in the fewest cases possible. With the flag we don't ignore |
olivielpeau
left a comment
There was a problem hiding this comment.
just a question, disregard if it's not relevant
|
The current implementation is scoped to Regardless both options are fine for me |
|
Oh yes you're right. I guess the flag is not really necessary then... |
|
The process agent is already ignoring all signals for example. I think it's fine to always ignore |
3fa214a to
e769708
Compare
e769708 to
0be6e0b
Compare
olivielpeau
left a comment
There was a problem hiding this comment.
Looks good, just a few nits :)
| } | ||
| }() | ||
|
|
||
| // By default systemd redirect the stdout to journald. When journald is stopped or crashes we receive a SIGPIPE signal. |
| }() | ||
|
|
||
| // By default systemd redirect the stdout to journald. When journald is stopped or crashes we receive a SIGPIPE signal. | ||
| // Go ignore SIGPIPE signals unless it is when stdout or stdout is closed, in this case the agent is stopped. We don't want that |
There was a problem hiding this comment.
nit: ignores. Also, it's not very clear what we don't want that refers to, maybe this would be clearer: We never want the agent to stop upon receiving SIGPIPE, so [...]
| <format id="common" format="%%Date(%s) | %%LEVEL | (%%File:%%Line in %%FuncShort) | %%Msg%%n"/> | ||
| <format id="syslog-json" format="%%CustomSyslogHeader(20,`+strconv.FormatBool(rfc)+`){"level":"%%LEVEL","relfile":"%%RelFile","line":"%%Line","msg":"%%Msg"}%%n"/> | ||
| <format id="syslog-common" format="%%CustomSyslogHeader(20,`+strconv.FormatBool(rfc)+`) %%LEVEL | (%%RelFile:%%Line) | %%Msg%%n" /> | ||
| <format id="syslog-common" format="%%CustomSyslogHeader(20,`+strconv.FormatBool(rfc)+`) %%LEVEL | (%%File:%%Line) | %%Msg%%n" /> |
There was a problem hiding this comment.
to give slightly more context, we use (%%File:%%Line in %%FuncShort) for agent.log (for ex: somefile.go:23 in myFunction), I think we should normalize to the latter unless there's a good reason not to
What does this PR do?
By default systemd redirect the stdout to journald. When journald is stopped or crashes we receive a SIGPIPE signal. Go ignore SIGPIPE signals unless it is when stdout or stdout is closed, in this case the agent is stopped. We don't want that so we intercept the SIGPIPE signals and just discard them using the new
--ignore-sigpipeflagOther small fix, don't display the absolute path of the source files when using syslog:
before:
after:
Motivation
Fix #1555