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

Creating key of v2 emulation is incompatible with v2 API #9609

Closed
summerwind opened this issue Apr 24, 2018 · 6 comments
Closed

Creating key of v2 emulation is incompatible with v2 API #9609

summerwind opened this issue Apr 24, 2018 · 6 comments

Comments

@summerwind
Copy link

We found the incompatibility of creating key with v2 emulation. The details are as follows:

# Check etcdctl version.
$ etcdctl --version
etcdctl version: 3.3.3
API version: 2

# Start etcd without v2 emulation.
$ docker run -it --rm -p 2379:2379 gcr.io/etcd-development/etcd:v3.3.3 \
    etcd --advertise-client-urls="http://127.0.0.1:2379" --listen-client-urls="http://0.0.0.0:2379"

# We can create a nested key.
$ etcdctl set /skydns/com/example/foo '{"host":"192.168.1.1"}'
{"host":"192.168.1.1"}

# Start etcd with v2 emulation.
$ docker run -it --rm -p 2379:2379 gcr.io/etcd-development/etcd:v3.3.3 \
    etcd --advertise-client-urls="http://127.0.0.1:2379" --listen-client-urls="http://0.0.0.0:2379" --experimental-enable-v2v3="/v2"

# We can't create a nested key.
$ etcdctl set /skydns/com/example/foo '{"host":"192.168.1.1"}'
Error:  100: Key not found (/skydns/com/example/foo) [0]

Is this the intended behavior? If this is the intended, we will need to modify the client even if we use v2 emulation.

@yudai
Copy link
Contributor

yudai commented Apr 24, 2018

I guess you had a directory at /skydns/com/example in your v2 store already and that made set to /skydns/com/example/foo succeeded.
With the v2v3 emulation, etcd uses the v3 store for v2 requests. So if you don't have the directory in your v3 store, even if you have it on your v2 store, set requests to the directory fails. I assume you just need to mkdir again with the emulation.

@summerwind
Copy link
Author

Hi, yudai-san :)

No, the v2 API allows us to set the key even if the directory does not exist as shown above. But v2 emulation does not do that.

When migrating from v2 API to use v2 emulation, should we change to use mkdir on all clients?

@xiang90
Copy link
Contributor

xiang90 commented Apr 25, 2018

@summerwind

When migrating from v2 API to use v2 emulation, should we change to use mkdir on all clients?

No, you should not. Probably you can help to fix the problem in etcd emulation layer instead.

@yudai
Copy link
Contributor

yudai commented Apr 25, 2018

Sorry, it's my misunderstand. v2 doesn't require mkdir to make files.

The cause is here:

https://github.com/coreos/etcd/blob/master/etcdserver/api/v2v3/store.go#L147

I'll send a PR to fix this.

@yudai
Copy link
Contributor

yudai commented Apr 25, 2018

I found Watch of v2v3 is also somewhat broken on the master.
I don't get events when I watch with etcdctl watch -r -f /skydns and put something to /skydns/com/example/foo, which is not compatible with the v2 api.
If you run etcdctl watch -r -f /skydns/com/example, you get identical events forever somehow.
I'll take a look into this issue as well maybe tomorrow.

@summerwind
Copy link
Author

Thank you for the support!

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

No branches or pull requests

3 participants