douhan4812 2018-09-19 10:29
浏览 70
已采纳

Go客户端和'etcdctl'cli实用工具似乎在不同的工作空间上工作,即使它们连接到相同的主机

I wrote a little Go program that connects to etcd hosts http://192.168.0.210:2379 and http://192.168.0.211:2379, sets a key /foo to bar and then reads it and prints the result. That part is working fine:

bar &{get {Key: /foo, CreatedIndex: 6, ModifiedIndex: 6, TTL: 0} <nil> 6 67b31bc85ffd6d2b} <nil>

the key can also be read using a HTTP GET request

{
    "action": "get",
    "node": {
        "key": "/foo",
        "value": "bar",
        "modifiedIndex": 6,
        "createdIndex": 6
    }
}

but when I use ectdctl it returns nothing as if the key didn't exist

./etcdctl --endpoints=192.168.0.210:2379,192.168.0.211:2379 get /foo

if I instead set /foo using etcdctl, then it works and reads the key correctly. It looks like etcdctl is working on a workspace of its own. Any ideas why this is happening?

  • 写回答

1条回答 默认 最新

  • duanpa2143 2018-09-19 12:05
    关注

    The issue was I was using API v2 for the client and v3 for the etcdctl. Different API versions have different key namespaces. To use client v3 in Go import go.etcd.io/etcd/clientv3

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料