diff --git a/py_eureka_client/__aws_info_loader.py b/py_eureka_client/__aws_info_loader.py index 8c05041..e9f79ef 100644 --- a/py_eureka_client/__aws_info_loader.py +++ b/py_eureka_client/__aws_info_loader.py @@ -53,14 +53,15 @@ def __check_connectivity(self): _logger.warn(f"Cannot connect to amazon metadata services in address [{_AWS_METADATA_SERVICE_IP}]") return False - def get_ec2_metadata(self, meta_path, default_value=""): + def get_ec2_metadata(self, meta_path, default_value="", ignore_error=False): if not self.__can_access: _logger.warn(f"Cannot connect to amazon metadata services in address [{_AWS_METADATA_SERVICE_IP}], return default value. ") return default_value try: return http_client.load(f"{_AWS_METADATA_SERVICE_URL}meta-data/{meta_path}")[0] except Exception: - _logger.exception(f"error when loading metadata from aws {meta_path}") + log_excep = _logger.debug if ignore_error else _logger.exception + log_excep(f"error when loading metadata from aws {meta_path}") return default_value def get_instance_identity_document(self, default_value={}): diff --git a/py_eureka_client/__init__.py b/py_eureka_client/__init__.py index 3083496..ae1f28c 100644 --- a/py_eureka_client/__init__.py +++ b/py_eureka_client/__init__.py @@ -22,4 +22,4 @@ SOFTWARE. """ -version="0.9.8" \ No newline at end of file +version="0.9.9" \ No newline at end of file diff --git a/py_eureka_client/eureka_client.py b/py_eureka_client/eureka_client.py index f89a240..6615dd0 100644 --- a/py_eureka_client/eureka_client.py +++ b/py_eureka_client/eureka_client.py @@ -1034,9 +1034,9 @@ def __load_ec2_metadata_dict(self): 'instance-type': amazon_info.get_ec2_metadata('instance-type'), 'local-ipv4': amazon_info.get_ec2_metadata('local-ipv4'), 'local-hostname': amazon_info.get_ec2_metadata('local-hostname'), - 'availability-zone': amazon_info.get_ec2_metadata('placement/availability-zone'), - 'public-hostname': amazon_info.get_ec2_metadata('public-hostname'), - 'public-ipv4': amazon_info.get_ec2_metadata('public-ipv4'), + 'availability-zone': amazon_info.get_ec2_metadata('placement/availability-zone', ignore_error=True), + 'public-hostname': amazon_info.get_ec2_metadata('public-hostname', ignore_error=True), + 'public-ipv4': amazon_info.get_ec2_metadata('public-ipv4', ignore_error=True), 'mac': mac, 'vpcId': vpc_id }