From 21559e616a8d732f85ea017da4c254262ef16acf Mon Sep 17 00:00:00 2001 From: Frank Niessink Date: Wed, 10 Jun 2020 15:05:29 +0200 Subject: [PATCH] Reenable environment variables to set a proxy to be used by the collector. See https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support. Fixes #1217. --- .../collector/src/base_collectors/metrics_collector.py | 6 +++--- docs/CHANGELOG.md | 4 ++++ docs/DEPLOY.md | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/components/collector/src/base_collectors/metrics_collector.py b/components/collector/src/base_collectors/metrics_collector.py index cddb3c050c..84e444b33f 100644 --- a/components/collector/src/base_collectors/metrics_collector.py +++ b/components/collector/src/base_collectors/metrics_collector.py @@ -61,14 +61,14 @@ async def start(self) -> NoReturn: max_sleep_duration = int(os.environ.get("COLLECTOR_SLEEP_DURATION", 60)) measurement_frequency = int(os.environ.get("COLLECTOR_MEASUREMENT_FREQUENCY", 15 * 60)) timeout = aiohttp.ClientTimeout(total=120) - async with aiohttp.ClientSession(timeout=timeout, raise_for_status=True) as session: + async with aiohttp.ClientSession(raise_for_status=True, timeout=timeout, trust_env=True) as session: self.data_model = await self.fetch_data_model(session, max_sleep_duration) while True: self.record_health() logging.info("Collecting...") async with aiohttp.ClientSession( - timeout=timeout, connector=aiohttp.TCPConnector(limit_per_host=20), - raise_for_status=True) as session: + connector=aiohttp.TCPConnector(limit_per_host=20), raise_for_status=True, timeout=timeout, + trust_env=True) as session: with timer() as collection_timer: await self.collect_metrics(session, measurement_frequency) sleep_duration = max(0, max_sleep_duration - collection_timer.duration) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 60c5c58702..653ecd8784 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Open the source links in separate window. Closes [#1203](https://github.com/ICTU/quality-time/issues/1203). +### Fixed + +- Reenable environment variables to set a proxy to be used by the collector. See https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support. Fixes [#1217](https://github.com/ICTU/quality-time/issues/1217). + ## [2.3.1] - [2020-06-02] ### Fixed diff --git a/docs/DEPLOY.md b/docs/DEPLOY.md index e037c9d6d5..8b2ea5b04a 100644 --- a/docs/DEPLOY.md +++ b/docs/DEPLOY.md @@ -68,3 +68,13 @@ To configure the sleep duration and the measurement frequency, set the `COLLECTO - COLLECTOR_SLEEP_DURATION=30 - COLLECTOR_MEASUREMENT_FREQUENCY=600 ``` + +To configure a proxy for the collector to use, set the `HTTP_PROXY` or `HTTPS_PROXY` environment variable, for example: + +```yaml + collector: + environment: + - HTTP_PROXY="http://proxy.com" +``` + +See the [aiohttp documentation](https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support) for more information on proxy support.