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

etcdctl snapshot mixes stdout and stderr #9179

Closed
hongchaodeng opened this issue Jan 20, 2018 · 5 comments
Closed

etcdctl snapshot mixes stdout and stderr #9179

hongchaodeng opened this issue Jan 20, 2018 · 5 comments

Comments

@hongchaodeng
Copy link
Contributor

etcdctl snapshot restore command mixes stdout and stderr message into stderr. This is due to capnslog sets it by default:
https://github.com/coreos/etcd/blob/0f1ac0cef6834f0927dec74b0f0bf4d0dad9b763/cmd/vendor/github.com/coreos/pkg/capnslog/init.go#L36

It is better to only write error messages into stderr.

@hongchaodeng
Copy link
Contributor Author

2018-01-19 23:42:54.398661 I | pkg/netutil: resolving test-etcd-backup-restore-0-0000.test-etcd-backup-restore-0.e2e-etcd-operator-flaketest-580.svc:2380 to 10.28.5.36:2380
2018-01-19 23:42:54.402454 I | pkg/netutil: resolving test-etcd-backup-restore-0-0000.test-etcd-backup-restore-0.e2e-etcd-operator-flaketest-580.svc:2380 to 10.28.4.183:2380
Error:  --initial-cluster must include test-etcd-backup-restore-0-0000=https://test-etcd-backup-restore-0-0000.test-etcd-backup-restore-0.e2e-etcd-operator-flaketest-580.svc:2380 given --initial-advertise-peer-urls=https://test-etcd-backup-restore-0-0000.test-etcd-backup-restore-0.e2e-etcd-operator-flaketest-580.svc:2380

From user's perspective, only the error message should go into stderr, i.e. last line with Error. The first two lines look like logging messages, and as a user I would expect them go into stdout.

@xiang90
Copy link
Contributor

xiang90 commented Feb 6, 2018

what messages did you see went into stdout?

it is wrong that only error should go to stderr. users should expect only result of the command goes (the matched text of grep command for example) into stdout, which is the common practice of unix program. All informational or diagnostic messages go to stderr.

@hongchaodeng
Copy link
Contributor Author

I agree with that. But is the "resolving ..." messages considered "diagnostic message"? Because the last line should contain enough message to diagnose.

@xiang90
Copy link
Contributor

xiang90 commented Feb 6, 2018

I agree with that. But is the "resolving ..." messages considered "diagnostic message"? Because the last line should contain enough message to diagnose.

yes. it is informational rather than the executing result of the command. it should go to stderr.

only the result of the command should go to stdout. for restore/bakup, probably we can output succeed to xxx into stdout. but it is OK to not produce anything to stdout and exit 0 to indicate a success.

@xiang90
Copy link
Contributor

xiang90 commented Feb 6, 2018

closing this out since etcdctl does the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants