-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[Improvement-17928][API] Add worker group id to environment relation #18349
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
base: dev
Are you sure you want to change the base?
Changes from 3 commits
fe1f40c
e7882b4
357458c
8268646
05ef512
f592c03
31159fb
be2c204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,7 +182,9 @@ private void checkWorkerGroupDependencies(WorkerGroup workerGroup) { | |
| // check if the worker group has any dependent environments | ||
| List<EnvironmentWorkerGroupRelation> environmentWorkerGroupRelations = | ||
| environmentWorkerGroupRelationMapper.selectList(new QueryWrapper<EnvironmentWorkerGroupRelation>() | ||
| .lambda().eq(EnvironmentWorkerGroupRelation::getWorkerGroup, workerGroup.getName())); | ||
| .eq("worker_group_id", workerGroup.getId()) | ||
| .or(queryWrapper -> queryWrapper.isNull("worker_group_id") | ||
| .eq("worker_group", workerGroup.getName()))); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The worker group name shouldn't be deprecated.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 05ef512. The worker group dependency check now checks both worker_group_id and worker_group name, so worker_group is still treated as valid data rather than deprecated fallback only.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed on the current branch: workerGroup remains a non-deprecated compatibility field, and worker group deletion dependency checks match environment relations by worker_group_id or by worker_group name. |
||
|
|
||
| if (CollectionUtils.isNotEmpty(environmentWorkerGroupRelations)) { | ||
| throw new ServiceException(Status.WORKER_GROUP_DEPENDENT_ENVIRONMENT_EXISTS, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,6 +37,11 @@ public class EnvironmentWorkerGroupRelation { | |||||||
| /** | ||||||||
| * worker group id | ||||||||
| */ | ||||||||
| private Integer workerGroupId; | ||||||||
|
|
||||||||
| /** | ||||||||
| * worker group name | ||||||||
| */ | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in f592c03. Removed the extra worker group name comment.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed on the current branch: EnvironmentWorkerGroupRelation keeps workerGroup without a deprecated marker in that area. |
||||||||
| private String workerGroup; | ||||||||
|
|
||||||||
| /** | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1149,7 +1149,8 @@ DROP TABLE IF EXISTS `t_ds_environment_worker_group_relation`; | |
| CREATE TABLE `t_ds_environment_worker_group_relation` ( | ||
| `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'id', | ||
| `environment_code` bigint(20) NOT NULL COMMENT 'environment code', | ||
| `worker_group` varchar(255) NOT NULL COMMENT 'worker group id', | ||
| `worker_group_id` int(11) DEFAULT NULL COMMENT 'worker group id', | ||
| `worker_group` varchar(255) NOT NULL COMMENT 'worker group name', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 05ef512. The base schema now defines worker_group_id as NOT NULL. For upgrades, DDL adds it nullable first, DML backfills it from t_ds_worker_group, and then the column is changed to NOT NULL for MySQL and PostgreSQL. |
||
| `operator` int(11) DEFAULT NULL COMMENT 'operator user id', | ||
| `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, | ||
| `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,4 +16,7 @@ | |
| */ | ||
|
|
||
| ALTER TABLE `t_ds_serial_command` | ||
| MODIFY COLUMN `workflow_definition_code` BIGINT(20) NOT NULL COMMENT 'workflow definition code'; | ||
| MODIFY COLUMN `workflow_definition_code` BIGINT(20) NOT NULL COMMENT 'workflow definition code'; | ||
|
|
||
| ALTER TABLE `t_ds_environment_worker_group_relation` | ||
| ADD COLUMN `worker_group_id` int(11) DEFAULT NULL COMMENT 'worker group id'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should put it into
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 05ef512. I moved the worker_group_id upgrade scripts from 3.4.1_schema to 3.5.0_schema for both MySQL and PostgreSQL. The 3.4.1 upgrade scripts are no longer changed in this PR.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed on the current branch: the MySQL worker_group_id upgrade DDL/DML is under sql/upgrade/3.5.0_schema, and the 3.4.1 MySQL DDL no longer contains this change. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workerGroupDao.queryWorkerGroupByNamereturn list?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 05ef512. EnvironmentServiceImpl now parses the worker groups once and loads them with workerGroupDao.queryWorkerGroupByNames(...). Missing worker groups now throw WORKER_GROUP_NOT_EXIST instead of returning null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed on the current branch: WorkerGroupDao/Mapper returns a list, EnvironmentServiceImpl performs a single queryWorkerGroupByNames batch lookup, maps results by name, and throws WORKER_GROUP_NOT_EXIST when any requested worker group is missing.