-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Output Inconsistency with json writer #9975
Comments
You want to use hexadecimal member ID. The JSON ID field is just a decimal number. We can improve docs. |
@gyuho Can you elaborate on that more? There is an obvious inconsistency between the default serializer and the json serializer. ie I can't take the member ID as reported in the json and use it in the member remove API but I can for the default serializer. From my point of view they should either be consistent or the other operations that take in a member ID should accept the decimal representation as valid. |
ref. #9535 |
/cc @jpbetz |
I stumbled into this today while trying to automate removing a member from the cluster. Right now, you can't take the IDs from
I would be happy to work on a PR but would like some clarification regarding the direction first. |
Based on what @gyuho pointed out that we should not change the behavior due to backward compatibility, seems like the quick and suggested fix is updating doc for now. |
The current decimal output for the id is dangerous (as some json parsers like jq truncate large integers) and of little use (as etcdctl itself does not accept the decimal back). |
I agree that doc is not a permanent solution but I guess for now clarifying the current behavior, as a temporary partial fix while keeping this issue open, should be helpful to users until we work out the approach for the actual fix. |
As a workaround, decimal output of id can be used when sending request to json grpc gateway: |
It's a very annoying thing. As other mentioned parsing a JSON is safer than expecting that the simple output structure (fields or ordering or printing out a few extra lines in the beginning) won't change in the future. Also with
It's not intuitive that this will not give back the member ID for the actual instance. Not even in a decimal form (that's why the supposed workaround won't work, at least in my case). Unfortunately on CoreOS only The other issue is that I wanted to wait until a new instance catches up to the cluster. For this I need to know who is the leader and what it's actual RaftIndex is. The leader is represented as a number in the It would be great if |
EDIT: This is incorrect.
etcdctl member list --write-out=json | jq ".members[] | select( .name == \"$AWS_INSTANCE_ID\" ) | .ID" | xargs printf '%x' |
@mattayes Unfortunately no, that won't help as the
The issue is that the ID is an integer and
If the ID would be string, even with the same content that would workaround the |
@akunszt Thanks, I was just about to post that it didn't actually work. |
@akunszt Alright a workaround that DOES work is to manually convert the IDs to strings with MEMBERS=$(etcdctl member list --write-out=json' | sed 's/\("ID":\)\([0-9]\+\)\(,\)/\1"\2"\3/g')
~ # echo $MEMBERS
... "members":[{"ID":"6374980892269173642","name"mynode",...
~ # jq -c '.' <<< $MEMBERS
... "members":[{"ID":"6374980892269173642","name"mynode",... Using ~ # etcdctl member list
...
808d618cff3d18a6, started, mynode, ...
~ # jq ".members[] | select( .name == \"mynode\" ) | .ID" <<< $MEMBERS | xargs printf '%x'
808d618cff3d18a6 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
@tangcong |
Can you share why you expect these requests to also support json? @DenisRazinkin |
@tangcong |
I tried to add hex option for endpoint status: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
Different format showing different member ID is REALLY SO confusing. Backward compatibility? for what? And why was it designed this way in the first place? And it seems like such a simple issue was closed without a fix... (Nobody was willing to fix it. Disappointing.) Anyway, fortunately, for those who are suffering this issue, there is a workaround, with version 3.5. I just tested, with option @gyuho and @spzala mentioned to update the doc, think of it as a fix. I wonder where is the updated (fixed) doc? At least, I didn't find any words about this issue in https://github.com/etcd-io/etcd/blob/main/etcdctl/README.md. |
Still bad output format after 3 years, really frustrating. |
Etcd version:
Output without specifying a writer. Take note of the member IDs.
Output using the JSON writer. Notice the member IDs are different from the output in the non-json output:
I'm not sure if they are encoded in a way that isn't documented or a serialization issue. FWIW this appears to be producible with v3.3
This produces an error when removing a member directly using the ID obtained from the json output since etcd does not recognize it.
The text was updated successfully, but these errors were encountered: