Skip to content

Commit 801e451

Browse files
fenarclaude
andcommitted
fix(sandbox): Add missing dependencies and SSL/auth support for sandbox testing
- Add cryptography and kubernetes dependencies to cluster-registry - Add python-jose dependency to realtime-streaming for JWT auth - Update prometheus_collector to skip TLS verification in dev mode - Use pod's service account token for Prometheus auth in dev mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dba8506 commit 801e451

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

src/cluster-registry/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ structlog>=24.1.0,<25.0.0
2323
# HTTP client
2424
httpx>=0.26.0,<0.30.0
2525

26+
# Cryptography for credential encryption
27+
cryptography>=42.0.0,<43.0.0
28+
29+
# Kubernetes client
30+
kubernetes>=29.0.0,<30.0.0
31+
2632
# Testing
2733
pytest>=8.0.0,<9.0.0
2834
pytest-asyncio>=0.23.0,<1.0.0

src/observability-collector/app/collectors/prometheus_collector.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import httpx
1313

14+
from shared.config import get_settings
1415
from shared.observability import get_logger
1516

1617
logger = get_logger(__name__)
@@ -23,9 +24,14 @@ class PrometheusCollector:
2324
"""
2425

2526
def __init__(self):
27+
self.settings = get_settings()
28+
# Create client with SSL verification based on settings
29+
# In sandbox/development mode, we may skip TLS verification
30+
verify = not self.settings.is_development
2631
self.client = httpx.AsyncClient(
2732
timeout=httpx.Timeout(30.0, connect=5.0),
2833
follow_redirects=True,
34+
verify=verify,
2935
)
3036

3137
async def query(
@@ -97,7 +103,7 @@ async def query(
97103
"data": self._parse_result(result),
98104
}
99105

100-
except asyncio.TimeoutError:
106+
except TimeoutError:
101107
return {
102108
"cluster_id": str(cluster["id"]),
103109
"cluster_name": cluster["name"],
@@ -193,7 +199,7 @@ async def query_range(
193199
"data": self._parse_result(result),
194200
}
195201

196-
except asyncio.TimeoutError:
202+
except TimeoutError:
197203
return {
198204
"cluster_id": str(cluster["id"]),
199205
"cluster_name": cluster["name"],
@@ -251,9 +257,25 @@ async def get_labels(self, cluster: dict) -> list[str]:
251257

252258
def _get_auth_headers(self, cluster: dict) -> dict[str, str]:
253259
"""Get authentication headers for cluster."""
254-
# In a real implementation, this would get the token from credentials
255-
# For now, return empty headers
256-
return {}
260+
headers = {}
261+
262+
# First check if cluster has a token in credentials
263+
credentials = cluster.get("credentials", {})
264+
token = credentials.get("token")
265+
266+
# For sandbox/development, use the pod's service account token
267+
# if querying the same cluster
268+
if not token and self.settings.is_development:
269+
try:
270+
with open("/var/run/secrets/kubernetes.io/serviceaccount/token") as f:
271+
token = f.read().strip()
272+
except FileNotFoundError:
273+
pass
274+
275+
if token:
276+
headers["Authorization"] = f"Bearer {token}"
277+
278+
return headers
257279

258280
def _parse_result(self, result: dict) -> list[dict]:
259281
"""Parse Prometheus result into standard format."""

src/realtime-streaming/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ pydantic>=2.5.0
77
pydantic-settings>=2.1.0
88
structlog>=24.1.0
99
httpx>=0.26.0
10+
11+
# JWT authentication
12+
python-jose[cryptography]>=3.3.0

0 commit comments

Comments
 (0)