Add nonblock logsink for non-blocking log writes to stderr/stdout/file - #22385
Add nonblock logsink for non-blocking log writes to stderr/stdout/file#22385brandond wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: brandond The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @brandond. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
c82fe21 to
2d6cc31
Compare
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2d6cc31 to
cfc2891
Compare
Fixes:
This PR adds a nonblocking log sink implementation under the
client/pkg/logutilpackage, and imports it fromserver/embedso that log outputs such asnonblock:stdoutornonblock:/var/log/etcd.logcan be specified in the server config.Since zap outputs are parsed as URLs, the log sink accepts query parameters; four are recognized:
timeout=(time.Duration)- timeout for log writes to the sink; defaults to 1ms.mode=(os.FileMode)- file mode for log files; defaults to0666.warn=(bool)- when writes succeed after failing due toos.ErrDeadlineExceeded, print a message to the sink counting how many writes were dropped; defaults to false.must=(bool)- drop the write ifSetWriteDeadlinecannot be used to enforce the timeout; defaults to false.The log sink uses
syscall.Dupto duplicate stdout/stderr file descriptors to a new File so that other accesses toos.Stdoutoros.Stderrdo not unintentionally put it into blocking mode - see golang/go#24331.Writes that fail are silently dropped, so this is a LOSSY log sink. That said, most administrators will probably find that potentially dropping logs is better than deadlocking.
This does NOT change the default log sinks; administrators must explicitly configure log output using the
nonblockscheme to use this new sink.