Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid sigpipe errors without pulling in libc #45

Merged
merged 2 commits into from
Mar 6, 2024
Merged

Avoid sigpipe errors without pulling in libc #45

merged 2 commits into from
Mar 6, 2024

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
refreshing to be able to work with a binary with low constraints

Signed-off-by: clux <[email protected]>
@clux clux merged commit a80a115 into main Mar 6, 2024
14 checks passed
@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