fix(db): enforce global nullpool session budget
This commit is contained in:
@@ -124,6 +124,8 @@ def test_prod_db_pool_budget_and_non_overlap_rollouts_are_source_controlled() ->
|
||||
assert "value: \"1\"" in api
|
||||
assert "DATABASE_MAX_OVERFLOW" in api
|
||||
assert "value: \"0\"" in api
|
||||
assert "DATABASE_NULL_POOL_CONCURRENCY_LIMIT" in api
|
||||
assert "2 replicas * 2 = 4 runtime connections" in api
|
||||
assert "DATABASE_BOOTSTRAP_DDL_ENABLED" in api
|
||||
assert "CD migration preflight" in api
|
||||
assert "replicas: 2" in api
|
||||
|
||||
@@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SCRIPT = ROOT / "ops" / "runner" / "verify_awoooi_api_liveness_stabilization.py"
|
||||
SPEC = importlib.util.spec_from_file_location("api_liveness_verifier", SCRIPT)
|
||||
@@ -27,6 +26,7 @@ def _receipt() -> dict[str, str]:
|
||||
return {
|
||||
"connection_budget_verified": "true",
|
||||
"api_database_null_pool": "true",
|
||||
"api_database_null_pool_concurrency_limit": "2",
|
||||
"api_representative_db_preflight_passed": "true",
|
||||
"api_http_concurrency_probe_passed": "true",
|
||||
"api_db_connection_limit": "12",
|
||||
@@ -82,6 +82,28 @@ def test_live_contract_fails_closed_on_budget_restart_or_cpu_regression() -> Non
|
||||
assert "live_cpu_saturated:awoooi-api-a:1000m" in failures
|
||||
|
||||
|
||||
def test_live_contract_rejects_missing_api_null_pool_concurrency_cap() -> None:
|
||||
pods = _pods()
|
||||
restarts = {pod["metadata"]["name"]: 0 for pod in pods}
|
||||
receipt = _receipt()
|
||||
receipt["api_database_null_pool_concurrency_limit"] = "0"
|
||||
|
||||
failures = verifier.evaluate_live_state(
|
||||
_live_deployment(),
|
||||
receipt,
|
||||
pods,
|
||||
restarts,
|
||||
restarts,
|
||||
{pod["metadata"]["name"]: 410 for pod in pods},
|
||||
900,
|
||||
)
|
||||
|
||||
assert (
|
||||
"receipt_api_database_null_pool_concurrency_limit_not_verified"
|
||||
in failures
|
||||
)
|
||||
|
||||
|
||||
def test_edge_receipt_requires_a_qualified_production_vantage() -> None:
|
||||
assert verifier.evaluate_edge_receipt(
|
||||
"192.168.0.120",
|
||||
|
||||
@@ -12,7 +12,6 @@ import urllib.request
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MANIFEST = ROOT / "k8s" / "awoooi-prod" / "06-deployment-api.yaml"
|
||||
NAMESPACE = "awoooi-prod"
|
||||
@@ -81,11 +80,15 @@ def evaluate_source_contract(deployment: dict[str, Any]) -> list[str]:
|
||||
"replicas": (spec.get("replicas"), 2),
|
||||
"max_surge": (strategy.get("maxSurge"), 0),
|
||||
"max_unavailable": (strategy.get("maxUnavailable"), 1),
|
||||
"cpu_limit": ((container.get("resources") or {}).get("limits", {}).get("cpu"), "1"),
|
||||
"cpu_limit": ((container.get("resources") or {}).get("limits", {}).get("cpu"), "2"),
|
||||
"memory_limit": ((container.get("resources") or {}).get("limits", {}).get("memory"), "1Gi"),
|
||||
"database_pool_size": (env.get("DATABASE_POOL_SIZE"), "1"),
|
||||
"database_max_overflow": (env.get("DATABASE_MAX_OVERFLOW"), "0"),
|
||||
"database_null_pool": (env.get("DATABASE_NULL_POOL"), "true"),
|
||||
"database_null_pool_concurrency_limit": (
|
||||
env.get("DATABASE_NULL_POOL_CONCURRENCY_LIMIT"),
|
||||
"2",
|
||||
),
|
||||
"database_bootstrap_ddl_enabled": (
|
||||
env.get("DATABASE_BOOTSTRAP_DDL_ENABLED"),
|
||||
"false",
|
||||
@@ -154,6 +157,7 @@ def evaluate_live_state(
|
||||
expected_receipt = {
|
||||
"connection_budget_verified": "true",
|
||||
"api_database_null_pool": "true",
|
||||
"api_database_null_pool_concurrency_limit": "2",
|
||||
"api_representative_db_preflight_passed": "true",
|
||||
"api_http_concurrency_probe_passed": "true",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user