Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Amazon EC2 metadata automatically #33

Closed
keijack opened this issue Sep 27, 2020 · 5 comments
Closed

Load Amazon EC2 metadata automatically #33

keijack opened this issue Sep 27, 2020 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@keijack
Copy link
Owner

keijack commented Sep 27, 2020

I want to load Amazon EC2 metadata when your component register to eureka server, I can find the method to do it, but I have no Amazon EC2 to test it. I will create a branch to write this feature, but I need someone help me to test it.

@keijack keijack added the help wanted Extra attention is needed label Sep 27, 2020
@dinuta
Copy link

dinuta commented Oct 15, 2020

I can help. Describe the steps needed.

@ciphero
Copy link

ciphero commented Apr 23, 2021

Getting errors loading AWS metadata with data_center_name="Amazon" set.

-[aws_info_loader]-[line:63] -ERROR: error when loading metadata from aws network/interfaces/macs/('02:49:7c:6a:c8:15', <http.client.HTTPResponse object at 0x7f6b1bce9610>)/vpc-id
-[aws_info_loader]-[line:63] -ERROR: error when loading metadata from aws public-hostname
-[aws_info_loader]-[line:63] -ERROR: error when loading metadata from aws public-ipv4
-[aws_info_loader]-[line:74] -ERROR: error when loading dynamic instance identity document from aws

@keijack
Copy link
Owner Author

keijack commented Apr 25, 2021

@ciphero Thanks, for submitting, I have update some code, please upgrade to 0.9.8 and try again.

@ciphero
Copy link

ciphero commented Apr 27, 2021

Still getting some errors.. Here's the full log:

$ python3 eurekaclient.py
[2021-04-27 10:46:15]-[aws_info_loader]-[line:63] -ERROR: error when loading metadata from aws public-hostname
Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/py_eureka_client/__aws_info_loader.py", line 61, in get_ec2_metadata
    return http_client.load(f"{_AWS_METADATA_SERVICE_URL}meta-data/{meta_path}")[0]
  File "/home/ec2-user/.local/lib/python3.7/site-packages/py_eureka_client/http_client.py", line 146, in load
    res = http_cli.urlopen()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/py_eureka_client/http_client.py", line 113, in urlopen
    cadefault=self.cadefault, context=self.context)
  File "/usr/lib64/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib64/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
[2021-04-27 10:46:15]-[aws_info_loader]-[line:63] -ERROR: error when loading metadata from aws public-ipv4
Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/py_eureka_client/__aws_info_loader.py", line 61, in get_ec2_metadata
    return http_client.load(f"{_AWS_METADATA_SERVICE_URL}meta-data/{meta_path}")[0]
  File "/home/ec2-user/.local/lib/python3.7/site-packages/py_eureka_client/http_client.py", line 146, in load
    res = http_cli.urlopen()
  File "/home/ec2-user/.local/lib/python3.7/site-packages/py_eureka_client/http_client.py", line 113, in urlopen
    cadefault=self.cadefault, context=self.context)
  File "/usr/lib64/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib64/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

@keijack
Copy link
Owner Author

keijack commented May 5, 2021

@ciphero This happens when trying to load public-hostname from http://169.254.169.254/latest/meta-data/public-hostname. It seems that public-hostname is not available in your metadata service configuration. That may be means your EC2 have no public hostname. However, in version 0.9.9 the error logs when loading public-hostname/public-ip like you post are ignored.

@keijack keijack closed this as completed Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants