Skip to content

[Improvement-18286][ApiServer] Remove the default workerGroup from the frontend and add backend validation for workerGroup#18293

Open
njnu-seafish wants to merge 4 commits into
apache:devfrom
njnu-seafish:Improvement-18286
Open

[Improvement-18286][ApiServer] Remove the default workerGroup from the frontend and add backend validation for workerGroup#18293
njnu-seafish wants to merge 4 commits into
apache:devfrom
njnu-seafish:Improvement-18286

Conversation

@njnu-seafish
Copy link
Copy Markdown
Contributor

Was this PR generated or assisted by AI?

Yes, Modify the frontend code using AI, then test and verify locally.

Purpose of the pull request

close #18286

Brief change log

Remove the default workerGroup from the frontend and add backend validation for workerGroup

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

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

@ruanwenjun ruanwenjun added this to the 3.4.2 milestone May 26, 2026
* @param workerGroups worker group names to validate
* @throws ServiceException if any worker group is not assigned
*/
void validateWorkerGroupsAssignedToProject(Long projectCode, List<String> workerGroups);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

duplicated with WorkerGroupValidator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

duplicated with WorkerGroupValidator

Okay, I will unify the logic.

Comment on lines +395 to +407
private void validateTaskWorkerGroups(long projectCode, List<TaskDefinitionLog> taskDefinitionLogs) {
if (CollectionUtils.isEmpty(taskDefinitionLogs)) {
return;
}

List<String> workerGroups = taskDefinitionLogs.stream()
.map(TaskDefinitionLog::getWorkerGroup)
.filter(StringUtils::isNotEmpty)
.distinct()
.collect(Collectors.toList());

projectWorkerGroupRelationService.validateWorkerGroupsAssignedToProject(projectCode, workerGroups);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This kind of code should put into WorkerGroupValidator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This kind of code should put into WorkerGroupValidator

Okay, I will unify the logic.

@SbloodyS SbloodyS changed the title [Improvement-18286][ApiServer]Remove the default workerGroup from the frontend and add backend validation for workerGroup [Improvement-18286][ApiServer] Remove the default workerGroup from the frontend and add backend validation for workerGroup May 26, 2026
.selectOne(new QueryWrapper<ProjectPreference>().lambda().eq(ProjectPreference::getProjectCode,
projectCode));

// Validate workerGroup is assigned to project
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Validate workerGroup is assigned to project

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

JSONUtils.parseObject(preferences, new TypeReference<Map<String, Object>>() {
});
if (preferenceMap != null) {
Object workerGroupObj = preferenceMap.get("workerGroup");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using entity instead of hard coding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using entity instead of hard coding.

good idea

}
}
} catch (Exception e) {
log.warn("Failed to parse preferences JSON: {}", preferences, e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

throw ServiceException here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

throw ServiceException here.

ok

scheduleObj.setReleaseState(ReleaseState.OFFLINE);
scheduleObj.setWorkflowInstancePriority(workflowInstancePriority);

// Validate workerGroup
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Validate workerGroup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

schedule.setFailureStrategy(failureStrategy);
}

// Validate workerGroup
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Validate workerGroup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok


startParamListValidator.validate(triggerWorkflowDTO.getStartParamList());

// Validate workerGroup using WorkerGroupValidator
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Validate workerGroup using WorkerGroupValidator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines +25 to +42
/**
* Validation context for workerGroup validation
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WorkerGroupValidationContext {

/**
* The workerGroup to validate
*/
private String workerGroup;

/**
* The project code to check against
*/
private long projectCode;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove all unnessnary comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove all unnessnary comment.

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend test UI ui and front end related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][ApiServer] Use real existing workerGroups more accurately instead of defaulting to 'default', to avoid ambiguity.

3 participants