dolphinscheduler
dolphinscheduler copied to clipboard
[Feature][API] Associate worker group with tenant
Search before asking
- [x] I had searched in the issues and found no similar feature requirement.
Description
We want to isolate worker resources based on different tenants. Currently in dolphinscheduler, when we create worker group, it is not associated with tenant (no such field in t_ds_worker_group)
Also for frontend, after we associated worker group with tenant, we need to ensure that user can only select worker group in his tenant when he tries to start executing workflows, or setting worker group in tasks
Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
+1, Good suggestion, in most of the cases, there will only one tenant in one worker.
Hi @lancemao @ruanwenjun ,
I'm interested in contributing to this feature. I've analyzed the current worker group implementation and understand the need for tenant-based isolation. I've read the contributing guidelines and plan to use the branch name feature-17167.
Before I begin working and raising a PR, I wanted to ask: Should I wait to be officially assigned this issue, or can I proceed with the implementation?
Current Architecture Analysis
I've reviewed the existing codebase and identified the key components:
Database Layer:
t_ds_worker_grouptable currently has no tenant associationt_ds_tenanttable exists with proper structure (id,tenant_code,queue_id)- Both have standard audit fields (
create_time,update_time)
API Layer:
WorkerGroupControllerprovides CRUD operations without tenant filteringWorkerGroupServicemethods likequeryAllGroup()andqueryAllGroupPaging()return all worker groups regardless of user's tenantWorkerGroupMapperqueries don't include tenant-based filtering
Proposed Technical Implementation
1. Database Schema Changes
-- Add tenant_id column to t_ds_worker_group
ALTER TABLE t_ds_worker_group
ADD COLUMN tenant_id INT(11) DEFAULT NULL COMMENT 'tenant id',
ADD INDEX idx_tenant_id (tenant_id),
ADD CONSTRAINT fk_worker_group_tenant
FOREIGN KEY (tenant_id) REFERENCES t_ds_tenant(id);
2. Entity Model Updates
// Add to WorkerGroup.java
private Integer tenantId;
@TableField(exist = false)
private String tenantCode; // For display purposes
3. Service Layer Changes
- Modify
queryAllGroup()andqueryAllGroupPaging()to filter by user's tenant - Update
saveWorkerGroup()to associate worker group with user's tenant - Add validation to prevent cross-tenant worker group access
4. Mapper/Query Updates
- Add tenant-based filtering to
queryAllWorkerGroup() - Create new method
queryWorkerGroupByTenant(Integer tenantId) - Update existing queries to respect tenant boundaries
5. Frontend Considerations
- Worker group selection dropdowns should only show tenant-specific groups
- Admin interface for worker group management should include tenant association
- Validation to prevent selecting worker groups from different tenants
Questions & Considerations
-
Backward Compatibility: How should we handle existing worker groups without tenant association?
- Option A: Assign them to a default tenant
- Option B: Allow them to be visible to all tenants until manually assigned
-
Admin vs User Access: Should admin users see all worker groups across tenants, or should tenant isolation be absolute?
-
Migration Strategy: Should we provide a migration script to associate existing worker groups with tenants based on usage patterns?
Implementation Approach
I'd like to start with:
- Database schema changes and entity updates
- Service layer modifications with proper tenant filtering
- Unit tests for tenant isolation logic
- Integration tests to ensure no cross-tenant data leakage
This would align with DolphinScheduler's existing patterns while providing the tenant isolation needed for multi-tenant deployments. I'm also working on the gRPC task plugin proposal for OSPP and this would help me better understand the DolphinScheduler architecture.
Technical Background: Java/Spring Boot, database design, Vue.js frontend development GitHub: https://github.com/SargamPuram
Best regards, Sargam