gmr / consulate

Python client for the Consul HTTP API
http://consulate.readthedocs.org
BSD 3-Clause "New" or "Revised" License
342 stars 100 forks source link

Bug is in api method deregister service. #119

Open linuxoid69 opened 6 years ago

linuxoid69 commented 6 years ago
import consulate

consul_host = os.environ['CONSUL_HOST']

consul = consulate.Consul(consul_host)

consul.agent.service.deregister('redis')

Your code use Method GET. You need to use ### PUT. So, service can't been deleted.

16:55:48.376090 IP colswic01.test.local.56820 > 172.18.0.2.8500: Flags [P.], seq 323:501, ack 491, win 245, options [nop,nop,TS val 1460761607 ecr 1460761605], length 178 E...L.@.@.............!4..:68.......Y...... W.t.W.t.GET /v1/agent/service/deregister/redis HTTP/1.1 Host: 127.0.0.1:8500 Accept-Encoding: gzip, deflate Connection: keep-alive User-Agent: python-requests/2.19.1 Accept: /

16:55:48.376423 IP 172.18.0.2.8500 > colswic01.test.local.56820: Flags [P.], seq 491:737, ack 501, win 252, options [nop,nop,TS val 1460761607 ecr 1460761607], length 246 E..*..@.@.H.........!4..8.....:.....YD..... W.t.W.t.HTTP/1.1 405 Method Not Allowed Allow: OPTIONS,PUT Content-Encoding: gzip Content-Type: text/plain; charset=utf-8 Vary: Accept-Encoding Date: Mon, 25 Jun 2018 13:55:48 GMT Content-Length: 46

gbiv commented 6 years ago

I'm seeing this as well. Is this the wrong API to call?

karma0 commented 6 years ago

This seems related to the following change in Consul: https://github.com/hashicorp/consul/issues/3659#issuecomment-342519570

Deadkorskiy commented 5 years ago

pip was not updated https://pypi.org/project/consulate/#files consul.agent.service.deregister('redis') still use return self._get_no_response_body(['deregister', service_id]) instead _put_no_response_body().