Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/20250902_fix_fix_proxy_environment_variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Fix proxy environment variables
kind: fix
date: 2025-09-02
---

* Fixed an issue where MongoDB Agents were not using the NO_PROXY environment variable when set on the operator.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ else
fi



if [[ -n "${HTTP_PROXY-}" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! I wanted to remove this one ages ago. That just makes no sense - since the go lib gets those from the env var anyway

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but let's link mms-automation code here for code reference for the future? I assume/remember that they create the http client including the proxy

transport := &http.Transport{
    Proxy: http.ProxyFromEnvironment,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment

agentOpts+=("-httpProxy=${HTTP_PROXY}")
fi

if [[ -n "${SSL_TRUSTED_MMS_SERVER_CERTIFICATE-}" ]]; then
agentOpts+=("-httpsCAFile=${SSL_TRUSTED_MMS_SERVER_CERTIFICATE}")
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import yaml
from kubernetes import client
from kubetester import create_or_update_configmap
from kubetester.create_or_replace_from_yaml import (
Expand All @@ -12,7 +11,6 @@
from kubetester.mongodb import MongoDB
from kubetester.operator import Operator
from kubetester.phase import Phase
from oauthlib.oauth1.rfc5849.endpoints import resource
from pytest import fixture, mark

MDB_RESOURCE = "replica-set"
Expand Down Expand Up @@ -45,7 +43,10 @@ def operator_with_proxy(namespace: str, operator_installation_config: dict[str,
os.environ["HTTP_PROXY"] = os.environ["HTTPS_PROXY"] = squid_proxy
helm_args = operator_installation_config.copy()
helm_args["customEnvVars"] += (
f"\&MDB_PROPAGATE_PROXY_ENV=true" + f"\&HTTP_PROXY={squid_proxy}" + f"\&HTTPS_PROXY={squid_proxy}"
f"\&MDB_PROPAGATE_PROXY_ENV=true"
+ f"\&HTTP_PROXY={squid_proxy}"
+ f"\&HTTPS_PROXY={squid_proxy}"
+ "\&NO_PROXY=cloud-qa.mongodb.com"
)
return Operator(namespace=namespace, helm_args=helm_args).install()

Expand Down Expand Up @@ -78,7 +79,7 @@ def test_proxy_logs_requests(namespace: str):
pod_name = proxy_pods[0].metadata.name
container_name = "squid"
pod_logs = KubernetesTester.read_pod_logs(namespace, pod_name, container_name)
assert "cloud-qa.mongodb.com" in pod_logs
assert "cloud-qa.mongodb.com" not in pod_logs
assert "api-agents-qa.mongodb.com" in pod_logs
assert "api-backup-qa.mongodb.com" in pod_logs

Expand Down