diff --git a/src/lib/k8s.ts b/src/lib/k8s.ts index 9e91db0..4bb7452 100644 --- a/src/lib/k8s.ts +++ b/src/lib/k8s.ts @@ -150,7 +150,10 @@ export async function createAgentPod(podName: string, userId: string): Promise { const client = getK8sClient() try { - await client.deleteNamespacedPod(podName, 'agents') + await client.deleteNamespacedPod({ + name: podName, + namespace: 'agents' + }) console.log(`✅ Pod ${podName} deleted successfully`) } catch (error: any) { // Ignore 404 errors (pod already deleted) - if (error.statusCode === 404) { + if (error.statusCode === 404 || error.response?.statusCode === 404) { console.log(`⚠️ Pod ${podName} not found (already deleted)`) return } @@ -185,10 +191,13 @@ export async function getPodStatus(podName: string): Promise { const client = getK8sClient() try { - const response = await client.readNamespacedPod(podName, 'agents') + const response = await client.readNamespacedPod({ + name: podName, + namespace: 'agents' + }) return response.body.status?.phase || null } catch (error: any) { - if (error.statusCode === 404) { + if (error.statusCode === 404 || error.response?.statusCode === 404) { return null } throw error