Upload Controller Service - manages uploads to an S3 inbox bucket.
1M+
manages uploads to an S3 inbox bucket.
The service ships as the container image ghga/ucs and the Helm chart ucs.
The executable ucs takes one of these commands:
run-rest runs the HTTP REST APIconsume-events runs an event consumer listening to the configured topicspublish-events publishes pending eventscleanup runs the periodic cleanup of stale uploadsThe cleanup command also aborts orphaned multipart uploads and deletes orphaned objects in the inbox bucket, meaning those without a matching FileUpload.
It deletes an orphaned object only once it is older than orphaned_object_min_age_hours.
For a storage alias, it leaves all orphans alone and logs an error if the FileUpload collection is empty, if the objects in the bucket can't be listed, or if the orphaned objects outnumber max_orphaned_objects.
These safeguards stop a deployment that shares the inbox bucket but not the database from deleting everything in the bucket.
After checking that the orphans are real, run ucs cleanup --no-run-forever --ignore-safeguards to remove them once.
Running a service shows how to start, build and deploy it.
The settings take the prefix ucs: the environment variable UCS_HOST sets host, and the YAML file is .ucs.yaml.
example_config.yaml holds a complete set to adapt, and Configuration says where the service looks for them.
The service requires the following configuration parameters:
file_deletion_request_topic (string, required): The name of the topic to receive events informing about files to delete.
Examples:
"file-deletion-requests"
file_deletion_request_type (string, required): The type used for events indicating that a request to delete a file has been received.
Examples:
"file_deletion_requested"
file_internally_registered_topic (string, required): Name of the topic used for events indicating that a file has been registered for download.
Examples:
"file-registrations"
"file-registrations-internal"
file_internally_registered_type (string, required): The type used for event indicating that that a file has been registered for download.
Examples:
"file_internally_registered"
file_interrogations_topic (string, required): The name of the topic use to publish file interrogation outcome events.
Examples:
"file-interrogations"
interrogation_success_type (string, required): The type used for events informing about successful file validations.
Examples:
"interrogation_success"
interrogation_failure_type (string, required): The type used for events informing about failed file validations.
Examples:
"interrogation_failed"
enable_opentelemetry (boolean): If set to true, this will run necessary setup code.If set to false, no setup code is run, which leaves tracing disabled.
Default: false.
otel_trace_sampling_rate (number): Determines which proportion of spans should be sampled.
A value of 1.0 means all and is equivalent to the previous behaviour.
Setting this to 0 will result in no spans being sampled, but this does not automatically set enable_opentelemetry to False.
Minimum: 0.
Maximum: 1.
Default: 1.0.
log_level (string): The minimum log level to capture.
Must be one of: "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", or "TRACE".
Default: "INFO".
service_instance_id (string, required): A string that uniquely identifies this instance across all instances of this service.
A globally unique Kafka client ID will be created by concatenating the service_name and the service_instance_id.
Examples:
"germany-bw-instance-001"
log_format: If set, will replace JSON formatting with the specified string format.
If not set, has no effect.
In addition to the standard attributes, the following can also be specified: timestamp, service, instance, level, correlation_id, and details.
Default: null.
Examples:
"%(timestamp)s - %(service)s - %(level)s - %(message)s"
"%(asctime)s - Severity: %(levelno)s - %(msg)s"
log_traceback (boolean): Whether to include exception tracebacks in log messages.
Default: true.
object_storages (object, required): Can contain additional properties.
kafka_servers (array, required): A list of connection strings to connect to Kafka bootstrap servers.
Examples:
[
"localhost:9092"
]
kafka_security_protocol (string): Protocol used to communicate with brokers.
Valid values are: PLAINTEXT, SSL.
Must be one of: "PLAINTEXT" or "SSL".
Default: "PLAINTEXT".
kafka_ssl_cafile (string): Certificate Authority file path containing certificates used to sign broker certificates.
If a CA is not specified, the default system CA will be used if found by OpenSSL.
Default: "".
kafka_ssl_certfile (string): Optional filename of client certificate, as well as any CA certificates needed to establish the certificate's authenticity.
Default: "".
kafka_ssl_keyfile (string): Optional filename containing the client private key.
Default: "".
kafka_ssl_password (string, format: password, write-only): Optional password to be used for the client private key.
Default: "".
generate_correlation_id (boolean): A flag, which, if False, will result in an error when inbound requests don't possess a correlation ID.
If True, requests without a correlation ID will be assigned a newly generated ID in the correlation ID middleware function.
Default: true.
Examples:
true
false
kafka_max_message_size (integer): The largest message size that can be transmitted, in bytes, before compression.
Only services that have a need to send/receive larger messages should set this.
When used alongside compression, this value can be set to something greater than the broker's message.max.bytes field, which effectively concerns the compressed message size.
Exclusive minimum: 0.
Default: 1048576.
Examples:
1048576
16777216
kafka_compression_type: The compression type used for messages.
Valid values are: None, gzip, snappy, lz4, and zstd.
If None, no compression is applied.
This setting is only relevant for the producer and has no effect on the consumer.
If set to a value, the producer will compress messages before sending them to the Kafka broker.
If unsure, zstd provides a good balance between speed and compression ratio.
Default: null.
Examples:
null
"gzip"
"snappy"
"lz4"
"zstd"
kafka_max_retries (integer): The maximum number of times to immediately retry consuming an event upon failure.
Works independently of the dead letter queue.
Minimum: 0.
Default: 0.
Examples:
0
1
2
3
5
kafka_enable_dlq (boolean): A flag to toggle the dead letter queue.
If set to False, the service will crash upon exhausting retries instead of publishing events to the DLQ.
If set to True, the service will publish events to the DLQ topic after exhausting all retries.
Default: false.
Examples:
true
false
kafka_dlq_topic (string): The name of the topic used to resolve error-causing events.
Default: "dlq".
Examples:
"dlq"
kafka_retry_backoff (integer): The number of seconds to wait before retrying a failed event.
The backoff time is doubled for each retry attempt.
Minimum: 0.
Default: 0.
Examples:
0
1
2
3
5
mongo_dsn (string, format: multi-host-uri, required): MongoDB connection string.
Might include credentials.
For more information see: https://naiveskill.com/mongodb-connection-string/.
Length must be at least 1.
Examples:
"mongodb://localhost:27017"
db_name (string, required): Name of the database located on the MongoDB server.
Examples:
"my-database"
mongo_timeout: Timeout in seconds for API calls to MongoDB.
The timeout applies to all steps needed to complete the operation, including server selection, connection checkout, serialization, and server-side execution.
When the timeout expires, PyMongo raises a timeout exception.
If set to None, the operation will not time out (default MongoDB behavior).
Default: null.
Examples:
300
600
null
db_version_collection (string, required): The name of the collection containing DB version information for this service.
Examples:
"ifrsDbVersions"
migration_wait_sec (integer, required): The number of seconds to wait before checking the DB version again.
Examples:
5
30
180
migration_max_wait_sec: The maximum number of seconds to wait for migrations to complete before raising an error.
Default: null.
Examples:
null
300
600
3600
file_upload_topic (string, required): Topic containing published FileUpload outbox events.
Examples:
"file-uploads"
"file-upload-topic"
file_upload_box_topic (string, required): Topic containing published FileUploadBox outbox events.
Examples:
"file-upload-boxes"
"file-upload-box-topic"
wps_auth_config (required): Refer to #/$defs/AuthConfig.
rs_auth_config (required): Refer to #/$defs/AuthConfig.
port (integer): Port to expose the server on the specified host.
Default: 8080.
auto_reload (boolean): A development feature.
Set to True to automatically reload the server upon code changes.
Default: false.
workers (integer): Number of workers processes to run.
Default: 1.
timeout_keep_alive (integer): The time in seconds to keep an idle connection open for subsequent requests before closing it.
This value should be higher than the timeout used by any client or reverse proxy to avoid premature connection closures.
Default: 90.
Examples:
5
90
5400
api_root_path (string): Root path at which the API is reachable.
This is relative to the specified host and port.
Default: "".
openapi_url (string): Path to get the openapi specification in JSON format.
This is relative to the specified host and port.
Default: "/openapi.json".
docs_url (string): Path to host the swagger documentation.
This is relative to the specified host and port.
Default: "/docs".
cors_allowed_origins: A list of origins that should be permitted to make cross-origin requests.
By default, cross-origin requests are not allowed.
You can use ['*'] to allow any origin.
Default: null.
Examples:
[
"https://example.org",
"https://www.example.org"
]
cors_allow_credentials: Indicate that cookies should be supported for cross-origin requests.
Defaults to False.
Also, cors_allowed_origins cannot be set to ['*'] for credentials to be allowed.
The origins must be explicitly specified.
Default: null.
Examples:
[
"https://example.org",
"https://www.example.org"
]
cors_allowed_methods: A list of HTTP methods that should be allowed for cross-origin requests.
Defaults to ['GET'].
You can use ['*'] to allow all standard methods.
Default: null.
Examples:
[
"*"
]
cors_allowed_headers: A list of HTTP request headers that should be supported for cross-origin requests.
Defaults to [].
You can use ['*'] to allow all request headers.
The Accept, Accept-Language, Content-Language, Content-Type and some are always allowed for CORS requests.
Default: null.
Examples:
[]
cors_exposed_headers: A list of HTTP response headers that should be exposed for cross-origin responses.
Defaults to [].
Note that you can NOT use ['*'] to expose all response headers.
The Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified and Pragma headers are always exposed for CORS responses.
Default: null.
Examples:
[]
max_concurrent_uploads_per_box (integer): Maximum number of in-progress FileUploads allowed per box at any one time.
When a new upload would exceed this count, the request is rejected with 429 Too Many Requests.
Exclusive minimum: 0.
Default: 5.
multipart_upload_ttl_hours (integer): Number of hours after which an in-progress FileUpload with no activity is considered stale and will be aborted by the cleanup job.
Default: 72.
cleanup_interval_minutes (integer): How often (in minutes) the cleanup job runs.
Default: 60.
orphaned_object_min_age_hours (integer): Minimum age in hours before the cleanup job deletes an inbox object that has no matching FileUpload.
Applies even when safeguards are ignored.
Age is measured from the object's LastModified time, which some S3 backends, including AWS, set to when a multipart upload was initiated rather than completed.
Minimum: 0.
Default: 6.
max_orphaned_objects (integer): If the cleanup job finds more orphaned inbox objects than this for one storage alias, it deletes no orphaned objects and aborts no orphaned multipart uploads for that alias, unless run with --ignore-safeguards.
Minimum: 0.
Default: 100.
AuthConfig (object): Config parameters and their defaults for the example auth context.
Cannot contain additional properties.
auth_key (string, required): The GHGA internal public key for validating the token signature.
Examples:
"{\"crv\": \"P-256\", \"kty\": \"EC\", \"x\": \"...\", \"y\": \"...\"}"
auth_algs (array): A list of all algorithms used for signing GHGA internal tokens.
Default: ["ES256"].
auth_check_claims (object): A dict of all GHGA internal claims that shall be verified.
Can contain additional properties.
Default: {"id": null, "name": null, "email": null, "iat": null, "exp": null}.
auth_map_claims (object): A mapping of claims to attributes in the GHGA auth context.
Can contain additional properties.
Default: {}.
S3Config (object): S3-specific config params.
Inherit your config class from this class if you need to talk to an S3 service in the backend.
Cannot contain additional properties.
s3_endpoint_url (string, required): URL to the S3 API.
Examples:
"http://localhost:4566"
s3_access_key_id (string, required): Part of credentials for login into the S3 service.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
Examples:
"my-access-key-id"
s3_secret_access_key (string, format: password, required and write-only): Part of credentials for login into the S3 service.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
Examples:
"my-secret-access-key"
s3_session_token: Part of credentials for login into the S3 service.
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html.
Default: null.
Examples:
"my-session-token"
aws_config_ini: Path to a config file for specifying more advanced S3 parameters.
This should follow the format described here: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-a-configuration-file.
Default: null.
Examples:
"~/.aws/config"
S3ObjectStorageNodeConfig (object): Configuration for one specific object storage node and one bucket in it.
The bucket is the main bucket that the service is responsible for.
Cannot contain additional properties.
bucket (string, required)credentials (required): Refer to #/$defs/S3Config.The service's OpenAPI specification is in openapi.yaml.
This is a Python-based service following the Triple Hexagonal Architecture pattern. It uses protocol/provider pairs and dependency injection mechanisms provided by the hexkit library.
This repository is free to use and modify according to the Apache 2.0 License.
Content type
Image
Digest
sha256:e0d17d2ee…
Size
79.5 MB
Last updated
about 10 hours ago
docker pull ghga/ucs:15.4.0-rc.2Pulls:
412
Oct 26 to Nov 1