Skip to content
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

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

ralphgj
Copy link
Contributor

@ralphgj ralphgj commented Mar 30, 2023

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

@SbloodyS SbloodyS added bug Something isn't working first time contributor First-time contributor 3.1.x for 3.1.x version labels Mar 30, 2023
@SbloodyS SbloodyS added this to the 3.1.5 milestone Mar 30, 2023
@SbloodyS
Copy link
Member

cc @ruanwenjun @caishunfeng

@codecov-commenter
Copy link

codecov-commenter commented Mar 30, 2023

Codecov Report

Merging #13829 (aac9a02) into dev (1e8d09e) will decrease coverage by 0.02%.
The diff coverage is 22.97%.

❗ Current head aac9a02 differs from pull request most recent head 84ba2b3. Consider uploading reports for the commit 84ba2b3 to get more accurate results

@@             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     
Impacted Files Coverage Δ
.../dolphinscheduler/alert/AlertRequestProcessor.java 0.00% <0.00%> (-93.75%) ⬇️
...org/apache/dolphinscheduler/alert/AlertServer.java 0.00% <0.00%> (-45.95%) ⬇️
.../dolphinscheduler/api/aspect/CacheEvictAspect.java 5.12% <0.00%> (ø)
...low/instance/pause/pause/PauseExecuteFunction.java 0.00% <0.00%> (ø)
...or/workflow/instance/stop/StopExecuteFunction.java 0.00% <0.00%> (ø)
.../apache/dolphinscheduler/api/rpc/ApiRpcClient.java 60.00% <0.00%> (ø)
...er/api/service/impl/MetricsCleanUpServiceImpl.java 14.28% <0.00%> (ø)
...uler/api/service/impl/TaskInstanceServiceImpl.java 51.79% <0.00%> (ø)
...hinscheduler/common/constants/TenantConstants.java 0.00% <0.00%> (ø)
...apache/dolphinscheduler/common/utils/LogUtils.java 0.00% <0.00%> (ø)
... and 131 more

... 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)
Copy link
Contributor

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()?

Copy link
Contributor Author

@ralphgj ralphgj Mar 30, 2023

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.

Copy link
Member

@Radeity Radeity left a 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?

@ralphgj
Copy link
Contributor Author

ralphgj commented Mar 30, 2023

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.

@Radeity
Copy link
Member

Radeity commented Mar 30, 2023

Hi, @ralphgj , thanks for your explanation for the use of filter above, i can get you point now, another humble suggestion, maybe use anyMatch(result -> result) is better : )

@ralphgj
Copy link
Contributor Author

ralphgj commented Mar 30, 2023

@Radeity thanks for your suggestion. I have resubmitted it. Could you please review it again?

@Radeity
Copy link
Member

Radeity commented Mar 30, 2023

@Radeity thanks for your suggestion. I have resubmitted it. Could you please review it again?

LGTM 👍

@sonarcloud
Copy link

sonarcloud bot commented Mar 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

75.0% 75.0% Coverage
0.0% 0.0% Duplication

@SbloodyS
Copy link
Member

SbloodyS commented Mar 31, 2023

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.

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.

@Radeity
Copy link
Member

Radeity commented Mar 31, 2023

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 findAny(). @ralphgj , can you update your description to make it clearer?

@SbloodyS
Copy link
Member

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 findAny(). @ralphgj , can you update your description to make it clearer?

Yes. You are right. I didn't look carefully.

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

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

+1

@ralphgj
Copy link
Contributor Author

ralphgj commented Mar 31, 2023

@Radeity Sure, I have updated it.

@SbloodyS SbloodyS merged commit 8f3a23d into apache:dev Mar 31, 2023
@zhuangchong zhuangchong modified the milestones: 3.1.5, 3.1.6 Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.1.x for 3.1.x version backend bug Something isn't working first time contributor First-time contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [Api] Work group have two default work group records
6 participants