lyft / metadataproxy

A proxy for AWS's metadata service that gives out scoped IAM credentials from STS
Other
458 stars 69 forks source link

Metadataproxy throwing error #47

Closed sujithvs-dev closed 7 years ago

sujithvs-dev commented 7 years ago

Metadataproxy throwing below error after installing it in docker host instance. I am not running this in python virtual environment and running it via run-server.sh script.

Error:

[2017-03-09 23:43:43 +0000] [32714] [DEBUG] GET /latest/meta-data/iam/security-credentials/r_ccc_ContainerRole/
[2017-03-09 23:43:43 +0000] [32714] [ERROR] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/gunicorn/workers/async.py", line 52, in handle
    self.handle_request(listener_name, req, client, addr)
  File "/usr/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 159, in handle_request
    super(GeventWorker, self).handle_request(*args)
  File "/usr/lib/python2.7/site-packages/gunicorn/workers/async.py", line 105, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/srv/metadataproxy/metadataproxy/routes/proxy.py", line 70, in iam_sts_credentials
    api_version=api_version
  File "/srv/metadataproxy/metadataproxy/roles.py", line 57, in timed
    result = method(*args, **kw)
  File "/srv/metadataproxy/metadataproxy/roles.py", line 262, in get_assumed_role_credentials
    assumed_role = get_assumed_role(requested_role)
  File "/srv/metadataproxy/metadataproxy/roles.py", line 57, in timed
    result = method(*args, **kw)
  File "/srv/metadataproxy/metadataproxy/roles.py", line 249, in get_assumed_role
    arn = get_role_arn(requested_role)
  File "/srv/metadataproxy/metadataproxy/roles.py", line 228, in get_role_arn
    role = iam.get_role(RoleName=role_name)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 251, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 526, in _make_api_call
    operation_model, request_dict)
  File "/usr/lib/python2.7/site-packages/botocore/endpoint.py", line 141, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/lib/python2.7/site-packages/botocore/endpoint.py", line 170, in _send_request
    success_response, exception):
  File "/usr/lib/python2.7/site-packages/botocore/endpoint.py", line 249, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/usr/lib/python2.7/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 269, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/usr/lib/python2.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
TypeError: __init__() got an unexpected keyword argument 'server_hostname'
ryan-lane commented 7 years ago

This looks like a gevent error related to the python version... See https://github.com/gevent/gevent/issues/477

ryan-lane commented 7 years ago

It looks to me like this stacktrace isn't in a virtualenv, but with libraries from the system site-packages. When you created the venv, did you use --system-site-packages? Are you sure you activated the venv before doing the pip install? When you ran the run-server.sh, is it after you've activated the venv?

sujithvs-dev commented 7 years ago

I didn't get this error after changing gevent version to 1.2.1.

Steps used to run metadataproxy,

  1. git clone https://github.com/lyft/metadataproxy.git
  2. cd metadataproxy
  3. pip install -r requirements.txt
  4. pip install -r requirements_wsgi.txt
  5. sh run-server.sh &

I am not using virtualenv for metadataproxy.

ryan-lane commented 7 years ago

I'll take a look into upgrading the requirements. It's really best to use a virtualenv, to ensure a proper working system for this, as it won't rely on your system dependencies.