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

command: Change delim in columnize to handle bars in node names #6652

Merged
merged 1 commit into from
Mar 9, 2020

Conversation

dzeban
Copy link
Contributor

@dzeban dzeban commented Oct 18, 2019

When node name contains vertical bar symbol some commands output is
garbled because | is used as a delimiter in columnize.SimpleFormat.

This commit changes format string to use \x1f - ASCII unit
separator1 as a delimiter and also adds test to cover this case.

Affected commands:

  • consul catalog nodes
  • consul members
  • consul operator raft list-peers
  • consul intention get

Fixes #3951.

@hashicorp-cla
Copy link

hashicorp-cla commented Oct 18, 2019

CLA assistant check
All committers have signed the CLA.

@hanshasselberg
Copy link
Member

@dzeban thank you for your contribution! This is not a correct solution unfortunately, because an agent can be started with your new delimiter in its name:

$ consul agent -dev -node 'bad |##| name'

There are different solutions to this problem: https://en.wikipedia.org/wiki/Delimiter#Solutions

@hanshasselberg hanshasselberg self-assigned this Dec 12, 2019
@hanshasselberg hanshasselberg added the waiting-reply Waiting on response from Original Poster or another individual in the thread label Dec 12, 2019
@dzeban
Copy link
Contributor Author

dzeban commented Jan 29, 2020

Frankly, I don't like this solution either - I just tried to implement first solution suggested by @freddygv. Whatever delimiter will be chosen there still will be the case for some bug.

I think we should abandon delimiters altogether and pass a slice of strings. There is a pending PR in ryanuber/columnize that will make this possible but it seems to stuck. We could remove columnize package and do this internally but I think that would be way too invasive for such case.

So I don't really know what is the best way to do here.

@ghost ghost removed the waiting-reply Waiting on response from Original Poster or another individual in the thread label Jan 29, 2020
@hanshasselberg
Copy link
Member

@dzeban I think using the delimiter characters mentioned on the wikipedia link from my previous comment would be a good solution.

@hanshasselberg hanshasselberg added the waiting-reply Waiting on response from Original Poster or another individual in the thread label Jan 29, 2020
@dzeban
Copy link
Contributor Author

dzeban commented Feb 7, 2020

I've changed the PR to us 0x1f - ASCII unit separator as a delimiter.
While we are here I wanted to ask - shouldn't this be changed in other commands like consul operator raft list-peers and consul catalog nodes?

@ghost ghost removed the waiting-reply Waiting on response from Original Poster or another individual in the thread label Feb 7, 2020
@hanshasselberg
Copy link
Member

While we are here I wanted to ask - shouldn't this be changed in other commands like consul operator raft list-peers and consul catalog nodes?

If you could fix them as well, that would be great! 🙏

@hanshasselberg hanshasselberg added the waiting-reply Waiting on response from Original Poster or another individual in the thread label Feb 11, 2020
When node name contains vertical bar symbol some commands output is
garbled because `|` is used as a delimiter in `columnize.SimpleFormat`.

This commit changes format string to use `\x1f` - ASCII unit
separator[1] as a delimiter and also adds test to cover this case.

Affected commands:

* `consul catalog nodes`
* `consul members`
* `consul operator raft list-peers`
* `consul intention get`

Fixes hashicorp#3951.

[1]: https://en.wikipedia.org/wiki/Delimiter#Solutions
@dzeban dzeban changed the title command/members: Change delim in columnize to handle bars in node names command: Change delim in columnize to handle bars in node names Mar 2, 2020
@dzeban
Copy link
Contributor Author

dzeban commented Mar 3, 2020

I've fixed the columnize everywhere I was able to find.

The CI failed for some unrelated reason - judging by other recent PRs it seems a bit broken for envoy integration.

Pinging @i0rek for review and look into CI jobs.

@ghost ghost removed waiting-reply Waiting on response from Original Poster or another individual in the thread labels Mar 3, 2020
@hanshasselberg
Copy link
Member

Thank you very much @dzeban! Thats amazing! I will review shortly!

Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks a lot!

Node           Address         Status  Type    Build     Protocol  DC   Segment
bad |##| name  127.0.0.1:8301  alive   server  1.7.0dev  2         dc1  <all>

👍

@hanshasselberg hanshasselberg merged commit 4137d06 into hashicorp:master Mar 9, 2020
freddygv pushed a commit that referenced this pull request Mar 12, 2020
When node name contains vertical bar symbol some commands output is
garbled because `|` is used as a delimiter in `columnize.SimpleFormat`.

This commit changes format string to use `\x1f` - ASCII unit
separator[1] as a delimiter and also adds test to cover this case.

Affected commands:

* `consul catalog nodes`
* `consul members`
* `consul operator raft list-peers`
* `consul intention get`

Fixes #3951.

[1]: https://en.wikipedia.org/wiki/Delimiter#Solutions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using vertical bar in node name messes up consul members pretty output
3 participants