-
Notifications
You must be signed in to change notification settings - Fork 934
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
some kubectl stdOut messages are sent to stdErr #1667
Comments
This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions 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. |
I think, this KEP kubernetes/enhancements#2551 will resolve the issue explained in here. |
@ardaguclu thanks for linking this up. I looked for something but couldn't find it. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
What happened
Attempted to use GNU/Bash command substitution to assign the output of a command to a variable:
This results in the message being printed to
stdErr
and nothing being assigned to the variableyo
.$
After redirecting
stdErr
back tostdOut
the issue is resolved:What you expected to happen:
The message to the user "No resources found in kube-public namespace." should be sent through
stdOut
.How to reproduce it (as minimally and precisely as possible):
See above.
Anything else we need to know?:
For reference, even given a similar command with a resulting failure, like searching for namespace
foo
(and there is no namespacefoo
) should even be sent tostdOut
(if there is a message) and accompanied by exitstatus:1
;kubectl
is telling the human something important.If there is nothing to share with the user (no messages printed to the terminal) then simple exit with
status:1
and move on.For Reference:
The most programmatically friendly thing to do is:
kubectl
messages (errors and everything) tostdOut
, andkubectl
has nothing to share with the human (rarely) THAT should exit withstatus:1
.Example
Given these conditions:
grep
will indicate success with a message and exit status:In this case the succeeding operation outputs a message to the user:
a2 b2 c2
.In this case there is nothing to share with the user; the purpose of the operation failed to return anything. But, given the exit status, we can make subsequent automation decisions on the exit status - simple.
Please see excerpts from our bible, The Linux Programming Interface. While this excerpt only explains the mechanics, the
grep
example supports historic implementation.I'd be interested in hearing from those with more gray hairs than me about the
whys
behind the historic bits.Environment:
kubectl version
):Client Version: v1.31.0
cat /etc/os-release
):macOS Sonoma/14.6.1
The text was updated successfully, but these errors were encountered: