Skip to content

Commit bc8f817

Browse files
committed
chore: add troubleshooting script for SQLSRV
Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com>
1 parent 528155f commit bc8f817

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.gitlab/check_sqlsrv.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
3+
set +e # Don't exit on error, we want to collect diagnostics
4+
5+
echo "=== SQL Server Diagnostics ==="
6+
7+
# Check if sqlsrv-integration is reachable
8+
echo "1. Checking if SQL Server port is reachable..."
9+
if timeout 5 bash -c "echo > /dev/tcp/sqlsrv-integration/1433" 2>/dev/null; then
10+
echo "✓ SQL Server port 1433 is open"
11+
else
12+
echo "✗ SQL Server port 1433 is NOT reachable"
13+
fi
14+
15+
# Try to connect via sqlcmd if available
16+
echo ""
17+
echo "2. Attempting SQL Server connection test..."
18+
if command -v sqlcmd &> /dev/null; then
19+
sqlcmd -S sqlsrv-integration,1433 -U sa -P 'Password12!' -Q 'SELECT @@VERSION' -C 2>&1 || echo "✗ Connection test failed"
20+
else
21+
echo "⊘ sqlcmd not available in this container"
22+
fi
23+
24+
# DNS check
25+
echo ""
26+
echo "3. DNS resolution check..."
27+
if command -v host &> /dev/null; then
28+
host sqlsrv-integration 2>&1 || echo "✗ DNS lookup failed"
29+
elif command -v nslookup &> /dev/null; then
30+
nslookup sqlsrv-integration 2>&1 || echo "✗ DNS lookup failed"
31+
else
32+
getent hosts sqlsrv-integration 2>&1 || echo "✗ DNS lookup failed"
33+
fi
34+
35+
# Check if we can get Kubernetes pod logs
36+
echo ""
37+
echo "4. Attempting to fetch SQL Server container logs..."
38+
if command -v kubectl &> /dev/null && [ -n "${CI_PROJECT_DIR}" ]; then
39+
POD_NAME=$(kubectl get pods -n gitlab-runner -l "ci-job-id=${CI_JOB_ID}" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
40+
41+
if [ -n "$POD_NAME" ]; then
42+
echo "Found pod: $POD_NAME"
43+
echo "--- SQL Server container logs (last 50 lines) ---"
44+
kubectl logs -n gitlab-runner "$POD_NAME" -c svc-3 --tail=50 2>&1 || echo "✗ Could not fetch container logs"
45+
echo "--- End of SQL Server logs ---"
46+
else
47+
echo "✗ Could not determine pod name"
48+
fi
49+
else
50+
echo "⊘ kubectl not available or not in CI environment"
51+
fi
52+
53+
# Network diagnostics
54+
echo ""
55+
echo "5. Network diagnostics..."
56+
echo "Active connections:"
57+
ss -tunap 2>/dev/null | grep -E "sqlsrv|1433" || netstat -tunap 2>/dev/null | grep -E "sqlsrv|1433" || echo "⊘ Network tools not available"
58+
59+
# Environment info
60+
echo ""
61+
echo "6. Environment information..."
62+
echo "Hostname: $(hostname)"
63+
echo "Pod IP: ${HOSTNAME:-unknown}"
64+
echo "Service env vars:"
65+
env | grep -i "sqlsrv\|sql\|mssql" | grep -v "PASSWORD" || echo "No SQL Server env vars found"
66+
67+
echo ""
68+
echo "=== End SQL Server Diagnostics ==="

.gitlab/generate-tracer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ function after_script($execute_dir = ".", $has_test_agent = false) {
2222
<?php if ($has_test_agent): ?>
2323
- .gitlab/check_test_agent.sh
2424
<?php endif; ?>
25+
- |
26+
if [[ "${MAKE_TARGET:-}" == *"sqlsrv"* ]]; then
27+
.gitlab/check_sqlsrv.sh
28+
fi
2529
- .gitlab/collect_artifacts.sh "<?= $execute_dir ?>"
2630
- .gitlab/silent-upload-junit-to-datadog.sh "test.source.file:src"
2731
<?php

0 commit comments

Comments
 (0)