CSCS-DWDI Plugin for Waldur Site Agent
This plugin provides integration with the CSCS Data Warehouse Data Intelligence (DWDI) system to report compute, storage, and LLM inference usage data to Waldur. The plugin supports secure OIDC authentication and optional SOCKS proxy connectivity for accessing DWDI API endpoints from restricted networks.
Features
- Multiple Backend Support: Separate backends for compute, storage, and inference usage reporting
- OIDC Authentication: Secure client credentials flow with automatic token refresh
- Proxy Support: SOCKS and HTTP proxy support for network-restricted environments
- Flexible Configuration: Configurable unit conversions and component mappings
- Production Ready: Comprehensive error handling and logging
Overview
The plugin implements three separate backends to handle different types of accounting data:
- Compute Backend (
cscs-dwdi-compute): Reports CPU and node hour usage from HPC clusters - Storage Backend (
cscs-dwdi-storage): Reports storage space and inode usage from filesystems - Inference Backend (
cscs-dwdi-inference): Reports LLM inference cost per resource
Backend Types
Compute Backend
The compute backend queries the DWDI API for computational resource usage and reports:
- Node hours consumed by accounts and users
- CPU hours consumed by accounts and users
- Account-level and user-level usage aggregation
API Endpoints Used:
/api/v1/compute/usage-month/account- Monthly usage data/api/v1/compute/usage-day/account- Daily usage data
Storage Backend
The storage backend queries the DWDI API for storage resource usage and reports:
- Storage space used (converted from bytes to configured units)
- Inode (file count) usage
- Path-based resource identification
API Endpoints Used:
/api/v1/storage/usage-month/filesystem_name/data_type- Monthly storage usage/api/v1/storage/usage-day/filesystem_name/data_type- Daily storage usage
Inference Backend
The inference backend queries the DWDI API for LLM inference cost and reports:
- Inference cost per resource, already priced by the warehouse (a
totalCostvalue) - Cost mapped onto a single
token_costcomponent, keyed by Waldur resource UUID
Unlike the compute and storage backends — which report raw usage that Waldur then prices — the inference backend reports a pre-computed cost: the DWDI warehouse owns the pricing and Waldur records the amount as-is.
API Endpoints Used:
/inference/resource/cost- Monthly inference cost per resource
Configuration
Compute Backend Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Storage Backend Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
Inference Backend Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
The warehouse returns a per-resource totalCost; the backend divides it by the token_cost
component's unit_factor (or unit_factor_reporting) and reports the result. Because the amount is
already priced by DWDI, set the offering plan's token_cost price to 1 so Waldur records the cost
as-is.
Authentication
Both backends use OIDC client credentials flow for authentication with the DWDI API. The authentication tokens are automatically managed with refresh capabilities.
Required Settings
cscs_dwdi_client_id: OIDC client identifiercscs_dwdi_client_secret: OIDC client secretcscs_dwdi_oidc_token_url: OIDC token endpoint URL
Optional Settings
cscs_dwdi_oidc_scope: OIDC scope (defaults to "openid")
Token Management
- Tokens are automatically acquired and cached
- Automatic token refresh before expiration
- Error handling for authentication failures
SOCKS Proxy Support
Both backends support SOCKS proxy for network connectivity. This is useful when the DWDI API is only accessible through a proxy or jump host.
SOCKS Proxy Configuration
Add the SOCKS proxy setting to your backend configuration:
1 2 3 | |
Supported Proxy Types
- SOCKS5:
socks5://hostname:port - SOCKS4:
socks4://hostname:port - HTTP:
http://hostname:port
Usage Examples
SSH Tunnel with SOCKS5:
1 2 3 4 5 6 | |
HTTP Proxy:
1 2 | |
Resource Identification
Compute Resources
For compute resources, the system uses account names as returned by the DWDI API. The Waldur resource
backend_id should match the account name in the cluster accounting system.
Storage Resources
For storage resources, there are two options:
- Direct Path Usage: Set the Waldur resource
backend_idto the actual filesystem path - Path Mapping: Use the
storage_path_mappingsetting to map resource IDs to paths
Usage Reporting
Both backends are read-only and designed for usage reporting. They implement the _get_usage_report() method
but do not support:
- Account creation/deletion
- Resource management
- User management
- Limit setting
Historical Usage Loading
The core waldur_site_load_historical_usage command can be used to bulk-load past usage data
from DWDI into Waldur. This requires implementing get_usage_report_for_period() on the
backend, which queries the same DWDI API endpoints but for a specific historical month instead
of the current one.
Cluster Filtering
For compute backends, the normal reporting flow reads the cluster from each Waldur resource's
offering_backend_id. The historical loader does not pass Waldur resources, so you can
configure a cluster filter in backend_settings:
1 2 | |
When set, all historical compute queries will include cluster=["alps"] in the API request.
If omitted, no cluster filter is applied.
How It Works
The DWDI API already supports date-range queries (from/to parameters on
/compute/usage-month/account and exact-month on /storage/usage-month). The historical
loader calls get_usage_report_for_period(resource_backend_ids, year, month) for each month in
the requested range, then submits the returned usage to Waldur.
Running Historical Loads
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
CLI Flags
| Flag | Description |
|---|---|
--config |
Path to waldur-site-agent configuration file |
--offering-uuid |
UUID of the Waldur offering to load data for |
--user-token |
Waldur API token (staff or service provider) |
--start-date |
Start date in YYYY-MM-DD format |
--end-date |
End date in YYYY-MM-DD format |
--no-staff-check |
Skip staff user validation (use with service provider tokens) |
--skip-user-usage |
Only submit resource-level totals, skip per-user breakdown |
--dry-run |
Log intended submissions without sending anything to Waldur |
--reconcile-stale |
Zero out usage records absent from backend data (see below) |
--resource-backend-id |
Process only the resource with this backend ID; repeatable |
Notes
- The
--no-staff-checkflag is useful when using a service provider token instead of a staff token — the Waldur API enforces permissions server-side regardless - The
--skip-user-usageflag skips themarketplace_offering_users_listAPI call and all per-user usage submission, which can significantly speed up large loads - Resources must already exist in Waldur with valid
backend_idvalues matching DWDI accounts - Maximum date range is 5 years
- Backfilling
usage-billing-type components into past billing periods is only permitted for staff tokens; with a service provider token the Waldur API rejects such submissions with an HTTP 400 mentioning "backfilling past billing periods"
Correcting Misreported Months
If a past month holds wrong values (for example usage misattributed across a month boundary), the loader can rewrite that month from the authoritative backend data. A staff token is required, since usage-based components are being backfilled.
Two flags exist specifically for corrections:
--reconcile-stalealso zeroes records that the backend does not report: resource totals for accounts with no backend data in that month, and per-user usage rows for users missing from the backend report. Without it, phantom values in Waldur survive whenever the backend has nothing to overwrite them with.--dry-runprints every intended submission so the correction can be reviewed before anything is written.
Recommended sequence:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Caveats:
- Rewriting a past-period usage re-triggers marketplace billing for that record, but the invoice item is only updated while the month's invoice is still mutable; otherwise Waldur logs a warning and leaves the invoice untouched. Align with the billing owner on which behaviour is expected before applying corrections.
- Newly created past-month usage records are stored without a plan period, so they do not generate retroactive invoice items — the correction is display/reporting oriented by design.
Example Configurations
See the examples/ directory for complete configuration examples:
cscs-dwdi-compute-config.yaml- Compute backend onlycscs-dwdi-storage-config.yaml- Storage backend onlycscs-dwdi-combined-config.yaml- Both backends in one configuration
Installation
The plugin is automatically discovered when the waldur-site-agent-cscs-dwdi package is installed alongside waldur-site-agent.
UV Workspace Installation
1 2 3 4 5 | |
Manual Installation
1 2 3 4 5 | |
Testing
Running Tests
1 2 3 4 5 6 7 8 | |
Test Coverage
The test suite covers:
- Client initialization and configuration
- OIDC authentication flow
- API endpoint calls (mocked)
- Usage data processing
- Error handling scenarios
- Backend initialization and validation
API Compatibility
This plugin is compatible with DWDI API version 1 (/api/v1/). It requires the following API endpoints to be available:
Compute API:
/api/v1/compute/usage-month/account/api/v1/compute/usage-day/account
Storage API:
/api/v1/storage/usage-month/filesystem_name/data_type/api/v1/storage/usage-day/filesystem_name/data_type
Inference API:
/inference/resource/cost
Troubleshooting
Authentication Issues
Problem: Authentication failures or token errors
Solutions:
- Verify OIDC client credentials are correct
- Check that the token endpoint URL is accessible
- Ensure the client has appropriate scopes for DWDI API access
- Verify network connectivity to the OIDC provider
- Check logs for specific authentication error messages
Testing authentication:
1 2 3 4 | |
Storage Backend Issues
Problem: Storage usage data not found or incorrect
Solutions:
- Verify
storage_filesystemandstorage_data_typematch available values in DWDI - Check
storage_path_mappingif using custom resource IDs - Ensure storage paths exist in the DWDI system
- Validate that the paths have usage data for the requested time period
Connection Issues
Problem: Network connectivity or API access failures
Solutions:
- Use the
ping()method to test API connectivity - Check network connectivity to the DWDI API endpoint
- Verify SSL/TLS configuration and certificates
- If behind a firewall, configure SOCKS proxy (
socks_proxysetting) - Check DNS resolution for the API hostname
Proxy Issues
Problem: SOCKS or HTTP proxy connection failures
Solutions:
- Verify proxy server is running and accessible
- Check proxy authentication if required
- Test proxy connectivity manually:
curl --proxy socks5://localhost:12345 https://dwdi.cscs.ch - Ensure proxy supports the required protocol (SOCKS4/5, HTTP)
- Verify proxy URL format is correct (e.g.,
socks5://hostname:port)
Debugging Tips
Enable debug logging:
1 2 | |
Test API connectivity:
1 2 3 4 5 | |
Development
Project Structure
1 2 3 4 5 6 7 8 9 10 | |
Key Classes
CSCSDWDIComputeBackend: Compute usage reporting backendCSCSDWDIStorageBackend: Storage usage reporting backendCSCSDWDIInferenceBackend: Inference cost reporting backendCSCSDWDIClient: HTTP client for CSCS-DWDI API communication with OIDC authentication
Key Features
- Automatic Token Management: OIDC tokens are cached and refreshed automatically
- Proxy Support: Built-in SOCKS and HTTP proxy support using httpx
- Error Handling: Comprehensive error handling with detailed logging
- Flexible Configuration: Support for custom unit conversions and component mappings
Extension Points
To extend the plugin:
- Additional Endpoints: Modify
CSCSDWDIClientto support more API endpoints - Authentication Methods: Update authentication logic in
client.py - Data Processing: Enhance response processing methods for additional data formats
- Proxy Types: Extend proxy support for additional proxy protocols
Contributing
When contributing to this plugin:
- Follow the existing code style and patterns
- Add tests for new functionality
- Update documentation for new features
- Ensure backward compatibility with existing configurations