- New services/cost_tracker.py: sync httpx preflight()/record() + async wrappers; BudgetExceeded exception; no-op when COST_TRACKER_BASE_URL is empty - Preflight budget check added before ingestion (Gemini), per-language translation (video-native + traditional), and per-language TTS dispatch - _record_gemini_usage and _record_tts_cost now call cost_tracker directly; removes broken asyncio.get_event_loop() hack from sync Celery worker - Fix: _cost_ctx now threaded into extract_accessibility_targeted (video-native path) - Fix: user_id/cost_project_id now propagated through dispatch_language_tts → synthesize_cue_task.s() and the rerender_accessible_video.py re-render path - Remove oliver-cost-tracker SDK dependency (was commented-out/never installed) - Drop cost_tracker_outbox_path setting and get_cost_tracker() factory - Update COST_TRACKER_BASE_URL default to optical-dev.oliver.solutions in .env.prod.example, docker-compose.yml, and all Cloud Run service yamls - Cloud Run yamls use Secret Manager ref (cost-tracker-api-key) for the API key Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
128 lines
No EOL
3.7 KiB
YAML
128 lines
No EOL
3.7 KiB
YAML
apiVersion: serving.knative.dev/v1
|
|
kind: Service
|
|
metadata:
|
|
name: accessible-video-api
|
|
annotations:
|
|
run.googleapis.com/ingress: all
|
|
run.googleapis.com/execution-environment: gen2
|
|
autoscaling.knative.dev/minScale: "1"
|
|
autoscaling.knative.dev/maxScale: "10"
|
|
run.googleapis.com/cpu-throttling: "false"
|
|
spec:
|
|
template:
|
|
metadata:
|
|
annotations:
|
|
autoscaling.knative.dev/maxScale: "10"
|
|
autoscaling.knative.dev/minScale: "1"
|
|
run.googleapis.com/execution-environment: gen2
|
|
run.googleapis.com/cpu-throttling: "false"
|
|
spec:
|
|
containerConcurrency: 100
|
|
timeoutSeconds: 3600
|
|
serviceAccountName: accessible-video-api@PROJECT_ID.iam.gserviceaccount.com
|
|
containers:
|
|
- image: gcr.io/PROJECT_ID/accessible-video-api:latest
|
|
ports:
|
|
- containerPort: 8000
|
|
env:
|
|
- name: APP_ENV
|
|
value: "prod"
|
|
- name: PYTHONPATH
|
|
value: "/app"
|
|
- name: PYTHONUNBUFFERED
|
|
value: "1"
|
|
- name: PYTHONDONTWRITEBYTECODE
|
|
value: "1"
|
|
- name: PORT
|
|
value: "8000"
|
|
- name: MONGODB_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mongodb-url
|
|
key: latest
|
|
- name: REDIS_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: redis-url
|
|
key: latest
|
|
- name: JWT_SECRET_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: jwt-secret
|
|
key: latest
|
|
- name: JWT_REFRESH_SECRET_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: jwt-refresh-secret
|
|
key: latest
|
|
- name: GEMINI_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: gemini-api-key
|
|
key: latest
|
|
- name: SENDGRID_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: sendgrid-api-key
|
|
key: latest
|
|
- name: ELEVENLABS_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: elevenlabs-api-key
|
|
key: latest
|
|
- name: GCS_BUCKET_NAME
|
|
value: "accessible-video-storage"
|
|
- name: GOOGLE_CLOUD_PROJECT
|
|
value: "PROJECT_ID"
|
|
# OpenTelemetry configuration
|
|
- name: OTEL_SERVICE_NAME
|
|
value: "accessible-video-api"
|
|
- name: OTEL_SERVICE_VERSION
|
|
value: "1.0.0"
|
|
- name: OTEL_TRACES_EXPORTER
|
|
value: "gcp_trace"
|
|
- name: OTEL_METRICS_EXPORTER
|
|
value: "prometheus"
|
|
- name: OTEL_LOGS_EXPORTER
|
|
value: "none"
|
|
# Sentry configuration
|
|
- name: SENTRY_DSN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: sentry-dsn
|
|
key: latest
|
|
- name: SENTRY_ENVIRONMENT
|
|
value: "production"
|
|
# AI Cost Tracker
|
|
- name: COST_TRACKER_BASE_URL
|
|
value: "https://optical-dev.oliver.solutions/cost-tracker/v1"
|
|
- name: COST_TRACKER_API_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: cost-tracker-api-key
|
|
key: latest
|
|
- name: COST_TRACKER_SOURCE_APP
|
|
value: "video-accessibility"
|
|
- name: COST_TRACKER_ENABLED
|
|
value: "true"
|
|
resources:
|
|
limits:
|
|
memory: "2Gi"
|
|
cpu: "2000m"
|
|
requests:
|
|
memory: "1Gi"
|
|
cpu: "1000m"
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8000
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 60
|
|
timeoutSeconds: 10
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8000
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5 |