Skip to content

Commit d589376

Browse files
authored
Merge branch 'main' into konflux/mintmaker/main/redis-7.x
2 parents 5959754 + 3c37275 commit d589376

39 files changed

+2358
-264
lines changed

.env.example

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ GOOGLE_API_KEY=your_google_api_key_here
1515

1616
# Vertex AI Configuration (required if GOOGLE_GENAI_USE_VERTEXAI=TRUE)
1717
GOOGLE_CLOUD_PROJECT=your_gcp_project_id
18-
GOOGLE_CLOUD_LOCATION=us-central1
18+
GOOGLE_CLOUD_LOCATION=global
1919

2020
# Model to use (default: gemini-2.5-flash)
2121
GEMINI_MODEL=gemini-2.5-flash
2222

23+
# Gemini HTTP retries (google-genai SDK: exponential backoff + jitter for 429/408/5xx)
24+
# See: https://cloud.google.com/vertex-ai/generative-ai/docs/retry-strategy
25+
# GEMINI_HTTP_RETRY_ATTEMPTS=5
26+
# GEMINI_HTTP_RETRY_INITIAL_DELAY=1.0
27+
# GEMINI_HTTP_RETRY_MAX_DELAY=60.0
28+
# GEMINI_HTTP_RETRY_EXP_BASE=2.0
29+
# GEMINI_HTTP_RETRY_JITTER=1.0
30+
2331
# -----------------------------------------------------------------------------
2432
# Red Hat SSO / OAuth 2.0 Configuration
2533
# -----------------------------------------------------------------------------
@@ -154,6 +162,11 @@ LOG_FORMAT=json
154162
# detailed - Also logs tool arguments and truncated results (may contain user data)
155163
AGENT_LOGGING_DETAIL=basic
156164

165+
# Maximum character length for MCP tool results sent to the LLM.
166+
# Oversized results are replaced with a message advising the user to
167+
# narrow down their query or use pagination. Set to 0 to disable.
168+
TOOL_RESULT_MAX_CHARS=51200
169+
157170
# Audit logging (automatic when LOG_FORMAT=json):
158171
# JSON log records automatically include user_id, org_id, order_id, and
159172
# request_id fields for every log entry. These fields are populated from

.tekton/google-lightspeed-agent-pull-request.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ spec:
351351
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
352352
- name: CACHI2_ARTIFACT
353353
value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
354+
- name: ARGS
355+
value: "--project-name=google-lightspeed-agent --report --org=d152f68c-67b3-4efa-a5da-207d8219ca59"
354356
runAfter:
355357
- build-image-index
356358
taskRef:

.tekton/google-lightspeed-agent-push.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ spec:
348348
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
349349
- name: CACHI2_ARTIFACT
350350
value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
351+
- name: ARGS
352+
value: "--project-name=google-lightspeed-agent --report --org=d152f68c-67b3-4efa-a5da-207d8219ca59"
351353
runAfter:
352354
- build-image-index
353355
taskRef:

.tekton/google-marketplace-handler-pull-request.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ spec:
353353
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
354354
- name: CACHI2_ARTIFACT
355355
value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
356+
- name: ARGS
357+
value: "--project-name=google-marketplace-handler --report --org=d152f68c-67b3-4efa-a5da-207d8219ca59"
356358
runAfter:
357359
- build-image-index
358360
taskRef:

.tekton/google-marketplace-handler-push.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ spec:
350350
value: $(tasks.prefetch-dependencies.results.SOURCE_ARTIFACT)
351351
- name: CACHI2_ARTIFACT
352352
value: $(tasks.prefetch-dependencies.results.CACHI2_ARTIFACT)
353+
- name: ARGS
354+
value: "--project-name=google-marketplace-handler --report --org=d152f68c-67b3-4efa-a5da-207d8219ca59"
353355
runAfter:
354356
- build-image-index
355357
taskRef:

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ All configuration is via environment variables, managed through Pydantic setting
155155
**LLM / Google Cloud:**
156156
- `GOOGLE_API_KEY` or `GOOGLE_CLOUD_PROJECT` + `GOOGLE_GENAI_USE_VERTEXAI=TRUE` (LLM access)
157157
- `GEMINI_MODEL` (model selection, default: `gemini-2.5-flash`)
158+
- Optional Gemini HTTP retries (Google Gen AI SDK exponential backoff + jitter): `GEMINI_HTTP_RETRY_ATTEMPTS`, `GEMINI_HTTP_RETRY_INITIAL_DELAY`, `GEMINI_HTTP_RETRY_MAX_DELAY`, `GEMINI_HTTP_RETRY_EXP_BASE`, `GEMINI_HTTP_RETRY_JITTER` (see `docs/configuration.md`)
158159

