Skip to content

Avoid sigpipe errors without pulling in libc#45

Merged
clux merged 2 commits intomainfrom
sigpipe
Mar 6, 2024
Merged

Avoid sigpipe errors without pulling in libc#45
clux merged 2 commits intomainfrom
sigpipe

Conversation

@clux
Copy link
Owner

@clux clux commented Mar 6, 2024

without this you get these lovely errors when dropping the end side of the pipe:

$ kgp -oyaml | yq | false
E0306 21:22:45.049441  149251 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:22:45.050078  149251 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:22:45.050996  149251 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:22:45.052296  149251 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:22:45.052513  149251 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
The connection to the server 0.0.0.0:38167 was refused - did you specify the right host or port?
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1019:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
   2: yq::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
zsh: exit 1                         kubectl get pod -oyaml |
zsh: IOT instruction (core dumped)  yq

after:

kgp -oyaml | yq | false
E0306 21:23:04.257852  149917 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:23:04.258105  149917 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:23:04.259471  149917 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:23:04.259666  149917 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
E0306 21:23:04.260945  149917 memcache.go:265] couldn't get current server API group list: Get "https://0.0.0.0:38167/api?timeout=32s": dial tcp 0.0.0.0:38167: connect: connection refused
The connection to the server 0.0.0.0:38167 was refused - did you specify the right host or port?

kubernetes logs unrelated, just needed a command that took a little time.

could have pulled in libc to do the sigpipe ignoring like we do in kopium:
https://github.com/kube-rs/kopium/blob/bb163bbc2f59dd9efbf23fd2c48c63091fb6a112/src/main.rs#L109-L114
but this felt overkill here (we only do one print) and nice to skip the dep. particularly if rust is actually going to give a better solution to this at some point.

clux added 2 commits March 6, 2024 21:23
Signed-off-by: clux <sszynrae@gmail.com>
refreshing to be able to work with a binary with low constraints

Signed-off-by: clux <sszynrae@gmail.com>
@clux clux merged commit a80a115 into main Mar 6, 2024
@clux clux deleted the sigpipe branch March 6, 2024 21:34
@clux clux added the bug Something isn't working label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant