How yaelitrovnik/storagegrid-usage-proxy works
Purpose and entry points
StorageGRID Usage Proxy is a long-running Python HTTP proxy for a closed-network Splunk/HTTP-SNIFFER gateway. It exposes a stable local usage endpoint while managing StorageGRID Tenant API bearer tokens only in process memory.
Primary application entry point: storagegrid_usage_proxy.py. Container/runtime entry points are defined by Dockerfile, compose.yml, and host lifecycle scripts such as scripts/start.sh.
Request-facing proxy boundary
The proxy serves:
• GET /storagegrid/usage for HTTP-SNIFFER, protected by X-StorageGRID-Proxy-Key
• GET /healthz for process liveness
• GET /readyz for token-backed operational readiness
The proxy is the boundary between a locally shared API key and upstream bearer authentication. Production listener exposure and security settings are supplied through compose.yml and config/proxy.env; certificates are mounted from certs/.
Relevant paths: storagegrid_usage_proxy.py, compose.yml, config/proxy.env.
StorageGRID authorization lifecycle
The application authenticates to the StorageGRID Tenant API via POST /api/v4/authorize, validates candidate tokens using GET /api/v4/org/usage, and activates only validated tokens. Tokens remain RAM-resident and are periodically refreshed.
On scheduled refresh failure, the previous working token remains active. If an upstream usage request returns HTTP 401, the proxy reauthorizes and retries once. This isolates HTTP-SNIFFER from token rotation and avoids changing its configuration or restarting it.
Relevant path: storagegrid_usage_proxy.py.
Usage retrieval flow
Control flow is:
HTTP-SNIFFER → authenticated local /storagegrid/usage → proxy token state → StorageGRID /api/v4/org/usage → returned usage JSON → HTTP-SNIFFER/Splunk.
The upstream TLS boundary is configured with TLS_VERIFY and an optional CA bundle. In production, Compose maps the host certificate directory read-only into the container at /app/certs.
Relevant paths: storagegrid_usage_proxy.py, compose.yml, certs/.keep.
Deployment and runtime model
Docker Compose is the recommended production runtime, intended for offline deployment: a versioned image TAR and SHA256 are transferred to the closed-network host, loaded locally, then started with Compose. The container uses restart policy rather than relying on Docker health status to restart an unhealthy-but-running process.
Development and direct-host operations are supported through setup, run, status, and autostart scripts.
Relevant paths: Dockerfile, compose.yml, scripts/setup.sh, scripts/run.sh, scripts/install-autostart.sh.
Release and supply-chain flow
TAG is the release-version source. CI builds versioned and latest images, exports an offline Docker archive, and produces a checksum for controlled transfer. Both GitHub Actions and GitLab CI paths exist, with image packaging scripts shared around the same offline distribution model.
Relevant paths: TAG, .github/workflows/build-offline-image.yml, .github/scripts/export-offline-image.sh, .gitlab-ci.yml, .gitlab-ci-cd/package-docker-offline.sh.
Operational boundaries
Persistent host-side state is intentionally limited to deployment configuration, trusted CA material, logs, and runtime artifacts; bearer tokens are excluded from files and environment mutation at runtime. Environment validation and upstream connectivity checks are explicit operational gates before service use.
Relevant paths: config/proxy.env, scripts/check-config.sh, scripts/test-upstream.sh, logs/.keep, runtime/.keep.
Main entry points: storagegrid_usage_proxy.py Usage Proxy · Dockerfile Offline container image · export-offline-image.sh Image archive and checksum · check-config.sh Operational gates
Components 18
Proxy Runtime
Local authenticated usage boundary and token lifecycle.
- HTTP-SNIFFER / Splunk · Consumes the stable local usage endpoint.
- Usage Proxy · Long-running local proxy with RAM-only bearer token state.
storagegrid_usage_proxy.py - GET /storagegrid/usage · Requires X-StorageGRID-Proxy-Key.
storagegrid_usage_proxy.py - Health and readiness · Provides /healthz and token-backed /readyz.
storagegrid_usage_proxy.py - Token lifecycle · Authorizes, validates, refreshes, and retains the last working token.
storagegrid_usage_proxy.py - Tenant authorize API · POST /api/v4/authorize issues bearer tokens.
storagegrid_usage_proxy.py - Tenant usage API · GET /api/v4/org/usage validates tokens and supplies usage JSON.
storagegrid_usage_proxy.py
Deployment
Offline container and host operation model.
- Docker Compose · Supplies listener exposure, security settings, restart policy, and certificate mount.
compose.yml - Proxy environment · Provides production settings including TLS verification.
config/proxy.env - Trusted certificates · Mounted read-only at /app/certs when needed.
certs/.keep - Offline container image · Loaded on the closed-network host before Compose starts it.
Dockerfile - Host operations · Supports setup, direct run, and autostart installation.
scripts/setup.sh - Operational gates · Validates environment and upstream connectivity before use.
scripts/check-config.sh - Host runtime state · Limited to logs and runtime artifacts; tokens are never persisted.
logs/.keep
Release Pipeline
Versioned offline image production.
- Release TAG · Source version for release images.
TAG - GitHub offline build · Builds images and exports the offline archive.
.github/workflows/build-offline-image.yml - GitLab offline package · Alternative CI path for the same offline distribution model.
.gitlab-ci.yml - Image archive and checksum · Controlled-transfer package for disconnected hosts.
.github/scripts/export-offline-image.sh
Connections 21
- HTTP-SNIFFER / Splunk → GET /storagegrid/usage: GET with proxy key
- GET /storagegrid/usage → Usage Proxy: handled by
- Usage Proxy → Health and readiness: serves
- Usage Proxy → Token lifecycle: uses
- Token lifecycle → Tenant authorize API: authorize / reauthorize
- Token lifecycle → Tenant usage API: validate candidate token
- Usage Proxy → Tenant usage API: fetch usage; retry once on 401
- Tenant usage API → HTTP-SNIFFER / Splunk: usage JSON via proxy
- Proxy environment → Usage Proxy: listener and TLS settings
- Trusted certificates → Docker Compose: read-only mount
- Docker Compose → Offline container image: runs
- Offline container image → Usage Proxy: contains
- Host operations → Usage Proxy: direct-host lifecycle
- Operational gates → Proxy environment: validate
- Operational gates → Tenant usage API: connectivity check
- Usage Proxy → Host runtime state: writes logs/runtime artifacts
- Release TAG → GitHub offline build: versions
- Release TAG → GitLab offline package: versions
- GitHub offline build → Image archive and checksum: produces
- GitLab offline package → Image archive and checksum: packages
- Image archive and checksum → Offline container image: transferred and loaded offline