Skip to content

Add user quota management system#11

Merged
KerwinTsaiii merged 11 commits intodevelopfrom
feature/user-quota-system
Jan 30, 2026
Merged

Add user quota management system#11
KerwinTsaiii merged 11 commits intodevelopfrom
feature/user-quota-system

Conversation

@MioYuuIH
Copy link
Copy Markdown
Contributor

@MioYuuIH MioYuuIH commented Jan 29, 2026

Summary

Add a complete user quota management system for tracking and controlling resource usage.

Changes

Core Features

  • Quota tracking with per-accelerator rates (GPU/NPU/CPU)
  • Admin UI quota column with inline editing
  • Batch quota operations API
  • Auto-refresh with CronJob support (configurable rules)
  • Pydantic validation for all quota API endpoints

New User Experience

  • Default quota allocation for new users (defaultQuota setting)
  • Option to grant unlimited quota to new users (defaultUnlimited setting)
  • Auto-allocate quota when new users first attempt to start container

Admin UI Enhancements

  • Expandable user details panel (auth_state, state, user_options as JSON)
  • Delete user functionality with confirmation modal
  • Quota inline editing in user table

Documentation

  • Complete quota-system.md with full API reference
  • Updated authentication-guide.md (fix class names)
  • Added missing doc links to main README
  • Removed outdated jupyterhub_config.py sections

Files Changed

Core:

  • runtime/jupyterhub/files/hub/quota_manager.py - quota logic
  • runtime/jupyterhub/files/hub/quota_models.py - Pydantic models
  • runtime/jupyterhub/files/hub/jupyterhub_config.py - API handlers

Admin UI:

  • dockerfiles/Hub/admin-ui/src/pages/UserList.tsx - quota column, user details
  • dockerfiles/Hub/admin-ui/src/api/client.ts - API client

Templates:

  • runtime/jupyterhub/templates/hub/cronjob-quota-refresh.yaml - CronJob
  • dockerfiles/Hub/templates/resource_options_form.html - spawn page

Documentation:

  • docs/jupyterhub/quota-system.md
  • docs/jupyterhub/authentication-guide.md
  • docs/jupyterhub/README.md
  • README.md

Testing

  • Quota set/add/deduct operations
  • Default quota for new users
  • Pydantic validation (invalid action, negative amount, overflow)
  • Batch quota operations
  • User details panel expand/collapse
  • Delete user functionality
  • Ruff format (Python)
  • ESLint (TypeScript)

Checklist

  • Code follows project style guidelines
  • Changes are backward compatible
  • Tested on local Kubernetes cluster
  • Documentation updated

Features:
- Quota tracking with per-accelerator rates (GPU/NPU)
- Admin UI quota column with inline editing
- Batch quota operations API
- Auto-refresh with CronJob support (configurable rules)
- Pydantic validation for all quota API endpoints

Security & Stability:
- Input validation with Pydantic models
- Proper API authentication
- SQL injection prevention
- Rate limiting support

Documentation:
- quota-system.md with full API reference
- Updated user-management.md
@MioYuuIH MioYuuIH marked this pull request as draft January 30, 2026 02:11
Features:
- Add defaultQuota setting to grant initial quota to new users
- Add defaultUnlimited setting to grant unlimited quota to new users
- Auto-allocate quota when new users first attempt to start container
- Record initial grants in transaction log as 'initial_grant' type

Documentation:
- Update quota system docs with new configuration options
- Fix outdated configuration examples (enabled: null)
- Fix transaction field structure in API examples
- Add /api/quota/me response fields (accelerators, enabled)
- Add screenshots for admin quota management UI
- Remove outdated quota status indicator documentation

Implementation:
- Add ensure_user_quota() method in QuotaManager
- Update can_start_container() to support default quota allocation
- Add DEFAULT_QUOTA and DEFAULT_UNLIMITED config loading
- Add logging for new user quota grants
Features:
- Add expandable user details panel showing User and Server info
- Display auth_state, state, user_options as formatted JSON
- Add delete user button with confirmation modal
- Move "Back to Users" button to right side in GroupList

UI improvements:
- JSON fields displayed in formatted <pre> with syntax highlighting
- Expand/collapse toggle (▶/▼) for each user row
- Delete button disabled for admin user
- Split /api/accelerators from /api/quota/me and /api/quota/rates
- Add XSRF token to spawn page API calls (fixes 403 error)
- Update documentation with new API structure
@MioYuuIH MioYuuIH force-pushed the feature/user-quota-system branch from fd30c5c to 863f199 Compare January 30, 2026 08:17
- Add missing doc links to main README (authentication, user-management, quota-system)
- Remove outdated jupyterhub_config.py sections from docs/jupyterhub/README.md
- Fix CustomNativeAuthenticator -> CustomFirstUseAuthenticator in authentication-guide.md
@MioYuuIH MioYuuIH marked this pull request as ready for review January 30, 2026 08:49
@MioYuuIH MioYuuIH requested a review from KerwinTsaiii January 30, 2026 08:49
- Remove adminsUnlimited, unlimitedUsers, defaultUnlimited config options
- Unlimited quota now managed exclusively via Admin UI
- Auto-login mode still disables quota system entirely
- Update documentation and values.yaml
@KerwinTsaiii KerwinTsaiii merged commit 455e3e4 into develop Jan 30, 2026
4 checks passed
@MioYuuIH MioYuuIH deleted the feature/user-quota-system branch February 6, 2026 02:16
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.

2 participants