Fix K8s API calls: use param object format
All checks were successful
Build and Push Backend / build (push) Successful in 5s
All checks were successful
Build and Push Backend / build (push) Successful in 5s
The @kubernetes/client-node API expects parameters as an object:
{ namespace: 'ns', body: pod } instead of positional params.
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -150,7 +150,10 @@ export async function createAgentPod(podName: string, userId: string): Promise<v
|
||||
const podSpec = createAgentPodSpec(podName, userId)
|
||||
|
||||
try {
|
||||
await client.createNamespacedPod('agents', podSpec)
|
||||
await client.createNamespacedPod({
|
||||
namespace: 'agents',
|
||||
body: podSpec
|
||||
})
|
||||
console.log(`✅ Pod ${podName} created successfully`)
|
||||
} catch (error: any) {
|
||||
console.error(`❌ Failed to create pod ${podName}:`, error.message)
|
||||
@@ -165,11 +168,14 @@ export async function deleteAgentPod(podName: string): Promise<void> {
|
||||
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<string | null> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user