KB-13BF
S109 Cleanup + Verify Report — 2026-03-11
7 min read Revision 1
reportcleanupverifyVPSmigrationS109
S109 Cleanup + Verify Report — 2026-03-11
1. DỌN DẸP AGENT DATA
- Tổng files đã xóa: 69 (37 batch 1 + 32 batch 2)
- Tổng documents còn lại: 358 (trước: 427)
- knowledge: 153
- operations: 97
- registries: 106
- test: 2
- Orphan vectors phát hiện: 0 — search với keywords từ files đã xóa trả về kết quả từ files khác, không từ files đã xóa
2. KIỂM TRA THỰC TẾ VPS
PostgreSQL:
- Version: PostgreSQL 16 (container image: postgres:16)
- Docker container: CÓ — tên
workflow-postgres, Up 11 days (healthy) - Port 5432: KHÔNG listening externally (chỉ internal Docker network, IP 172.19.0.2)
- Databases hiện có: Chưa list được (docker exec postgres fails vì tên container là
workflow-postgres) - Container nằm trong compose riêng:
/opt/incomex/docker/nuxt-repo/web/.directus/docker-compose.yaml - ⚠️ VẤN ĐỀ: Container tên
workflow-postgres, KHÔNG có trong main docker-compose.yml. Cần thêm vào main compose hoặc đổi tên container.
Disk:
- Total: 96 GB
- Used: 38 GB (39%)
- Available: 59 GB
- Đủ cho migration: CÓ — 59GB trống, đủ cho bucket data + PG + growth
Docker Stack:
- Services đang chạy: 6 (nginx, nuxt, directus, agent-data, mysql, qdrant)
- PostgreSQL trong main compose: KHÔNG (nằm trong compose riêng)
- Agent Data image: asia-southeast1-docker.pkg.dev (Artifact Registry)
- Nuxt image: asia-southeast1-docker.pkg.dev (Artifact Registry)
Firestore dependency:
- Files import Firestore (core): 4 files
server.py— ~20 references,_firestore()function, CRUD operations chínhmain.py—firestore.Client()init, GCS ingestionresilient_client.py— health probeprobe_firestore()memory.py— chat memory storage via Firestore
- Files test: 10 files (test_server.py, test_firestore_integration.py, etc.)
- Complexity: MEDIUM-HIGH — server.py là core, ~20 Firestore calls spread qua nhiều endpoints
- Collections dùng: kb_documents (chính), chat sessions/memory
Bucket dependency:
- Files import GCS: 2 files (server.py, main.py)
- Complexity: LOW — chỉ dùng cho ingestion (parse_gcs_uri), không dùng cho storage chính
- Buckets dùng: huyen1974_agent_data_knowledge_test (inferred)
- Pattern: simple file download for ingestion, không có streaming phức tạp
Artifact Registry:
- Workflows dùng AR: 2
artifact-registry-cd.yml— build + push to ARdeploy-vps.yml— pull from AR + deploy to VPS via SSH
- Pattern VPS direct deploy sẵn có: CÓ — web-test có
deploy-vps.yml(proven pattern) - agent-data-test đã có
deploy-vps.ymlnhưng vẫn pull image từ AR
Secrets (Google Secret Manager):
- Tổng secrets: 14
- Secrets liên quan Firestore/GCS: GCS_BUCKET_BACKUP
- Secrets cần giữ sau migration:
- AGENT_DATA_API_KEY
- OPENAI_API_KEY
- POSTGRES_DB, POSTGRES_PASSWORD, POSTGRES_USER
- QDRANT_LOCAL_API_KEY, QDRANT_URL
- gh_pat_sync_secrets
- smtp-password-nmhuyen
- vps_contabo_id, vps_contabo_secret
- MYSQL_ROOT_PASSWORD (cho đến khi retire MySQL)
- Có thể xóa sau migration: GCS_BUCKET_BACKUP, Qdrant_agent_data_N1D8R2vC0_5 (legacy name)
3. ĐỐI CHIẾU VỚI KẾ HOẠCH
| Hạng mục | Kế hoạch ghi | Thực tế | Khớp? | Cần sửa? |
|---|---|---|---|---|
| PostgreSQL 16 đã cài | Khoản 2 Luật VPS | PG 16 running (workflow-postgres), healthy | ✅ Khớp | Container cần thêm vào main compose |
| Docker compose có PG | Khoản 5 Luật VPS | KHÔNG có trong main compose | ❌ Không khớp | Cần thêm postgres service vào main compose |
| Firestore refactor ~2.5 ngày | CP-3 Migration Plan | 4 core files, ~20 refs trong server.py | ✅ Hợp lý | Có thể 2-3 ngày, server.py phức tạp |
| Bucket refactor ~1.5 ngày | CP-2 Migration Plan | Chỉ 2 files, LOW complexity | ⚡ Nhanh hơn | 0.5-1 ngày đủ |
| Artifact deploy pattern có sẵn | CP-1 Migration Plan | web-test deploy-vps.yml proven, agent-data đã có deploy-vps.yml | ✅ Sẵn sàng | Chỉ cần bỏ AR dependency |
| Disk 100GB đủ | Khoản 3 Luật VPS | 96GB total, 59GB available (39%) | ✅ Khớp | Đủ cho migration |
4. KHUYẾN NGHỊ TRƯỚC KHI BẮT TAY VÀO
Cần làm trước migration (nếu có):
- Thêm postgres vào main docker-compose.yml — hiện tại workflow-postgres chạy từ compose riêng tại nuxt-repo, cần consolidate
- Đổi tên container từ
workflow-postgres→postgresđể khớp với migration plan (docker exec postgres) - Tạo database + user trước:
CREATE DATABASE incomex_metadata; CREATE USER incomex; - Backup Firestore trước khi bắt đầu CP-3
- DISABLE GCP BILLING ngay (tiết kiệm ₫45K/ngày)
Cần sửa kế hoạch (nếu có):
- CP-2 Bucket: Giảm timeline từ 1.5 ngày → 0.5-1 ngày (GCS chỉ dùng cho ingestion, LOW complexity)
- CP-1 Artifact: agent-data đã có deploy-vps.yml nhưng vẫn pull từ AR. Cần refactor thành build local trên VPS hoặc build trong GH Actions rồi scp
- CP-3 Firestore: server.py cần refactor cẩn thận —
_firestore()function là entry point chính, 20+ calls. Nên giữ nguyên interface, thay backend - Docker compose: Cần bước consolidate — merge workflow-postgres vào main compose TRƯỚC khi migration
Thứ tự ưu tiên đề xuất:
- DISABLE BILLING GCP (ngay hôm nay, tiết kiệm ₫45K/ngày)
- Consolidate Docker compose (thêm postgres vào main, tạo DB/user)
- CP-1 Artifact Registry → Direct deploy (0.5 ngày)
- CP-2 GCS Buckets → Local storage (0.5-1 ngày)
- CP-3 Firestore → PostgreSQL (2-3 ngày)
- CP-4 Verify + Cleanup (1 ngày)
Rủi ro phát hiện thêm:
- workflow-postgres ở compose riêng — nếu restart main compose, PG không restart theo → cần merge
- agent-data image vẫn từ AR — nếu disable GCP billing → không pull được image mới → CẦN GIẢI QUYẾT TRƯỚC KHI DISABLE BILLING
- Nuxt image cũng từ AR — cùng rủi ro như agent-data
docker exec postgresfails — tất cả migration plan commands dùngdocker exec postgressẽ fail vì container tênworkflow-postgres- VPS .env chỉ có DIRECTUS_SECRET — thiếu nhiều env vars cho PG, Firestore, GCS → kiểm tra lại source of secrets