Files
sless/doc/progress.md
T
“Naeel” 0268ef0523 fix: multiple fixes + pg-query e2e passed
upload.go:
- Update → Patch (MergeFrom) to avoid resourceVersion conflict when operator
  modifies Function between Get() and Update()

terraform provider v0.1.1:
- trigger_resource.go: trToModel returns StringNull() for empty schedule
  (fixes 'provider produced inconsistent result' for http triggers)
- main.go: bump version to 0.1.1

examples/pg-query:
- handler.py: fix column name started_at → created_at (matches migrations/001)
- main.tf: pin provider to ~> 0.1.1

.gitignore: add terraform state, lock, .terraform/, handler.zip

doc/errors/log.md: documented all 5 errors from this session:
- resourceVersion conflict → use Patch
- terraform inconsistent result for schedule → StringNull
- terraform import not implemented → delete+recreate workaround
- wrong column name → check migrations before writing handlers
- Deployment not restarting after image rebuild → rollout restart / TODO: restartedAt annotation

doc/progress.md: terraform apply e2e 
2026-03-07 10:52:29 +04:00

98 lines
5.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Прогресс разработки
Последнее обновление: 2026-03-07
## Статусы: ✅ готово | 🔄 в процессе | ⏳ не начато
---
## v1 — Базовый сервис
### Код
| # | Компонент | Статус | Заметки |
|---|-----------|--------|---------|
| 1 | Структура проекта, operator-sdk init | ✅ | module: gitea-naeel.giteak8s.services.ngcloud.ru/naeel/sless |
| 2 | CRD types: Function, Trigger | ✅ | api/v1alpha1/, zz_generated.deepcopy.go |
| 3 | internal/config | ✅ | config.go, Load() из env vars, добавлены IngressHost + APIToken |
| 4 | Миграции PostgreSQL | ✅ | migrations/001_initial.sql — таблица invocations |
| 5 | internal/storage/postgres | ✅ | store.go: SaveInvocation, ListInvocations, RunMigrations |
| 6 | internal/storage/s3 | ✅ | client.go: Upload, Download, Delete, EnsureBucket (Ceph S3) |
| 7 | internal/builder | ✅ | builder.go: kaniko Jobs для сборки образов функций |
| 8 | controllers/function_controller.go | ✅ | Pending→Building(kaniko)→Ready/Failed, Deployment, finalizer |
| 9 | controllers/trigger_controller.go | ✅ | HTTP→Service+Ingress, Cron→CronJob, finalizer |
| 10 | internal/api/router.go | ✅ | gorilla/mux, /v1/namespaces/{ns}/... |
| 11 | internal/api/handler/ | ✅ | functions.go, triggers.go, invocations.go, handler.go (slog) |
| 12 | internal/api/middleware/ | ✅ | auth.go (Bearer token), logging.go (slog) |
| 13 | main.go | ✅ | operator manager + HTTP сервер параллельно, wire всех зависимостей |
### Кластер (namespace: sless)
| # | Ресурс | Статус | Заметки |
|---|--------|--------|---------|
| 1 | namespace sless | ✅ | создан |
| 2 | CRD functions.sless.kube5s.ru | ✅ | установлен из config/crd/bases/ |
| 3 | CRD triggers.sless.kube5s.ru | ✅ | установлен из config/crd/bases/ |
| 4 | ServiceAccount sless-operator | ✅ | deployments/k8s/rbac.yaml |
| 5 | ClusterRole + ClusterRoleBinding | ✅ | deployments/k8s/rbac.yaml |
| 6 | PostgreSQL Deployment + Service | ✅ | deployments/k8s/postgres.yaml, Running |
| 7 | Secret postgres-secret | ✅ | в namespace sless |
### Runtime image + Upload endpoint (2026-03-07)
| # | Компонент | Статус | Заметки |
|---|-----------|--------|---------|
| 1 | runtimes/python3.11/server.py | ✅ | HTTP wrapper :8080, loads /app/function/handler.py |
| 2 | runtimes/python3.11/Dockerfile | ✅ | FROM python:3.11-slim, naeel/sless-runtime-python3.11:latest |
| 3 | Secret sless-registry-auth | ✅ | DockerHub creds для kaniko в namespace sless |
| 4 | internal/api/handler/upload.go | ✅ | POST /v1/namespaces/{ns}/functions/{name}/upload |
| 5 | Fix: kaniko S3 endpoint | ✅ | https:// + S3_FORCE_PATH_STYLE=true (Ceph) |
| 6 | Fix: бесконечный цикл сборки | ✅ | idempotency guard через аннотацию last-built-s3key |
### E2E тест (2026-03-07)
| # | Шаг | Результат |
|---|-----|-----------|
| 1 | Запуск оператора локально | ✅ `source hack/local.env && go run main.go` |
| 2 | Создание функции hello + upload handler.zip | ✅ kaniko собрал naeel/sless-default-hello:latest |
| 3 | Function phase=Ready, Deployment Running | ✅ namespace sless-fn-default |
| 4 | `GET /health` | ✅ `{"status": "ok"}` |
| 5 | `POST / {"name":"Naeel"}` | ✅ `{"message": "Hello, Naeel!"}` |
### Terraform провайдер (2026-03-07)
| # | Компонент | Статус | Заметки |
|---|-----------|--------|---------|
| 1 | terraform/provider/ — независимый Go-модуль | ✅ | module: terraform-provider-sless |
| 2 | internal/client/client.go | ✅ | HTTP-клиент sless API, готов к переносу в nubes |
| 3 | internal/provider/provider.go | ✅ | паттерн идентичен nubes NubesProvider |
| 4 | sless_function resource | ✅ | CRUD + upload zip + WaitReady (kaniko) |
| 5 | sless_trigger resource | ✅ | CRUD (http/cron) |
| 6 | hack/build-and-publish.sh | ✅ | GPG-подпись + mc upload в S3 |
| 7 | Публикация в terra.k8c.ru | ✅ | v0.1.0, key CB3A0DF161ECC416 |
| 8 | terraform init | ✅ | Installed terra.k8c.ru/naeel/sless v0.1.0 |
**Примечание:** Код провайдера писался с прицелом на перенос в nubes провайдер.
`internal/client/``internal/core/` nubes, ресурсы → `internal/resources_gen/`.
### Что ещё не сделано
| # | Компонент | Статус | Заметки |
|---|-----------|--------|---------|
| 1 | terraform apply e2e — функция с postgres | ✅ | `{"invocations": [], "count": 0}` — функция подключилась к postgres.sless.svc, таблица пустая |
| 2 | HTTP trigger e2e тест | ⏳ | Service+Ingress через TriggerController |
| 3 | deployments/k8s/operator.yaml | ⏳ | Deployment оператора в кластере |
| 4 | Перенос ресурсов sless в nubes провайдер | ⏳ | после e2e тестирования |
---
## v2 — Расширения
| # | Компонент | Статус | Заметки |
|---|-----------|--------|---------|
| 1 | RabbitMQ event triggers | ⏳ | |
| 2 | Облачный auth (nubes.ru token validation) | ⏳ | v1 — статический токен |
| 3 | Метрики → Victoria Metrics | ⏳ | |
| 4 | Managed PostgreSQL от провайдера | ⏳ | сейчас postgres в k8s |
| 5 | Pre-warm для cron триггеров | ⏳ | TriggerSpec.PreWarmSeconds — поле есть, логика не реализована |