fix: persist code agent workspace

This commit is contained in:
Codex
2026-05-27 13:25:52 +08:00
parent 3c7f13191b
commit d02b7cd8a6
8 changed files with 421 additions and 16 deletions
+52 -1
View File
@@ -2,6 +2,28 @@
"apiVersion": "v1",
"kind": "List",
"items": [
{
"apiVersion": "v1",
"kind": "PersistentVolumeClaim",
"metadata": {
"labels": {
"app.kubernetes.io/name": "hwlab-code-agent-workspace",
"hwlab.pikastech.local/service-id": "hwlab-code-agent-workspace"
},
"name": "hwlab-code-agent-workspace",
"namespace": "hwlab-dev"
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "8Gi"
}
}
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
@@ -15,6 +37,9 @@
},
"spec": {
"replicas": 1,
"strategy": {
"type": "Recreate"
},
"selector": {
"matchLabels": {
"app.kubernetes.io/name": "hwlab-cloud-api"
@@ -28,6 +53,30 @@
}
},
"spec": {
"initContainers": [
{
"command": [
"sh",
"-ceu",
"target=/workspace/hwlab\nmarker=\"$target/.hwlab-workspace-initialized\"\nmkdir -p \"$target\"\nif [ ! -e \"$marker\" ]; then\n if [ -z \"$(find \"$target\" -mindepth 1 -maxdepth 1 ! -name lost+found -print -quit)\" ]; then\n cp -a /app/. \"$target\"/\n mode=copied-from-image\n else\n mode=adopted-existing-workspace\n fi\n printf '%s\\n' \"$mode\" > \"$marker\"\n printf '%s\\n' \"${HWLAB_WORKSPACE_SOURCE_COMMIT:-unknown}\" > \"$target/.hwlab-workspace-base-revision\"\nfi\nprintf '%s\\n' \"${HWLAB_WORKSPACE_SOURCE_COMMIT:-unknown}\" > \"$target/.hwlab-workspace-current-image-revision\"\n"
],
"env": [
{
"name": "HWLAB_WORKSPACE_SOURCE_COMMIT",
"value": "af46386"
}
],
"image": "127.0.0.1:5000/hwlab/hwlab-cloud-api:af46386",
"imagePullPolicy": "IfNotPresent",
"name": "hwlab-code-agent-workspace-init",
"volumeMounts": [
{
"mountPath": "/workspace",
"name": "hwlab-code-agent-workspace"
}
]
}
],
"containers": [
{
"name": "hwlab-cloud-api",
@@ -303,7 +352,9 @@
"volumes": [
{
"name": "hwlab-code-agent-workspace",
"emptyDir": {}
"persistentVolumeClaim": {
"claimName": "hwlab-code-agent-workspace"
}
},
{
"name": "hwlab-code-agent-codex-home",