From a37b5fe562a85787b74edc48c923aa6343490ec1 Mon Sep 17 00:00:00 2001 From: Dina Belova Date: Mon, 29 Aug 2016 17:47:10 -0700 Subject: [PATCH] Make osprofiler dependency "soft" All OpenStack clients contain osprofiler as a soft dependency (profiling works only if osprofiler package is installed already on the env). This is done intentionally: this allows to avoid its installation on the client nodes, that are not supposed to present a profiling client (e.g. non-admin users). Moreover, marking osprofiler as a strict dependency now leads to bug #1361235 being reproduced in specific Horizon installations (when horizon is installed in a python virtualenv along with it's dependencies). Change-Id: Ifdfaa89995fb2340d7b6540373f41e9f2fd35bcc Closes-Bug: #1361235 --- mistralclient/api/httpclient.py | 5 +++-- mistralclient/api/v2/client.py | 5 +++-- requirements.txt | 2 +- test-requirements.txt | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mistralclient/api/httpclient.py b/mistralclient/api/httpclient.py index 2b52907d..411a93ea 100644 --- a/mistralclient/api/httpclient.py +++ b/mistralclient/api/httpclient.py @@ -16,11 +16,12 @@ import copy import os +from oslo_utils import importutils import requests import logging -import osprofiler.web +osprofiler_web = importutils.try_import("osprofiler.web") LOG = logging.getLogger(__name__) @@ -128,6 +129,6 @@ class HTTPClient(object): headers['X-Target-Auth-Uri'] = target_auth_uri # Add headers for osprofiler. - headers.update(osprofiler.web.get_trace_id_headers()) + headers.update(osprofiler_web.get_trace_id_headers()) return headers diff --git a/mistralclient/api/v2/client.py b/mistralclient/api/v2/client.py index 206087b7..e5fba33c 100644 --- a/mistralclient/api/v2/client.py +++ b/mistralclient/api/v2/client.py @@ -15,7 +15,7 @@ import six -import osprofiler.profiler +from oslo_utils import importutils from mistralclient.api import httpclient from mistralclient.api.v2 import action_executions @@ -32,6 +32,7 @@ from mistralclient.auth import auth_types from mistralclient.auth import keycloak from mistralclient.auth import keystone +osprofiler_profiler = importutils.try_import("osprofiler.profiler") _DEFAULT_MISTRAL_URL = "http://localhost:8989/v2" @@ -98,7 +99,7 @@ class Client(object): mistral_url = _DEFAULT_MISTRAL_URL if profile: - osprofiler.profiler.init(profile) + osprofiler_profiler.init(profile) if target_auth_url: keystone.authenticate( diff --git a/requirements.txt b/requirements.txt index af214dca..93f3901f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0 osc-lib>=1.0.2 # Apache-2.0 -osprofiler>=1.4.0 # Apache-2.0 +oslo.utils>=3.16.0 # Apache-2.0 pbr>=1.6 # Apache-2.0 python-keystoneclient!=2.1.0,>=2.0.0 # Apache-2.0 PyYAML>=3.1.0 # MIT diff --git a/test-requirements.txt b/test-requirements.txt index 100e5b35..2be4f246 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -11,3 +11,4 @@ mock>=2.0 # BSD nose # LGPL tempest>=12.1.0 # Apache-2.0 testtools>=1.4.0 # MIT +osprofiler>=1.4.0 # Apache-2.0