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

client hangs on write #75

Closed
jwerak opened this issue Dec 15, 2014 · 5 comments
Closed

client hangs on write #75

jwerak opened this issue Dec 15, 2014 · 5 comments

Comments

@jwerak
Copy link

jwerak commented Dec 15, 2014

Hi,

I have trouble when writing data to etcd although I can read data without any problem. Would anyone know where the problem could be?

I have following simple code:

#!/usr/bin/python
import etcd
                                                                                                                                                                   client = etcd.Client(host = '127.0.0.1', port = 5000)

print client.read('/coreos_apps/marathon/dev')
print client.write('/writetest', 'TESTSTRING')

Here is my output after I interrupt program with ctrl+C

-> % python scripts/etcd_test.py<class 'etcd.EtcdResult'>({'newKey': False, 'raft_index': 64071, '_children': [], 'createdIndex': 6684, 'modifiedIndex': 6684, 'value': u'{"ssh_port": 224, "count": 1, "version": "latest", "ssh_support": true}', 'etcd_index': 16626, 'expiration': None, 'key': u'/coreos_apps/marathon/dev', 'ttl': None, 'action': u'get', 'dir': False})




^CTraceback (most recent call last):
  File "scripts/etcd_test.py", line 9, in <module>
    print client.write('/writetest', 'TESTSTRING')
  File "/usr/lib/python2.7/site-packages/python_etcd-0.3.2-py2.7.egg/etcd/client.py", line 272, in write
    response = self.api_execute(path, method, params=params)
  File "/usr/lib/python2.7/site-packages/python_etcd-0.3.2-py2.7.egg/etcd/client.py", line 575, in api_execute
    redirect=self.allow_redirect)
  File "build/bdist.linux-x86_64/egg/urllib3/request.py", line 135, in request_encode_body
  File "build/bdist.linux-x86_64/egg/urllib3/poolmanager.py", line 174, in urlopen
  File "build/bdist.linux-x86_64/egg/urllib3/poolmanager.py", line 153, in urlopen
  File "build/bdist.linux-x86_64/egg/urllib3/connectionpool.py", line 516, in urlopen
  File "build/bdist.linux-x86_64/egg/urllib3/connectionpool.py", line 308, in _make_request
  File "/usr/lib64/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 791, in send
    self.connect()
  File "build/bdist.linux-x86_64/egg/urllib3/connection.py", line 154, in connect
  File "build/bdist.linux-x86_64/egg/urllib3/connection.py", line 133, in _new_conn
  File "build/bdist.linux-x86_64/egg/urllib3/util/connection.py", line 78, in create_connection
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
KeyboardInterrupt

Every time it seems it hangs here:

  File "/usr/lib/python2.7/site-packages/python_etcd-0.3.2-py2.7.egg/etcd/client.py", line 272, in write
    response = self.api_execute(path, method, params=params)

Could it be due to connection problem? Weird is that Read works without any problem.

I have no problems writing to database using curl.

My Setup:
python --version
Python 2.7.5

etcd version 0.4.6

Would you need any info for debugging ?

@jwerak
Copy link
Author

jwerak commented Dec 15, 2014

Another info, after timeout traceback was:

Traceback (most recent call last):
  File "scripts/etcd_test.py", line 9, in <module>
    print client.write('/writetest', 'TESTSTRING')
  File "/usr/lib/python2.7/site-packages/python_etcd-0.3.2-py2.7.egg/etcd/client.py", line 272, in write
    response = self.api_execute(path, method, params=params)
  File "/usr/lib/python2.7/site-packages/python_etcd-0.3.2-py2.7.egg/etcd/client.py", line 581, in api_execute
    self._base_uri = self._next_server()
  File "/usr/lib/python2.7/site-packages/python_etcd-0.3.2-py2.7.egg/etcd/client.py", line 539, in _next_server
    raise etcd.EtcdException('No more machines in the cluster')
etcd.EtcdException: No more machines in the cluster

so it has troubles in writing to etcd db for some reason. Is this library tested with etcd 0.4.6?

@chadlung
Copy link

Per the readme it looks like the client is only supporting the 2.0 release candidate versions and up now: "Install etcd (0.2.rc1 or later). This version of python-etcd will only work correctly with the etcd API version 2".

I wonder with you using 0.4.6 if that is the issue? I tested with the latest python-etcd source code, etcd 2.0.0 RC1 and Python 3.4.2 and didn't have any issues.

@cameronmaske
Copy link

I'm encountering a similar problem.
I think it has something to do with etcd 0.4.6 returning a 307 (HTTP/1.1 307 Temporary Redirect) and urllib3 not following that on a PUT request.

@veverjak Were you running python-etcd through an SSH tunnel?

@jwerak
Copy link
Author

jwerak commented Apr 26, 2015

Nope, it was called from docker container running on CoreOS host.
I was connecting to etcd running on CoreOS.

@lavagetto
Copy link
Collaborator

The library is tested with 0.4.6 and failure to write while you can still read means your etcd cluster has lost quorum, most probably.

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

No branches or pull requests

4 participants