Skip to content

feat: implement user-level storage quota#1814

Open
jack-wang-176 wants to merge 1 commit into
Tencent:mainfrom
jack-wang-176:feat/user-storage-quota
Open

feat: implement user-level storage quota#1814
jack-wang-176 wants to merge 1 commit into
Tencent:mainfrom
jack-wang-176:feat/user-storage-quota

Conversation

@jack-wang-176

Copy link
Copy Markdown
Contributor

feat: implement user-level storage quota

Description

This PR introduces a user-level storage quota mechanism within the existing tenant-level quota framework.
It enables Tenant Owners and Admins to assign specific storage limits to individual users, providing granular control over resource consumption. The system now enforces a dual-tier quota check (Tenant-level and User-level) on operations that consume storage, such as document uploads and FAQ indexing.

Key additions:

  • Database & Model: Added storage_quota and storage_used fields to tenant_members table with corresponding migrations.
  • Backend API: Added PUT /api/v1/tenants/:id/members/:user_id/quota endpoint for Admins to adjust user quotas.
  • Service Layer: Updated all storage adjusting/checking points (file upload, chunk processing, deleting, FAQ indexing) to atomically account for both tenant and user storage.
  • Frontend: Added a visual edit flow in the "Tenant Members" table to display used/quota and allow Admins to configure individual limits via a dialog.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

Fixes #1653

Testing

  • Local Database Migration: Verified SQL up/down scripts apply cleanly.
  • UI Editing Flow: Created a new account, granted Admin rights, and modified another member's tenant storage quota via the new UI dialog. Verified the payload via browser network requests and confirmed the successful update in the backend terminal logs.
  • Upload Interception: Temporarily set a user's quota to 10 bytes and verified that attempting to upload a document correctly blocks the operation and surfaces the new USER_STORAGE_QUOTA_EXCEEDED error.
  • Accounting Validation: Uploaded and deleted documents and monitored both tenant-level and user-level storage_used fields to ensure they atomically increment/decrement in sync.

Checklist

  • make fmt && make lint && make test pass locally
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

8311bdbf83fe91feb0b860e3f709c367 43f6e79c0bec4be4e0051d7b59375418 ="816" height="270" alt="656eda3a464427183a3730dd6862089f" src="https://github.com/user-attachments/assets/840a5b59-f63d-473e-944c-a14856bb8b76" /> h="1570" 987e9f090c9dc358efa83dd13a621680 ="1040" height="664" alt="d765aa346a77286e9f72c06dae969a3d" src="https://github.com/user-attachments/assets/b08ed4f5-3039-4210-b998-7abb59283acf" /> height="340" alt="3d971682c72c455ee1368f6526cd6665" src="https://github.com/user-attachments/assets/b3f249bb-2bb0-4360-be78-9a9a515a7514" />

This commit introduces a user-level storage quota mechanism.
It enables Tenant Owners and Admins to assign specific storage limits to individual users, providing granular control over resource consumption.
Copilot AI review requested due to automatic review settings June 25, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

[Feature]: 系统管理员 支持修改用户空间存储配额

2 participants