-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[Fix-13828][api] Fix the problem of work groups have two defult records #13829
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #13829 +/- ##
============================================
- Coverage 39.10% 39.08% -0.02%
+ Complexity 4440 4434 -6
============================================
Files 1132 1142 +10
Lines 42163 42014 -149
Branches 4746 4740 -6
============================================
- Hits 16487 16423 -64
+ Misses 23868 23790 -78
+ Partials 1808 1801 -7
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -293,7 +293,9 @@ private List<WorkerGroup> getWorkerGroups(List<Integer> ids) { | |||
workerGroups = workerGroupMapper.queryAllWorkerGroup(); | |||
} | |||
Optional<Boolean> containDefaultWorkerGroups = workerGroups.stream() | |||
.map(workerGroup -> Constants.DEFAULT_WORKER_GROUP.equals(workerGroup.getName())).findAny(); | |||
.map(workerGroup -> Constants.DEFAULT_WORKER_GROUP.equals(workerGroup.getName())) | |||
.filter(result -> result) |
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.
Hi, @ralphgj , could you please explain more about this filter()?
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.
The containDefaultWorkerGroups
method should verify whether it contains the default
work group. The map
method only converts the work group into true/false, which indicates whether it is the default
work group or not. The findAny
method will select the first one. If the first work group converted by map
is not the default
work group, the result of containDefaultWorkerGroups
will be false, but the actual work group retrieved contains the default
work group.
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.
Hi, @ralphgj , my suggestion is to find out why is it possible to create another worker group named default
and fix that bug, rather than directly filter here, WDYT?
@Radeity Currently, the default worker group contains all existing worker servers. However, in some cases, I do not want the default worker group include certain special worker servers. |
Hi, @ralphgj , thanks for your explanation for the use of |
@Radeity thanks for your suggestion. I have resubmitted it. Could you please review it again? |
LGTM 👍 |
Kudos, SonarCloud Quality Gate passed! |
In this case, I think we should do a validation logic to avoid creating worker groups with the same name. Removing duplicates may lead to confusion among different users regarding worker groups with the same name. |
Hi, @SbloodyS , i think this PR has a correct fix, but wrong issue description which may be confused. Actually, we have this validation, user can not create worker groups with the same name, this bug happens because of using |
Yes. You are right. I didn't look carefully. |
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.
+1
@Radeity Sure, I have updated it. |
Purpose of the pull request
close #13828
Brief change log
Fix the problem of work groups have two defult records
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)
If your pull request contain incompatible change, you should also add it to
docs/docs/en/guide/upgrede/incompatible.md