-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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 txn" does not properly parse newline characters #10169
Comments
@jutley this isn't really an etcd issue in my opinion. How about something like this with a Heredoc?
|
But to your point, the put would work on its own so this probably needs more investigation.
|
I've tried your literal example and a few alterations to try to get this to work, with no success. The only thing that I've gotten to work is escaping newlines in my value using a command like I think this is an issue with etcdctl because it makes the |
@jutley I will dig into this for you to better understand what is going on. The error message is very specific so we might not support it for a reason but I will explore further and at least document. Thanks for the report. |
I think the fundamental difference between the If nothing else, it would be a big improvement to update the documentation to call out that values must have escaped newlines. |
@jutley I don't want to discourage you from exploring this as well. You seem to have a solid grasp of the situation and we would love the help :). If not I can review over the next week or so. |
/cc @jingyih |
@jutley Your observation is correct. Currently the Txn command relies on '\n' to separate CMP, THEN, ELSE. It also relies on '\n' to separate multiple ops/requests. Thanks for pointing this out. |
I'd be happy to at least make a PR to improve the documentation, but it'll be at least a week before I can get started. |
@jutley Sounds good. Thanks! |
Add documentation to clarify that when writing TXN commands, multi-line values should be written using "\n" and not a literal newline (as in other commands). Fixes etcd-io#10169
We are using
etcdctl txn
to make sure servers running in parallel do not both write a new value for a specific key. To do this, we are running a command from a bash script that looks something like this:Essentially: If the value does not already exist, write it. Otherwise, do nothing.
The problem is that etcdctl does not parse this as intended. Instead, we get this error:
Looking at the source code, it's pretty clear that the command is strictly parsing for newline characters. I've verified that using
my\nmultiline\nvalue
as the value gives the desired effect, so we can get by. However, this functionality is inconsistent withetcdctl put
, which DOES handle the newline characters.These commands should parse consistently.
We are currently using etcd 3.3.2, though the changelog shows no changes to
etcdctl txn
in newer versions, so I would assume this is still an issue.The text was updated successfully, but these errors were encountered: