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 member add -wjson --hex=true does not output member IDs in hex #19262

Open
4 tasks done
kwohlfahrt opened this issue Jan 23, 2025 · 2 comments
Open
4 tasks done
Labels

Comments

@kwohlfahrt
Copy link

Bug report criteria

What happened?

I ran etcdctl member add -w json --hex=true, with the aim of extracting the newly added member ID for use with etcdctl member promote later. However, the member ID was printed as decimal:

> etcdctl member add test-node --peer-urls=https://10.16.36.111:2380 --learner=true -w json --hex=true
{"header":{"cluster_id":8614491861582198852,"member_id":9202843606982955899,"raft_term":2},"member":{"ID":12981492951526344977,"peerURLs":["https://10.16.36.111:2380"],"isLearner":true},"members":[{"ID":677637297205855628,"name":"etcd-i-0287724fa565aba47","peerURLs":["https://10.16.43.142:2380"],"clientURLs":["https://10.16.43.142:2379"]},{"ID":9202843606982955899,"name":"etcd-i-0a11bcfc6be104246","peerURLs":["https://10.16.33.50:2380"],"clientURLs":["https://10.16.33.50:2379"]},{"ID":12981492951526344977,"peerURLs":["https://10.16.36.111:2380"],"isLearner":true},{"ID":16455373321881049425,"name":"etcd-i-0e6aa2e540fd3c248","peerURLs":["https://10.16.36.53:2380"],"clientURLs":["https://10.16.36.53:2379"]}]

This does not match the behaviour of etcdctl member list -w json --hex=true, which prints the member IDs in hexadecimal, compatible for use with other etcdctl commands.

What did you expect to happen?

I expect etcdctl member add ... -w json --hex=true to print the IDs in hexadecimal, just like etcdctl member list does.

How can we reproduce it (as minimally and precisely as possible)?

Run the following command (the new member doesn't actually ever have to join the cluster, it can be immediately deleted afterwards):

etcdctl member add test-node --peer-urls=https://10.16.36.111:2380 --learner=true -w json --hex=true

Anything else we need to know?

No response

Etcd version (please run commands below)

$ etcd --version
etcd Version: 3.5.15
Git SHA: 9a5533382
Go Version: go1.21.12
Go OS/Arch: linux/arm64

$ etcdctl version
etcdctl version: 3.5.15
API version: 3.5

Etcd configuration (command line flags or environment variables)

paste your configuration here

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

$ etcdctl member list -w table
# paste output here

$ etcdctl --endpoints=<member list> endpoint status -w table
# paste output here

Relevant log output

@kwohlfahrt kwohlfahrt changed the title member add -wjson --hex=true does not output member IDs in hex etcdctl member add -wjson --hex=true does not output member IDs in hex Jan 23, 2025
@wjf222
Copy link

wjf222 commented Jan 25, 2025

@kwohlfahrt
jsonprint is currently only able to respond to isHex for member list operations. The rest of the commands use the default json.Marshal method.
If you want to implement the isHex of the add method, you need to refer to the MemberList method and implement the MemberAdd method of the print interface separately.

Image

@wjf222
Copy link

wjf222 commented Jan 25, 2025

Can I pick this? Thanks!

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

No branches or pull requests

2 participants