Skip to content

Commit 0b63f9d

Browse files
authored
bug when loading custom certificate too late - some http clients were initialized before it was loaded, caused ssl errors (#1485)
1 parent aed9399 commit 0b63f9d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ exclude = .git,
1212
.mypy_cache,
1313
src/robusta/integrations/kubernetes/autogenerated,
1414
src/robusta/integrations/kubernetes/custom_models.py
15-
ignore = E501, W503, E203
15+
ignore = E501, W503, E203, E402

src/robusta/runner/main.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
import os
2+
3+
from robusta.runner.ssl_utils import add_custom_certificate
4+
5+
ADDITIONAL_CERTIFICATE: str = os.environ.get("CERTIFICATE", "")
6+
7+
if add_custom_certificate(ADDITIONAL_CERTIFICATE):
8+
print("added custom certificate")
9+
10+
# DO NOT ADD ANY CODE ABOVE THIS
11+
# ADDING IMPORTS BEFORE ADDING THE CUSTOM CERTS MIGHT INIT HTTP CLIENTS THAT DOESN'T RESPECT THE CUSTOM CERT
12+
113
import signal
214

315
from robusta.core.model.env_vars import (
4-
ADDITIONAL_CERTIFICATE,
516
ENABLE_TELEMETRY,
617
ROBUSTA_TELEMETRY_ENDPOINT,
718
SEND_ADDITIONAL_TELEMETRY,
@@ -13,7 +24,6 @@
1324
from robusta.runner.config_loader import ConfigLoader
1425
from robusta.runner.log_init import init_logging, logging
1526
from robusta.runner.process_setup import process_setup
16-
from robusta.runner.ssl_utils import add_custom_certificate
1727
from robusta.runner.telemetry_service import TelemetryLevel, TelemetryService
1828
from robusta.runner.web import Web
1929
from robusta.utils.server_start import ServerStart
@@ -23,8 +33,6 @@ def main():
2333
process_setup()
2434
init_logging()
2535
ServerStart.set()
26-
if add_custom_certificate(ADDITIONAL_CERTIFICATE):
27-
logging.info("added custom certificate")
2836

2937
create_monkey_patches()
3038
registry = Registry()

0 commit comments

Comments
 (0)