Add extensive debug logging for K8s client
All checks were successful
Build and Push Backend / build (push) Successful in 4s
All checks were successful
Build and Push Backend / build (push) Successful in 4s
- Log cluster config details - Log HTTPS agent setup - Log detailed error information on pod creation failure - Track applyToHTTPSOptions execution Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,24 +21,33 @@ export function initK8sClient() {
|
|||||||
|
|
||||||
if (inCluster) {
|
if (inCluster) {
|
||||||
k8sConfig.loadFromCluster()
|
k8sConfig.loadFromCluster()
|
||||||
|
console.log('📦 Loaded K8s config from cluster')
|
||||||
|
|
||||||
// Skip TLS verification when in cluster
|
// Skip TLS verification when in cluster
|
||||||
// This is needed because the cluster uses self-signed certificates
|
// This is needed because the cluster uses self-signed certificates
|
||||||
const cluster = k8sConfig.getCurrentCluster()
|
const cluster = k8sConfig.getCurrentCluster()
|
||||||
|
console.log('📦 Current cluster:', cluster)
|
||||||
|
|
||||||
if (cluster) {
|
if (cluster) {
|
||||||
cluster.skipTLSVerify = true
|
cluster.skipTLSVerify = true
|
||||||
console.log('🔓 K8s client configured to skip TLS verification (in-cluster mode)')
|
console.log('🔓 Set skipTLSVerify = true')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create custom HTTPS agent that ignores certificate errors
|
// Create custom HTTPS agent that ignores certificate errors
|
||||||
const httpsAgent = new https.Agent({
|
const httpsAgent = new https.Agent({
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
})
|
})
|
||||||
|
console.log('🔓 Created HTTPS agent with rejectUnauthorized: false')
|
||||||
|
|
||||||
// Apply custom agent to the config
|
// Apply custom agent to the config
|
||||||
|
try {
|
||||||
k8sConfig.applyToHTTPSOptions({
|
k8sConfig.applyToHTTPSOptions({
|
||||||
httpsAgent: httpsAgent
|
httpsAgent: httpsAgent
|
||||||
} as any)
|
} as any)
|
||||||
|
console.log('✅ Applied custom HTTPS agent to K8s config')
|
||||||
|
} catch (applyError: any) {
|
||||||
|
console.error('❌ Failed to apply HTTPS options:', applyError.message)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Load from kubeconfig file
|
// Load from kubeconfig file
|
||||||
const configPath = process.env.K8S_CONFIG_PATH || process.env.KUBECONFIG || '~/.kube/config'
|
const configPath = process.env.K8S_CONFIG_PATH || process.env.KUBECONFIG || '~/.kube/config'
|
||||||
@@ -168,14 +177,28 @@ export async function createAgentPod(podName: string, userId: string): Promise<v
|
|||||||
const client = getK8sClient()
|
const client = getK8sClient()
|
||||||
const podSpec = createAgentPodSpec(podName, userId)
|
const podSpec = createAgentPodSpec(podName, userId)
|
||||||
|
|
||||||
|
console.log(`🔧 Creating pod ${podName} for user ${userId}`)
|
||||||
|
console.log(`🔧 K8s config:`, {
|
||||||
|
cluster: k8sConfig?.getCurrentCluster(),
|
||||||
|
user: k8sConfig?.getCurrentUser(),
|
||||||
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.createNamespacedPod({
|
const result = await client.createNamespacedPod({
|
||||||
namespace: 'agents',
|
namespace: 'agents',
|
||||||
body: podSpec
|
body: podSpec
|
||||||
})
|
})
|
||||||
console.log(`✅ Pod ${podName} created successfully`)
|
console.log(`✅ Pod ${podName} created successfully`)
|
||||||
|
console.log(`✅ Pod UID: ${result.body.metadata?.uid}`)
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(`❌ Failed to create pod ${podName}:`, error.message)
|
console.error(`❌ Failed to create pod ${podName}`)
|
||||||
|
console.error(`❌ Error message:`, error.message)
|
||||||
|
console.error(`❌ Error code:`, error.code)
|
||||||
|
console.error(`❌ Error stack:`, error.stack)
|
||||||
|
if (error.response) {
|
||||||
|
console.error(`❌ Response status:`, error.response.statusCode)
|
||||||
|
console.error(`❌ Response body:`, error.response.body)
|
||||||
|
}
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user