Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions eureka/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -142,11 +142,13 @@ 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:
try:
r = requests.post(urljoin(eureka_url, "apps/%s" % self.app_name), json.dumps(instance_data),
Expand All @@ -155,12 +157,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" % (
Expand All @@ -172,9 +175,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
Expand Down Expand Up @@ -220,4 +223,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))