11package debug
22
33import (
4+ _ "embed"
5+
46 "bufio"
57 "context"
68 "errors"
@@ -18,6 +20,9 @@ import (
1820 "galileoctl/pkg/utils"
1921)
2022
23+ //go:embed connectivity_check.py
24+ var connectivityCheckScript string
25+
2126// ApiConnections runs the connectivity checks from an api pod inside the given namespace.
2227func ApiConnections (namespace string , tailLines int ) error {
2328 if namespace == "" {
@@ -49,64 +54,8 @@ func ApiConnections(namespace string, tailLines int) error {
4954
5055 fmt .Printf ("✅ Using pod: %s\n " , pod )
5156
52- // Run the same Python connectivity checks inside the pod
53- py := `import socket
54- import os
55- from urllib.parse import urlparse
56-
57- services = [
58- 'rabbitmq-cluster.%s.svc.cluster.local',
59- 'authz.%s.svc.cluster.local'
60- ]
61-
62- print('Starting connectivity tests...')
63- print('')
64-
65- for svc in services:
66- print(f'Testing connectivity to {svc}...')
67- try:
68- socket.setdefaulttimeout(5)
69- result = socket.getaddrinfo(svc, None)
70- if result:
71- print(f'✅ SUCCESS: {svc} is reachable (DNS resolved)')
72- else:
73- print(f'❌ FAILED: {svc} DNS resolution failed')
74- except Exception as e:
75- print(f'❌ FAILED: {svc} is not reachable ({str(e)})')
76- print('')
77-
78- env_vars = [
79- 'GALILEO_DATABASE_URL_READ',
80- 'GALILEO_CLICKHOUSE_URL_READ_WRITE'
81- ]
82-
83- for env_var in env_vars:
84- url = os.getenv(env_var)
85- if url:
86- print(f'Testing connectivity to {env_var}...')
87- try:
88- parsed = urlparse(url)
89- host = parsed.hostname
90- port = parsed.port or (5432 if 'postgresql' in url else 9000)
91- print(f' Connecting to {host}:{port}...')
92- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
93- sock.settimeout(5)
94- result = sock.connect_ex((host, port))
95- sock.close()
96- if result == 0:
97- print(f'✅ SUCCESS: {env_var} ({host}:{port}) is reachable')
98- else:
99- print(f'❌ FAILED: {env_var} ({host}:{port}) connection refused')
100- except Exception as e:
101- print(f'❌ FAILED: {env_var} connectivity test failed ({str(e)})')
102- else:
103- print(f'⚠️ WARNING: {env_var} environment variable not found')
104- print('')
105-
106- print('Connectivity tests completed.')
107- `
108-
109- py = fmt .Sprintf (py , namespace , namespace )
57+ // Run connectivity checks inside the pod (script embedded from connectivity_check.py)
58+ py := strings .ReplaceAll (connectivityCheckScript , "{ns}" , namespace )
11059
11160 // Load Kubernetes config
11261 cfg , client , err := utils .LoadK8sConfig ()
@@ -328,6 +277,13 @@ func diagnoseLogs(logLines []string) string {
328277 issues = append (issues , "❌ ClickHouse connection failed (check if ClickHouse pods are running)" )
329278 }
330279
280+ // Redis connection issues
281+ if strings .Contains (allLogs , "redis" ) && (strings .Contains (allLogs , "connection refused" ) ||
282+ strings .Contains (allLogs , "failed to connect" ) ||
283+ strings .Contains (allLogs , "10000" )) {
284+ issues = append (issues , "❌ Redis connection failed (check Azure Managed Redis reachability)" )
285+ }
286+
331287 // RabbitMQ connection issues
332288 if strings .Contains (allLogs , "rabbitmq" ) && (strings .Contains (allLogs , "connection refused" ) ||
333289 strings .Contains (allLogs , "failed to connect" ) ||
0 commit comments