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

Always print the raft_term in decimal #13711

Merged
merged 1 commit into from
Feb 22, 2022

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Feb 17, 2022

Fix 13709

When executing command etcdctl member list --hex -w json, it gets the cluster_id and member_id included in double quotes, but the raft_term isn't. All of three fields are uint64, so we should be consistent on displaying them.

Without this fix, the output can't be formatted using tool like jq either.

It's just a minor fix.

cc @serathius @spzala @ptabor

EDIT: I did some archaeology, the change was original introduced in PR/11812 in order to fix issues/9975. The original PR was just trying to resolve the inconsistent memberID output. But somehow it also printed the raft_term in hexdecimal. It seems not correct, because it can't be parsed correctly by json.NewDecoder, neither the tool something like jq, because the raft_term isn't a valid integer.

We have two solutions:

  1. Always print raft_term in decimal, so that it works for both json.NewDecoder/json.Unmarshal and tool like jq;
  2. Get the raft_term included in double quotes.

This PR follows the first solution. cc @tangcong @danbeaulieu @omkensey

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2022

Codecov Report

Merging #13711 (02872ae) into main (e814f6f) will decrease coverage by 0.24%.
The diff coverage is 100.00%.

❗ Current head 02872ae differs from pull request most recent head 4158323. Consider uploading reports for the commit 4158323 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13711      +/-   ##
==========================================
- Coverage   72.85%   72.61%   -0.25%     
==========================================
  Files         465      465              
  Lines       37880    37880              
==========================================
- Hits        27599    27508      -91     
- Misses       8508     8582      +74     
- Partials     1773     1790      +17     
Flag Coverage Δ
all 72.61% <100.00%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
etcdctl/ctlv3/command/printer_json.go 77.35% <100.00%> (ø)
client/v3/txn.go 73.33% <0.00%> (-26.67%) ⬇️
server/proxy/grpcproxy/register.go 69.76% <0.00%> (-9.31%) ⬇️
server/auth/simple_token.go 80.00% <0.00%> (-8.47%) ⬇️
client/pkg/v3/tlsutil/tlsutil.go 83.33% <0.00%> (-8.34%) ⬇️
client/v3/leasing/util.go 91.66% <0.00%> (-6.67%) ⬇️
etcdctl/ctlv3/command/lease_command.go 65.34% <0.00%> (-5.95%) ⬇️
server/etcdserver/api/rafthttp/msgappv2_codec.go 67.82% <0.00%> (-5.22%) ⬇️
server/storage/mvcc/watchable_store.go 85.14% <0.00%> (-3.99%) ⬇️
client/v3/leasing/cache.go 87.77% <0.00%> (-3.89%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e814f6f...4158323. Read the comment docs.

@ahrtr ahrtr force-pushed the quote_raft_term_on_display branch 2 times, most recently from acabf77 to ca6c5ff Compare February 18, 2022 01:57
@ahrtr ahrtr changed the title Get the raft_term included in double quote when displaying in hex Always print the raft_term in decimal Feb 18, 2022
@ahrtr ahrtr force-pushed the quote_raft_term_on_display branch 3 times, most recently from 4158323 to 17fb791 Compare February 18, 2022 11:30
@ahrtr
Copy link
Member Author

ahrtr commented Feb 18, 2022

Just rebased this PR.

@ahrtr ahrtr force-pushed the quote_raft_term_on_display branch 2 times, most recently from 086daba to 9d62ed2 Compare February 18, 2022 22:25
@ahrtr
Copy link
Member Author

ahrtr commented Feb 18, 2022

All tests passed, Please take a look. @serathius @spzala @ptabor

Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

Thank you. Please resolve the conflicts.

@ptabor
Copy link
Contributor

ptabor commented Feb 21, 2022

Agree that raft_term as decimal is better choice. It's identifier that you might want to compare with </> other... while the hex is optically perceived as a unique identifier.

Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

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

LGTM, please resolve the conflict.

@ahrtr ahrtr force-pushed the quote_raft_term_on_display branch 3 times, most recently from b363fd4 to 7fde3c4 Compare February 22, 2022 00:35
@ahrtr
Copy link
Member Author

ahrtr commented Feb 22, 2022

Just rebased this PR. PTAL @serathius @ptabor @spzala Thanks.

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

Successfully merging this pull request may close these issues.

--hex=true converts raft_term to hexadecimal in json format Output Inconsistency with json writer
4 participants