Skip to content

feat(storage): add UCloud US3 object storage backend - #6173

Open
chennqqi wants to merge 1 commit into
Tencent:mainfrom
chennqqi:feat/us3-storage-backend
Open

chennqqi wants to merge 1 commit into
Tencent:mainfrom
chennqqi:feat/us3-storage-backend

Conversation

@chennqqi

Copy link
Copy Markdown

What

Adds a us3 storage provider for UCloud US3(UCloud 对象存储).

US3 is S3-protocol compatible and implements signature V4 only — exactly what aws-sdk-go-v2 already sends — so the backend reuses the existing S3 client instead of pulling in another SDK. s3FileService now carries its scheme (s3:// / us3://), so references from the two providers stay distinguishable while sharing one implementation.

Behaviour

  • endpoint is optional: empty → https://s3-<region>.ufileos.com. A bare host gets https://, and a region that is not a documented code is rejected so it cannot smuggle a different host into the derived endpoint. Internal endpoints (http://internal.s3-<region>.ufileos.com) must be set explicitly.
  • Path-style addressing by default — every public region supports path-style HTTPS; US3_VIRTUAL_HOSTED_STYLE=true (tenant JSON: virtual_hosted_style) opts into virtual-hosted style. The UI drawer defaults the path-style switch to on for US3.
  • Presigned download URLs are issued by the same presigner (PresignGetObject, 24 h), i.e. V4 query-string signing.
  • The bucket is created on first use like the other S3-family backends; the connectivity test is read-only.

Wiring

  • internal/application/service/file/us3.go — new backend (CheckUS3Connectivity, ResolveUS3Endpoint)
  • file/s3.go — service carries scheme; newS3ClientWithScheme
  • factory, storageallowlist, types.StorageEngineConfig / instance model / legacy + env projection, redaction + secret preservation, provider validation (endpoint optional), system handler (status item, POST /system/storage-engine-check), container env init, CLI provider list, API client, scheme allow-lists (Go + frontend), storage settings drawer, swagger, docs, .env.example

Env

US3_ENDPOINT=            # optional
US3_REGION=cn-bj
US3_ACCESS_KEY=...
US3_SECRET_KEY=...
US3_BUCKET_NAME=...
US3_PATH_PREFIX=weknora/
US3_VIRTUAL_HOSTED_STYLE=false

Tests

  • go test ./internal/application/service/file/ -run 'US3|S3|StorageClients' — PASS (endpoint resolution, scheme round-trip incl. the storage://<backend>/us3://… wrapper, SSRF rejection)
  • go test ./internal/storageallowlist ./internal/storageurl — PASS
  • internal/types and internal/handler cannot be built on this Windows host (pre-existing cgo-only deps: pg_query, sqlite-vec, duckdb); the new provider path there is covered by knowledge_storage_config_test.go in CI.

No live US3 credentials were available, so the end-to-end upload/presign path is not exercised here; the endpoint/region/signature rules follow the documented US3 behaviour.

🤖 Generated with Claude Code

US3 is UCloud's object storage service. It speaks the S3 protocol with
signature V4 only, which is exactly what aws-sdk-go-v2 already emits, so the
backend reuses the existing S3 client instead of adding another SDK.

- new provider `us3` (scheme `us3://`) registered in the factory, the storage
  allow-list, the tenant storage config, the instance model, the system
  handler (status + connectivity check), the env-driven initialisation and
  the CLI provider list
- endpoint is optional: when empty it is derived from the region as
  https://s3-<region>.ufileos.com; bare hosts get https://, and a region that
  is not a documented code is rejected so it cannot inject a host
- path-style addressing is the default (every public region supports
  path-style HTTPS); `virtual_hosted_style` / `US3_VIRTUAL_HOSTED_STYLE`
  opts into the other form
- s3FileService now carries its scheme, so `s3://` and `us3://` references
  stay distinguishable while sharing one implementation
- credential redaction, secret preservation, provider validation (endpoint
  optional) and reference/URL scheme allow-lists updated
- unit tests for endpoint resolution, scheme handling, SSRF rejection and the
  provider → engine-config mapping; docs and .env.example updated

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant