Fix getPodIP: handle different K8s API response structures
All checks were successful
Build and Push Backend / build (push) Successful in 6s

- Add debug logging to getPodIP
- Handle both response.body and direct response
- Apply same fix to getPodStatus for consistency
- Fixes 500 error when accessing agent terminal
This commit is contained in:
Hector Ros
2026-01-20 19:56:04 +01:00
parent 209b439d26
commit 6864258810

View File

@@ -253,7 +253,10 @@ export async function getPodStatus(podName: string): Promise<string | null> {
name: podName, name: podName,
namespace: 'agents' namespace: 'agents'
}) })
return response.body.status?.phase || null
// Handle different response structures
const pod = response.body || response
return pod?.status?.phase || null
} catch (error: any) { } catch (error: any) {
if (error.statusCode === 404 || error.response?.statusCode === 404) { if (error.statusCode === 404 || error.response?.statusCode === 404) {
return null return null
@@ -269,12 +272,23 @@ export async function getPodIP(podName: string): Promise<string | null> {
const client = getK8sClient() const client = getK8sClient()
try { try {
console.log(`🔍 Getting IP for pod: ${podName}`)
const response = await client.readNamespacedPod({ const response = await client.readNamespacedPod({
name: podName, name: podName,
namespace: 'agents' namespace: 'agents'
}) })
return response.body.status?.podIP || null
console.log(`🔍 Response type: ${typeof response}`)
console.log(`🔍 Has body: ${'body' in response}`)
// Handle different response structures
const pod = response.body || response
const podIP = pod?.status?.podIP
console.log(`🔍 Pod IP: ${podIP}`)
return podIP || null
} catch (error: any) { } catch (error: any) {
console.error(`❌ Error getting pod IP for ${podName}:`, error.message)
if (error.statusCode === 404 || error.response?.statusCode === 404) { if (error.statusCode === 404 || error.response?.statusCode === 404) {
return null return null
} }