159160
**Database:**
160161
- `DATABASE_URL` / `SESSION_DATABASE_URL` (PostgreSQL or SQLite)

Containerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# =============================================================================
55
# Build Stage
66
# =============================================================================
7-
FROM registry.access.redhat.com/ubi9/python-312-minimal:latest as builder
7+
FROM registry.access.redhat.com/ubi10/python-312-minimal:latest as builder
88

99
WORKDIR /opt/app-root/src
1010

@@ -16,7 +16,7 @@ RUN pip install --no-cache-dir --upgrade pip && \
1616
# =============================================================================
1717
# Production Stage
1818
# =============================================================================
19-
FROM registry.access.redhat.com/ubi9/python-312-minimal:latest as production
19+
FROM registry.access.redhat.com/ubi10/python-312-minimal:latest as production
2020

2121
# Labels for container metadata
2222
LABEL org.opencontainers.image.title="Red Hat Lightspeed Agent for Google Cloud"

Containerfile.marketplace-handler

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# =============================================================================
66
# Build Stage
77
# =============================================================================
8-
FROM registry.access.redhat.com/ubi9/python-312-minimal:latest as builder
8+
FROM registry.access.redhat.com/ubi10/python-312-minimal:latest as builder
99

1010
WORKDIR /opt/app-root/src
1111

@@ -17,7 +17,7 @@ RUN pip install --no-cache-dir --upgrade pip && \
1717
# =============================================================================
1818
# Production Stage
1919
# =============================================================================
20-
FROM registry.access.redhat.com/ubi9/python-312-minimal:latest as production
20+
FROM registry.access.redhat.com/ubi10/python-312-minimal:latest as production
2121

2222
# Labels for container metadata
2323
LABEL org.opencontainers.image.title="Marketplace Handler"

