This repository contains a plugin for the XrdHttp server which implements specific behaviors needed by the Pelican platform.
The plugin provides:
- Prestage API for triggering file pulls from remote sources into the cache
- Eviction API for removing files from the cache
- Dynamic CA and certificate file reload without server restart
mkdir build
cd build
cmake ..
makeTo use the plugin, add the following line to your XRootD configuration:
http.exthandler xrdpelican libXrdHttpPelican.so
The plugin supports the following configuration directives:
Controls the logging level for the plugin. Multiple levels can be specified.
Syntax:
pelican.trace <level> [<level> ...]
Levels:
all- Enable all logging levelsdebug- Detailed debugging informationinfo- Informational messageswarning- Warning messageserror- Error messages onlynone- Disable all logging
Example:
pelican.trace info warning error
Configures the idle timeout for prestage worker threads. Workers that are idle for longer than this duration will automatically exit.
Syntax:
pelican.worker_idle <duration>
Duration format: Number followed by a unit (ms, s, m, h)
Default: 1 minute
Example:
pelican.worker_idle 5m
Sets the maximum number of concurrent worker threads per user/VO identity for prestage operations.
Syntax:
pelican.worker_max <count>
Default: 20
Example:
pelican.worker_max 10
Sets the maximum number of queued prestage requests per user/VO identity. If this limit is reached, new prestage requests will be rejected with a 429 (Too Many Requests) response.
Syntax:
pelican.idle_request_max <count>
Default: 20
Example:
pelican.idle_request_max 100
The plugin implements dynamic configuration updates through the Handler::ProcessMessage method, which processes control messages from the parent XRootD process over a Unix domain socket.
The handler supports the following control messages:
-
CA File Update (Message Type 1)
- Receives a file descriptor containing the new CA certificate bundle
- Atomically replaces the existing CA file
- Enables CA rotation without server restart
-
Certificate File Update (Message Type 2)
- Receives a file descriptor containing the new host certificate and key
- Atomically replaces the existing certificate file
- Enables certificate rotation without server restart
-
Signal Relay (Message Type 3)
- Receives a signal number to relay to the process itself
- Used for graceful shutdown and reload operations
-
Cache Self-Test File Update (Message Type 4)
- Receives a file descriptor containing the cache self-test file
- Atomically replaces the existing self-test file
- Used for cache validation and health checks
-
Cache Self-Test File CInfo Update (Message Type 5)
- Receives a file descriptor containing the cache self-test file cinfo metadata
- Atomically replaces the existing cinfo file
- Contains metadata for cache self-test validation
-
Auth File Update (Message Type 6)
- Receives a file descriptor containing the generated authorization file
- Atomically replaces the existing auth file
- Enables dynamic authorization updates without server restart
-
SciTokens File Update (Message Type 7)
- Receives a file descriptor containing the generated SciTokens configuration
- Atomically replaces the existing SciTokens file
- Enables dynamic token configuration updates without server restart
-
Process Re-exec (Message Type 8)
- Triggers a re-execution of the XRootD process
- Preserves the environment and replaces the current process image
- Useful for applying updates that require a full restart without service interruption
- Falls back gracefully if re-exec is not possible
The message handler:
- Uses
recvmsg()withSCM_RIGHTSto receive file descriptors from the parent process - Implements atomic file replacement using temporary files and rename operations
- Runs in a dedicated thread that polls the control socket
- Handles errors gracefully and logs all operations
The plugin provides two HTTP endpoints for cache management when running on a cache server (XRDPFC environment variable is set).
Endpoint: GET /pelican/api/v1.0/prestage?path=<absolute_path>
Triggers a prestage operation to pull a file from the remote origin into the local cache.
Query Parameters:
path(required): URL-encoded absolute path to the file to prestage
Authentication:
- Requires read permission on the requested path
- User identity is determined from the security entity (certificate, token, or username)
- Virtual organization (VO) is included if available
Response:
The response uses chunked transfer encoding to provide progress updates:
- Queued:
status: queued - Active:
status: active,offset=<bytes> - Success:
success: ok - Failure:
failure: <code>(<description>): <details>
Status Codes:
200 OK- Prestage completed successfully400 Bad Request- Invalid request (missing path, non-absolute path, or malformed URL encoding)403 Forbidden- Permission denied404 Not Found- File does not exist409 Conflict- Path is a directory429 Too Many Requests- Queue is full500 Internal Server Error- Prestage operation failed
Example:
curl -X GET "https://cache.example.com/pelican/api/v1.0/prestage?path=%2Fdata%2Ffile.txt"Endpoint: GET /pelican/api/v1.0/evict?path=<absolute_path>
Evicts a file from the cache, freeing up storage space.
Query Parameters:
path(required): URL-encoded absolute path to the file to evict
Authentication:
- Requires delete permission on the requested path
Response:
The response is a simple text response indicating success or failure.
Status Codes:
200 OK- File evicted successfully400 Bad Request- Invalid request403 Forbidden- Permission denied423 Locked- File is currently in use and cannot be evicted500 Internal Server Error- Eviction operation failed
Example:
curl -X GET "https://cache.example.com/pelican/api/v1.0/evict?path=%2Fdata%2Ffile.txt"- Per-User Queueing: Prestage requests are queued per user/VO identity to ensure fair resource allocation
- Worker Pools: Each user/VO gets a dedicated pool of worker threads (up to
pelican.worker_max) - Automatic Cleanup: Worker pools automatically shut down after being idle for
pelican.worker_idleduration - Progress Tracking: Prestage operations report progress every 200ms or when offset changes significantly
- Backpressure: When queues are full, new requests receive a 429 status code
See pelican-api.yaml for the complete OpenAPI 3.0 specification of the prestage and eviction APIs.
To run the tests, build with testing enabled (-DENABLE_TESTS=true) and use ctest:
Run with:
cd build
ctestLicensed under the Apache License, Version 2.0. See LICENSE for details.