Connecting to ceilometer using proxy_url fails

Bug #1357879 reported by Eran Raichstein
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-ceilometerclient
New
Undecided
Unassigned

Bug Description

The BUG:
-----

- When using ceilometerclient with a proxy-url to connect to a ceilometer server (as part of devstack) connection fails with HTTP response 406 (Not acceptable)

Looking into code/details --> the code creates the correct connection using the function get_proxy_url from common/http.py (which tunnels the code to the proxy:8777 end-point) but the function _http_request is creating the bug by::

   after creating the connection using "conn = self.get_connection()" [which is a correct behavior]
the code adds "self.endpoint.rstrip('/')" to the conn_url. This is not needed and causes in failure for ceilometer (the code should not add anything, or somehow add end-point of the proxy and not the original end-point)

WORKAROUND:
-------

One possible workaround is just to remove the lines in the code that adds that unneeded end-point, so the code for ceilometer\common\http.py (after proposed workaround) will look like::

.

    def _http_request(self, url, method, **kwargs):
        """Send an http request with the specified characteristics.

        Wrapper around httplib.HTTP(S)Connection.request to handle tasks such
        as setting headers and error handling.
        """
        # Copy the kwargs so we can reuse the original in case of redirects
        kwargs['headers'] = copy.deepcopy(kwargs.get('headers', {}))
        kwargs['headers'].setdefault('User-Agent', USER_AGENT)
        auth_token = self.auth_token()
        if auth_token:
            kwargs['headers'].setdefault('X-Auth-Token', auth_token)

        self.log_curl_request(method, url, kwargs)
        conn = self.get_connection()

        try:
            #if self.proxy_url:
            # conn_url = (self.endpoint.rstrip('/') +
            # self._make_connection_url(url))
            #else:
            conn_url = self._make_connection_url(url)
            conn.request(method, conn_url, **kwargs)
            resp = conn.getresponse()

ENVIRONMENT:
------

The code was tested with the following configuration (before and after fix)

        env['OS_USERNAME'] = "demo"
        env['OS_PASSWORD'] = "devstack"
        env['OS_AUTH_URL'] = "http://proxyIPAddress:5000/v2.0"
        env['OS_TENANT_NAME'] = "demo"
        env["http_proxy"] = "http://proxyIPAddress:5000/"

      a devstack machine (with ceilometer service enabled ) is running on the proxy machine in a virtual box (using NAT configuration) and port forward for ports 5000 and 8777 and ceilometerclient is running against that code from remote machine.

Revision history for this message
Eran Raichstein (eran-raichstein) wrote :

Addendum, for the WORKAROUND:

Need to also change function get_connection to reflect original :8777 port (using the original not the proxy :5000 port) i.e:

    def get_connection(self):
        _class = self.connection_params[0]
        try:
            if self.proxy_url:
                proxy_parts = parse.urlparse(self.proxy_url)
                return _class(proxy_parts.hostname, *self.connection_params[1][1:2],
                              **self.connection_params[2])
            else:
                return _class(*self.connection_params[1][0:2],
                              **self.connection_params[2])
        except httplib.InvalidURL:
            raise exc.InvalidEndpoint()

Revision history for this message
gordon chung (chungg) wrote :

this is old code. could you reverify against current client.

also, this appears to be a duplicate bug so let's track this here: https://bugs.launchpad.net/python-ceilometerclient/+bug/1310805

feel free to change it if you feel like it's not a dup.

cheers,

affects: ceilometer → python-ceilometerclient
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.