EXTERNAL_SERVICES.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# External Services Inventory
2+
3+
A comprehensive list of all external services used by the Google Lightspeed Agent.
4+
5+
## LLM Models
6+
7+
The agent uses Google Gemini models by default, but Vertex AI supports deploying other models as well. Two access paths are supported:
8+
9+
| Access Path | Description | Key Config |
10+
|-------------|-------------|------------|
11+
| **Google AI Studio** (default) | Direct API key access to Gemini | `GOOGLE_API_KEY` |
12+
| **Vertex AI** | Enterprise access via GCP project | `GOOGLE_GENAI_USE_VERTEXAI=true`, `GOOGLE_CLOUD_PROJECT`, `GOOGLE_CLOUD_LOCATION` |
13+
14+
| Setting | Default | Description |
15+
|---------|---------|-------------|
16+
| `GEMINI_MODEL` | `gemini-2.5-flash` | Model used for agent responses |
17+
| `GOOGLE_GENAI_USE_VERTEXAI` | `false` | Switch between AI Studio and Vertex AI |
18+
| `GOOGLE_CLOUD_LOCATION` | `us-central1` | Region for Vertex AI |
19+
20+
The model is configured in `src/lightspeed_agent/config/settings.py` and used via the Google Agent Development Kit (ADK) `LlmAgent` in `src/lightspeed_agent/core/agent.py`.
21+
22+
## Google Cloud Services
23+
24+
| Service | Purpose | Required | Key Config |
25+
|---------|---------|----------|------------|
26+
| **Gemini (AI Studio / Vertex AI)** | LLM for agent responses | Yes | `GOOGLE_API_KEY`, `GOOGLE_GENAI_USE_VERTEXAI`, `GEMINI_MODEL` |
27+
| **Cloud Run** | Production serverless deployment (2 services: agent + handler) | For production | `deploy/cloudrun/` |
28+
| **Cloud Pub/Sub** | Receives marketplace provisioning events asynchronously | For marketplace | Topic: `marketplace-entitlements` |
29+
| **Commerce Procurement API** | Approve/manage marketplace accounts & entitlements | For marketplace | `https://cloudcommerceprocurement.googleapis.com/v1` |
30+
| **Service Control API** | Usage metering & billing reporting to GCP Marketplace | For marketplace | `SERVICE_CONTROL_SERVICE_NAME`, `SERVICE_CONTROL_ENABLED` |
31+
| **Cloud IAM** | Service account management, role bindings, token creation | For deployment | `deploy/cloudrun/setup.sh` |
32+
| **Cloud Build** | Container image builds | For deployment | `deploy/cloudrun/deploy.sh` |
33+
| **Container Registry (gcr.io)** | Container image storage | For deployment | `gcr.io/{PROJECT_ID}/...` |
34+
35+
### Managed GCP Infrastructure
36+
37+
These services are required for production Cloud Run deployments and are configured in `deploy/cloudrun/setup.sh`:
38+
39+
| Service | Purpose | Required | Reference |
40+
|---------|---------|----------|-----------|
41+
| **Cloud SQL** | Managed PostgreSQL for production databases | For production | `setup.sh:322`, IAM role `roles/cloudsql.client` |
42+
| **Secret Manager** | Stores API keys, database URLs, Redis URL, and other secrets | For production | `setup.sh:157-187` |
43+
| **Cloud Scheduler** | Schedules usage reporting jobs | For marketplace | `setup.sh:80` |
44+
| **Cloud Logging** | Centralized log collection | For production | IAM role `roles/logging.logWriter` |
45+
| **Cloud Monitoring** | Metrics and alerting | For production | IAM role `roles/monitoring.metricWriter` |
46+
| **Cloud Memorystore** | Managed Redis instance for rate limiting | For production | `setup.sh:85` |
47+
| **Cloud Storage** | Stores the agent card JSON file for agent publishing | For production | Required for Agent Builder |
48+
| **Serverless VPC Access** | Connects Cloud Run to Cloud Memorystore (Redis) | For production | `setup.sh:85`, `service.yaml:37` |
49+
50+
## Red Hat Services
51+
52+
| Service | Purpose | Required | Key Config |
53+
|---------|---------|----------|------------|
54+
| **Red Hat SSO (Keycloak)** | OAuth 2.0 auth, token introspection, Dynamic Client Registration | Yes | `RED_HAT_SSO_ISSUER` (default: `https://sso.redhat.com/auth/realms/redhat-external`) |
55+
| **console.redhat.com (Lightspeed APIs)** | Advisor, Inventory, Vulnerability, Remediations, Patch, Image Builder, RBAC, RHSM | Yes (via MCP) | `MCP_SERVER_URL`, JWT forwarded via MCP headers (see `mcp_headers.py`) |
56+
| **Red Hat Lightspeed MCP Server** | Sidecar gateway to Lightspeed APIs | Yes | `MCP_SERVER_URL`, `MCP_TRANSPORT_MODE` |
57+
58+
## Databases
59+
60+
| Service | Purpose | Required | Key Config |
61+
|---------|---------|----------|------------|
62+
| **PostgreSQL** | Marketplace data (orders, entitlements, DCR clients) + agent sessions | Yes (production) | `DATABASE_URL`, `SESSION_DATABASE_URL` |
63+
| **SQLite** | Development/testing fallback database | Dev only | Default in `DATABASE_URL` |
64+
65+
## Caching / Rate Limiting
66+
67+
| Service | Purpose | Required | Key Config |
68+
|---------|---------|----------|------------|
69+
| **Redis** | Distributed rate limiting across agent replicas | Yes (production) | `RATE_LIMIT_REDIS_URL` (default: `redis://localhost:6379/0`) |
70+
71+
## Observability (Optional)
72+
73+
| Service | Purpose | Required | Key Config |
74+
|---------|---------|----------|------------|
75+
| **OpenTelemetry Collector** | Distributed tracing export (gRPC or HTTP) | No | `OTEL_ENABLED`, `OTEL_EXPORTER_OTLP_ENDPOINT` |
76+
| **Jaeger** | Trace storage/visualization backend | No | `OTEL_EXPORTER_TYPE=jaeger` |
77+
| **Zipkin** | Trace storage/visualization backend | No | `OTEL_EXPORTER_TYPE=zipkin` |
78+
79+
## Container Registries
80+
81+
| Registry | Image | Purpose |
82+
|----------|-------|---------|
83+
| `registry.access.redhat.com` | `ubi9/python-312-minimal` | Base image for agent & handler |
84+
| `registry.redhat.io` | `rhel9/postgresql-16` | PostgreSQL for Podman deployments |
85+
| `quay.io` | `redhat-services-prod/insights-management-tenant/insights-mcp/red-hat-lightspeed-mcp:latest` | MCP server sidecar (source registry, Podman deployments) |
86+
| `gcr.io` | `{PROJECT_ID}/red-hat-lightspeed-mcp:latest` | MCP server sidecar (uploaded from quay.io for Cloud Run deployments) |
87+
| `quay.io` | `fedora/redis-7` | Redis for rate limiting (production uses Cloud Memorystore) |
88+
89+
## Google JWT Validation Endpoint
90+
91+
| Endpoint | Purpose |
92+
|----------|---------|
93+
| `https://www.googleapis.com/service_accounts/v1/metadata/x509/cloud-agentspace@system.gserviceaccount.com` | Fetches public keys to validate DCR software_statement JWTs. This URL also serves as the expected `iss` (issuer) claim in the JWT for verification (see `google_jwt.py:20-23`) |
94+
95+
## Key Architectural Notes
96+
97+
1. **Two-service architecture**: The agent (port 8000) and marketplace handler (port 8001) are separate services with separate databases for security isolation.
98+
2. **All external connections are configurable** via environment variables defined in `src/lightspeed_agent/config/settings.py`.
99+
3. **Development can run with minimal services**: SQLite replaces PostgreSQL, JWT validation can be skipped, and the MCP server is optional for limited functionality.
100+
4. **Production requires**: Gemini API, Red Hat SSO, PostgreSQL (x2), Redis, MCP server, and the Google Marketplace services (Pub/Sub, Procurement, Service Control) if marketplace integration is enabled.

