Skip to content

Commit

Permalink
Merge pull request #16 from tomislater/bump-consul-version
Browse files Browse the repository at this point in the history
Bump python-consul version to 0.7.0
  • Loading branch information
swistakm authored Aug 2, 2017
2 parents 38c1e8f + 11e0e6c commit 05ff1f6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
34 changes: 17 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ language: python
install: pip install tox
env:
matrix:
# consul 0.4.1
- TOX_ENV=py27 CONSUL_VERSION=0.4.1
- TOX_ENV=py33 CONSUL_VERSION=0.4.1
- TOX_ENV=py34 CONSUL_VERSION=0.4.1
- TOX_ENV=py35 CONSUL_VERSION=0.4.1
# consul 0.7.5
- TOX_ENV=py27 CONSUL_VERSION=0.7.5
- TOX_ENV=py33 CONSUL_VERSION=0.7.5
- TOX_ENV=py34 CONSUL_VERSION=0.7.5
- TOX_ENV=py35 CONSUL_VERSION=0.7.5

# consul 0.5.2
- TOX_ENV=py27 CONSUL_VERSION=0.5.2
- TOX_ENV=py33 CONSUL_VERSION=0.5.2
- TOX_ENV=py34 CONSUL_VERSION=0.5.2
- TOX_ENV=py35 CONSUL_VERSION=0.5.2
# consul 0.8.5
- TOX_ENV=py27 CONSUL_VERSION=0.8.5
- TOX_ENV=py33 CONSUL_VERSION=0.8.5
- TOX_ENV=py34 CONSUL_VERSION=0.8.5
- TOX_ENV=py35 CONSUL_VERSION=0.8.5

# consul 0.6.4
- TOX_ENV=py27 CONSUL_VERSION=0.6.4
- TOX_ENV=py33 CONSUL_VERSION=0.6.4
- TOX_ENV=py34 CONSUL_VERSION=0.6.4
- TOX_ENV=py35 CONSUL_VERSION=0.6.4
# consul 0.9.0
- TOX_ENV=py27 CONSUL_VERSION=0.9.0
- TOX_ENV=py33 CONSUL_VERSION=0.9.0
- TOX_ENV=py34 CONSUL_VERSION=0.9.0
- TOX_ENV=py35 CONSUL_VERSION=0.9.0

# coverage and style checks
- TOX_ENV=pep8 CONSUL_VERSION=0.4.1
- TOX_ENV=coverage CONSUL_VERSION=0.4.1
- TOX_ENV=pep8 CONSUL_VERSION=0.9.0
- TOX_ENV=coverage CONSUL_VERSION=0.9.0

before_script:
- wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-consul==0.4.0
python-consul>=0.7.0,<0.8.0
6 changes: 4 additions & 2 deletions src/ianitor/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import logging
from requests import ConnectionError

from consul import Check
from consul import Check, ConsulException


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -122,7 +122,9 @@ def keep_alive(self):
:return: None
"""
with ignore_connection_errors("ttl_pass"):
if not self.session.agent.check.ttl_pass(self.check_id):
try:
self.session.agent.check.ttl_pass(self.check_id)
except ConsulException:
# register and ttl_pass again if it failed
logger.warning("service keep-alive failed, re-registering")
self.register()
Expand Down
3 changes: 1 addition & 2 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_remove_services():
if description["ID"] != 'consul':
agent.service.deregister(description["ID"])

# this is consul 0.4.1 behavior - consul is one of services
# this is consul behavior - consul is one of services
services = agent.services()
if 'consul' in services:
services.pop('consul')
Expand Down Expand Up @@ -142,7 +142,6 @@ def _get_service_status(session, service_obj):
# return none because check does not even exist
return

# from pprint import pprint; pprint(checks)
service_check = list(filter(
lambda check: check["ServiceName"] == service_obj.service_name, checks
)).pop()
Expand Down

0 comments on commit 05ff1f6

Please sign in to comment.