saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

etcd_mod/etcd_util does not support etcd api v3 #55377

Closed maikelpoot closed 4 years ago

maikelpoot commented 4 years ago

Description of Issue

The etcd implementation within salt only supports etcd api v2 (etcd2) and not etcd api v3 (etcd3). since etcd 3.4.0 etcd3 has become the default api, and etcd2 is disabled by default.

Setup

Salt formula:

etcd-test:
  etcd.set:
    - name: /path/to/key
    - value: value
    - host: 127.0.0.1
    - port: 2379

Newest version:

$ /tmp/etcd-download-test/etcd --version
etcd Version: 3.4.3
Git SHA: 3cf2f69b5
Go Version: go1.12.12
Go OS/Arch: linux/amd64

$ /tmp/etcd-download-test/etcdctl version
etcdctl version: 3.4.3
API version: 3.4

Steps to Reproduce Issue

  1. Install etcd using https://github.com/etcd-io/etcd/releases/tag/v3.4.3
  2. Install python-etcd pip install python-etcd
  3. Run newest etcd /tmp/etcd-download-test/etcd
  4. Run state salt-call state.sls etcd-test
          ID: etcd-test
    Function: etcd.set
        Name: /path/to/key
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1933, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1951, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/etcd_mod.py", line 177, in set_
                  current = __salt__['etcd.get'](name, profile=profile, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/modules/etcd_mod.py", line 95, in get_
                  return client.get(key, recurse=recurse)
                File "/usr/lib/python2.7/site-packages/salt/utils/etcd_util.py", line 181, in get
                  result = self.read(key, recursive=recurse)
                File "/usr/lib/python2.7/site-packages/salt/utils/etcd_util.py", line 199, in read
                  result = self.client.read(key, recursive=recursive, wait=wait, timeout=timeout)
                File "/usr/lib/python2.7/site-packages/etcd/client.py", line 597, in read
                  timeout=timeout)
                File "/usr/lib/python2.7/site-packages/etcd/client.py", line 907, in wrapper
                  return self._handle_server_response(response)
                File "/usr/lib/python2.7/site-packages/etcd/client.py", line 987, in _handle_server_response
                  etcd.EtcdError.handle(r)
                File "/usr/lib/python2.7/site-packages/etcd/__init__.py", line 306, in handle
                  raise exc(msg, payload)
              EtcdException: Bad response : 404 page not found
     Started: 05:25:27.300628
    Duration: 98.371 ms
     Changes:   

Versions Report

salt-call --versions-report
Salt Version:
           Salt: 2019.2.2

Dependency Versions:
           cffi: 1.13.2
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: 4.1.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Aug  7 2019, 00:51:29)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.7.1908 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1062.4.1.el7.x86_64
         system: Linux
        version: CentOS Linux 7.7.1908 Core
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

exe90 commented 4 years ago

I'm trying to build a distributed system with syndicates and etcd, i got a problem. @Akm0d

salt-call etcd.ls Traceback (most recent call last): File "/usr/bin/salt-call", line 11, in salt_call() File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 431, in salt_call client.run() File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run caller.run() File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 138, in run ret = self.call() File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 237, in call ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs) File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute return func(*args, *kwargs) File "/usr/lib/python2.7/site-packages/salt/modules/etcdmod.py", line 216, in ls return client.ls(path) File "/usr/lib/python2.7/site-packages/salt/utils/etcd_util.py", line 293, in ls items = self.read(path) File "/usr/lib/python2.7/site-packages/salt/utils/etcd_util.py", line 199, in read result = self.client.read(key, recursive=recursive, wait=wait, timeout=timeout) File "/usr/lib/python2.7/site-packages/etcd/client.py", line 597, in read timeout=timeout) File "/usr/lib/python2.7/site-packages/etcd/client.py", line 907, in wrapper return self._handle_server_response(response) File "/usr/lib/python2.7/site-packages/etcd/client.py", line 987, in _handle_server_response etcd.EtcdError.handle(r) File "/usr/lib/python2.7/site-packages/etcd/init.py", line 306, in handle raise exc(msg, payload) EtcdException: Bad response : 404 page not found Traceback (most recent call last): File "/usr/bin/salt-call", line 11, in salt_call() File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 431, in salt_call client.run() File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 57, in run caller.run() File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 138, in run ret = self.call() File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 237, in call ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs) File "/usr/lib/python2.7/site-packages/salt/executors/direct_call.py", line 12, in execute return func(args, **kwargs) File "/usr/lib/python2.7/site-packages/salt/modules/etcdmod.py", line 216, in ls return client.ls(path) File "/usr/lib/python2.7/site-packages/salt/utils/etcd_util.py", line 293, in ls items = self.read(path) File "/usr/lib/python2.7/site-packages/salt/utils/etcd_util.py", line 199, in read result = self.client.read(key, recursive=recursive, wait=wait, timeout=timeout) File "/usr/lib/python2.7/site-packages/etcd/client.py", line 597, in read timeout=timeout) File "/usr/lib/python2.7/site-packages/etcd/client.py", line 907, in wrapper return self._handle_server_response(response) File "/usr/lib/python2.7/site-packages/etcd/client.py", line 987, in _handle_server_response etcd.EtcdError.handle(r) File "/usr/lib/python2.7/site-packages/etcd/init.py", line 306, in handle raise exc(msg, payload) etcd.EtcdException: Bad response : 404 page not found

Version

Salt Version: Salt: 2019.2.0

Dependency Versions: cffi: 1.5.2 cherrypy: 3.6.0 dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.8 libgit2: Not Installed libnacl: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.6 mysql-python: Not Installed pycparser: 2.10 pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: Not Installed Python: 2.7.13 (default, Jan 11 2017, 10:56:06) [GCC] python-gnupg: Not Installed PyYAML: 3.12 PyZMQ: 14.0.0 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.2.1 ZMQ: 4.0.4

System Versions: dist: SuSE 12 x86_64 locale: UTF-8 machine: x86_64 release: 4.4.155-94.50-default system: Linux version: SUSE Linux Enterprise Server 12 x86_64

etcd --version

etcd Version: 3.4.0 Git SHA: 898bd1351 Go Version: go1.12.9 Go OS/Arch: linux/amd64

etcdctl --version

etcdctl version: 3.4.0 API version: 3.4

kuznetsov420 commented 4 years ago

Same problem here with using etcd as ext_pillar. Looks like that etcd_util uses python-etcd which doesn't support etcd v3 API.