cloudbuild.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
substitutions:
1616
_SERVICE_NAME: lightspeed-agent
1717
_REGION: us-central1
18+
_VERTEXAI_LOCATION: global
1819
_IMAGE_TAG: latest
1920

2021
options:
@@ -80,7 +81,7 @@ steps:
8081
- '--concurrency'
8182
- '80'
8283
- '--set-env-vars'
83-
- 'GOOGLE_GENAI_USE_VERTEXAI=TRUE,GOOGLE_CLOUD_PROJECT=${PROJECT_ID},GOOGLE_CLOUD_LOCATION=${_REGION},AGENT_HOST=0.0.0.0,AGENT_PORT=8000,LOG_FORMAT=json'
84+
- 'GOOGLE_GENAI_USE_VERTEXAI=TRUE,GOOGLE_CLOUD_PROJECT=${PROJECT_ID},GOOGLE_CLOUD_LOCATION=${_VERTEXAI_LOCATION},AGENT_HOST=0.0.0.0,AGENT_PORT=8000,LOG_FORMAT=json'
8485
- '--set-secrets'
8586
- 'RED_HAT_SSO_CLIENT_ID=redhat-sso-client-id:latest,RED_HAT_SSO_CLIENT_SECRET=redhat-sso-client-secret:latest,DATABASE_URL=database-url:latest,REDIS_URL=redis-url:latest'
8687
- '--service-account'

0 commit comments

Comments
 (0)