feat(service): timeout_sec без дефолта; 0=нет таймаута; operator v0.1.48

- api/v1alpha1/service_types.go: убрать +kubebuilder:default=30
- invoke.go: TimeoutSec=0 → &http.Client{} (без таймаута)
- services.go: валидация timeout_sec < 0 || > 900 → HTTP 400
- service_resource.go: TF schema Optional (без Computed); 0 → Int64Null()
- deployments/k8s/operator.yaml: v0.1.47 → v0.1.48
- doc/: progress.md + api/design.md (модель Service) + decisions/log.md
- examples/POSTGRES/: bug_hunter.sh, chaos_marathon.sh, chaos_marathon.tf
This commit is contained in:
Naeel
2026-03-21 16:58:43 +03:00
parent 7f7aa44e59
commit b86ff3a62e
37 changed files with 2493 additions and 50 deletions
@@ -0,0 +1,33 @@
# 2026-03-21 — pg-delete-old: удаляет строки старше N минут (default 60).
# Тестирует: DELETE с RETURNING, идемпотентность (повторный вызов = 0 удалений если нет старых).
import os, psycopg2, psycopg2.extras
def delete_old(event):
older_than_min = max(int(event.get("older_than_min", 60)), 1)
prefix_filter = event.get("prefix", "")
conn = psycopg2.connect(
host=os.environ["PGHOST"], port=int(os.environ.get("PGPORT", 5432)),
dbname=os.environ["PGDATABASE"], user=os.environ["PGUSER"],
password=os.environ["PGPASSWORD"], sslmode=os.environ.get("PGSSLMODE", "require"),
)
try:
with conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur:
if prefix_filter:
cur.execute(
"DELETE FROM terraform_demo_table "
"WHERE created_at < now() - interval '1 minute' * %s "
"AND title LIKE %s RETURNING id, title",
(older_than_min, f"{prefix_filter}%"),
)
else:
cur.execute(
"DELETE FROM terraform_demo_table "
"WHERE created_at < now() - interval '1 minute' * %s RETURNING id, title",
(older_than_min,),
)
deleted = [dict(r) for r in cur.fetchall()]
conn.commit()
return {"deleted": len(deleted), "older_than_min": older_than_min, "sample": deleted[:5]}
finally:
conn.close()