From edc22cd0b6577e549053c681b5ef363aad32ac97 Mon Sep 17 00:00:00 2001 From: Lars Marius Garshol Date: Fri, 11 Sep 2015 13:11:11 +0200 Subject: [PATCH 1/2] Don't swallow error messages --- eureka/client.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eureka/client.py b/eureka/client.py index 13c3271..2cac958 100644 --- a/eureka/client.py +++ b/eureka/client.py @@ -3,7 +3,7 @@ from urllib2 import URLError from urlparse import urljoin from eureka import requests -import ec2metadata +from eureka import ec2metadata import logging import dns.resolver from eureka.requests import EurekaHTTPException @@ -147,6 +147,7 @@ def register(self, initial_status="STARTING"): } } success = False + last_e = None for eureka_url in self.eureka_urls: try: r = requests.post(urljoin(eureka_url, "apps/%s" % self.app_name), json.dumps(instance_data), @@ -155,12 +156,13 @@ def register(self, initial_status="STARTING"): success = True break except (EurekaHTTPException, URLError) as e: - pass + last_e = e if not success: - raise EurekaRegistrationFailedException("Did not receive correct reply from any instances") + raise EurekaRegistrationFailedException("Did not receive correct reply from any instances, last error: " + str(e)) def update_status(self, new_status): success = False + last_e = None for eureka_url in self.eureka_urls: try: r = requests.put(urljoin(eureka_url, "apps/%s/%s/status?value=%s" % ( @@ -172,9 +174,9 @@ def update_status(self, new_status): success = True break except (EurekaHTTPException, URLError) as e: - pass + last_e = e if not success: - raise EurekaUpdateFailedException("Did not receive correct reply from any instances") + raise EurekaUpdateFailedException("Did not receive correct reply from any instances, last error: " + str(e)) def heartbeat(self): instance_id = self.host_name @@ -220,4 +222,3 @@ def get_instance(self, instance_id): def get_app_instance(self, app_id, instance_id): return self._get_from_any_instance("apps/%s/%s" % (app_id, instance_id)) - From 61460a90ce085fb14c5e232e5fa7d51ae88d4861 Mon Sep 17 00:00:00 2001 From: Lars Marius Garshol Date: Fri, 11 Sep 2015 13:42:46 +0200 Subject: [PATCH 2/2] Don't crash if secure_port isn't specified --- eureka/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eureka/client.py b/eureka/client.py index 2cac958..e112a4e 100644 --- a/eureka/client.py +++ b/eureka/client.py @@ -142,10 +142,11 @@ def register(self, initial_status="STARTING"): 'secureVipAddr': self.secure_vip_address or '', 'status': initial_status, 'port': self.port, - 'securePort': self.secure_port, 'dataCenterInfo': data_center_info } } + if self.secure_port: # or Eureka POST call crashes if no secure port + instance_data['instance']['securePort'] = self.secure_port success = False last_e = None for eureka_url in self.eureka_urls: