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

Parsing connection port fails whit whitespace after port number #15

Closed
twdkeule opened this issue Aug 10, 2020 · 2 comments · Fixed by #57
Closed

Parsing connection port fails whit whitespace after port number #15

twdkeule opened this issue Aug 10, 2020 · 2 comments · Fixed by #57

Comments

@twdkeule
Copy link

When parsing the connection port, the config name/option is included because the sed rege does not match:

# grep -e '^native_transport_port: ' "$CONF_DIR/cassandra.yaml" | sed -e 's|^[^:]*:[ ]*\([^ ]*\)$|\1|' | tr -d "'"
native_transport_port: 9042

Solution: allow whitespace after port number with \w*:

# grep -e '^native_transport_port: ' "$CONF_DIR/cassandra.yaml" | sed -e 's|^[^:]*:[ ]*\([^ ]*\)\w*$|\1|' | tr -d "'"
9042

I noticed the parsing is always this strict, eg when parsing IP adresses.

@msmygit
Copy link
Collaborator

msmygit commented Aug 19, 2020

@twdkeule thank you for using the diagnostics collection script and providing us feedback! Happy to received PRs as well.

I noticed that the command in question is working without any hiccups on the system where I tested this and it is correctly pulling the port details for me as shown below,

$ grep -e '^native_transport_port: ' "cassandra.yaml" |sed -e 's|^[^:]*:[ ]*\([^ ]*\)$|\1|'|tr -d "'"
9042

Alternatively, I also did run your command which also yielded the same output,

$ grep -e '^native_transport_port: ' "cassandra.yaml" | sed -e 's|^[^:]*:[ ]*\([^ ]*\)\w*$|\1|' | tr -d "'"
9042

so, I don't think we need to get this changed in here at this time.

@RomainAnselin
Copy link
Contributor

Ive encountered a similar problem on the listen_address. It didnt fail the collection, but ended up being unable to parse the nodes IP and the diag collected had X folders "listen_address: " which I then had to correct manually.
This is how I ended up on this one.

For this particular scenario above, to handle white spaces or making sure we target the port info only, I would consider using regex in the sed as we know a port will be defined by a set of 1 to 5 digits. ie: sed -E 's|^[^:]*:[ ]*\([0-9]{1,5}\)$|\1|'|tr -d "'"

Would also be of interest to confirm the sed version used in both tests above (OP + response) as I've encountered issues in the past on some AMI build where sed isnt up to date

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 a pull request may close this issue.

4 participants