Skip to content

[Feature-17167][server] Add tenant association to WorkerGroup #17246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

SargamPuram
Copy link

@SargamPuram SargamPuram commented Jun 8, 2025

⚠️ Draft PR — Groundwork for Issue #17167
Work in Progress

  • add tenant_id column + Foreign Key in t_ds_worker_group
  • Added new DAO methods:
    • queryByIdsAndTenant
    • queryAllWorkerGroupByTenant
  • Updated backend logic to respect tenant boundaries in worker group selection
  • Implemented getUiWorkerGroupPageDetailsByTenant helper method
  • Work in progress: frontend logic and migration scripts

This partially implements tenant-based filtering for worker groups.

Not tested end-to-end yet due to local setup issues; submitting as draft .

This is a draft PR; local testing and frontend integration pending.

Purpose of the pull request

tenant association to WorkerGroup

  1. DB schema

    • ALTER TABLE t_ds_worker_group ADD tenant_id (FK → t_ds_tenant)
  2. Entity

    • WorkerGroup.java: add tenantId, tenantCode
  3. DAO/Mapper

    • New methods queryAllWorkerGroupByTenant, queryByIdsAndTenant
    • XML for those queries
  4. Service

    • queryAllGroup() now filters by loginUser.getTenantId()

Open questions

  • Admin-user visibility scope?
  • Backward compatibility

Closes nothing yet — this is the first draft for feedback.
Looking forward to your reviews!

Brief change log

Verify this pull request

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

- add tenant_id column + FK in t_ds_worker_group
- extend WorkerGroup entity with tenantId/tenantCode
- implement tenant-filtered DAO methods
- update service queryAllGroup() to use tenant filter

This is a draft PR; local testing and frontend integration pending.
Copy link

boring-cyborg bot commented Jun 8, 2025

Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This draft PR lays the groundwork for tenant-based filtering in worker group selection by adding a tenant association in the database and propagating that change through the DAO, entity, and service layers.

  • Added a tenant_id column and corresponding foreign key in the t_ds_worker_group table.
  • Implemented two new DAO methods in WorkerGroupMapper.xml and updated the WorkerGroup entity to include tenantId and tenantCode.
  • Updated service logic in WorkerGroupServiceImpl to filter worker groups based on the tenant of the logged-in user.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql Adds tenant_id column, index, and foreign key to t_ds_worker_group
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkerGroupMapper.xml Introduces new queries for tenant-based filtering
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/WorkerGroupDao.java Adds new DAO method prototypes for tenant filtering
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerGroup.java Updates WorkerGroup entity with tenantId and tenantCode fields
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java Modifies service methods to enforce tenant boundaries on worker groups

Comment on lines 247 to +248
workerGroupPageDetails =
getUiWorkerGroupPageDetails(ids.isEmpty() ? Collections.emptyList() : new ArrayList<>(ids));
getUiWorkerGroupPageDetailsByTenant(ids.isEmpty() ? Collections.emptyList() : new ArrayList<>(ids), tenantId);
Copy link
Preview

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

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

The result of the call to getUiWorkerGroupPageDetailsByTenant is not assigned to a variable in the non-admin branch, which appears to be an oversight. Please assign its result to workerGroupPageDetails to avoid unintended behavior.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant