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

feat: Return failed/successful operations count together with batch operation #18171

Merged
merged 9 commits into from
May 27, 2024

Conversation

kristinkomschow
Copy link
Contributor

Description

Added feature to return the failed and successfully completed count of operations for batch operations to display them in the UI.

Notes for reviewer

I decided to fetch the additional data from the Operation index individually instead of for all currently active operations (as suggested in the issue), since the batch operations are loaded progressively while scrolling.
Performance could probably be improved by requesting information for all the operations that are being loaded in one scroll at once. I'd like to hear opinions on that (and on whether it should be done before we merge the feature or if we can improve that later).

Related issues

closes #https://github.com/camunda/operate/issues/6294

@github-actions github-actions bot added the component/operate Related to the Operate component/team label May 2, 2024
@kristinkomschow kristinkomschow requested a review from a team May 2, 2024 09:46
Copy link
Contributor

github-actions bot commented May 2, 2024

Operate Test Results

778 tests   759 ✅  16m 48s ⏱️
130 suites   15 💤
130 files      0 ❌  4 🔥

For more details on these errors, see this check.

Results for commit c644d45.

♻️ This comment has been updated with latest results.

@@ -313,9 +324,52 @@ public List<OperationDto> getOperationsByBatchOperationId(String batchOperationI
}
}

@Override
public List<BatchOperationDto> enrichBatchEntitiesWithMetadata(
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like it would be better in its own component dedicated to data transformation of this type. OperationReader and the opensearch version are pretty large as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. There are some parts in the code around here that don't quite follow the single responsibility principle, but I shouldn't be adding on top of that.
I'll change this tomorrow. Let me know if there's anything else you notice meanwhile.

Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the data transformation to an own component (DataAggregator), but kept the requests for reading Operations in the OperationReader as I thought that's the most fitting.
I also changed the requests to use ID-batches rather than request every ID individually and instead work more with aggregations.

Copy link
Contributor

github-actions bot commented May 22, 2024

Operate Opensearch ITs Results

182 tests  ±0   182 ✅ ±0   58s ⏱️ -1s
 19 suites ±0     0 💤 ±0 
 19 files   ±0     0 ❌ ±0 

Results for commit 3f88f8d. ± Comparison against base commit 0db4dbc.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented May 22, 2024

Operate Unit Tests Results

299 tests  ±0   298 ✅ ±0   5m 30s ⏱️ -27s
 45 suites ±0     1 💤 ±0 
 45 files   ±0     0 ❌ ±0 

Results for commit 3f88f8d. ± Comparison against base commit 0db4dbc.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented May 22, 2024

Operate Integration Tests Results

523 tests  ±0   521 ✅ ±0   7m 55s ⏱️ +26s
 88 suites ±0     2 💤 ±0 
 88 files   ±0     0 ❌ ±0 

Results for commit 3f88f8d. ± Comparison against base commit 0db4dbc.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented May 22, 2024

Tasklist Test Results

549 tests  ±0   544 ✅ ±0   1h 34m 14s ⏱️ + 2m 35s
143 suites ±0     5 💤 ±0 
143 files   ±0     0 ❌ ±0 

Results for commit ea03334. ± Comparison against base commit 0d2e6d2.

This pull request removes 13 and adds 13 tests. Note that renamed tests count towards both.
io.camunda.tasklist.webapp.api.rest.v1.controllers.external.ProcessExternalControllerTest ‑ startProcessWithEmbeddedForm(HttpStatus, String, ProcessEntity, ProcessInstanceDTO)[1] expectedHttpStatus=200 OK, bpmnProcessId=StartProcessByForm, processEntity=TenantAwareTasklistEntity[id='1', tenantId='<default>'], providedProcessInstanceDTO=io.camunda.tasklist.webapp.graphql.entity.ProcessInstanceDTO@af62fca2
io.camunda.tasklist.webapp.api.rest.v1.controllers.external.ProcessExternalControllerTest ‑ startProcessWithLinkedForm(HttpStatus, String, ProcessEntity, ProcessInstanceDTO)[1] expectedHttpStatus=200 OK, bpmnProcessId=StartProcessByForm, processEntity=TenantAwareTasklistEntity[id='1', tenantId='<default>'], providedProcessInstanceDTO=io.camunda.tasklist.webapp.graphql.entity.ProcessInstanceDTO@409a9f7a
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginAndUsageOfGraphQlApi(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginAndUsageOfRestApi(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginFailedWithNoPermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginFailedWithNoReadPermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginSucceedWithNoWritePermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginSuccess(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLogout(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007d1b5530eb40@24e8652
io.camunda.tasklist.webapp.security.sso.AuthenticationWithPersistentSessionsIT ‑ testLoginFailedWithNoPermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationWithPersistentSessionsIT$$Lambda/0x000078a6f92e1a78@678b6fb7
…
io.camunda.tasklist.webapp.api.rest.v1.controllers.external.ProcessExternalControllerTest ‑ startProcessWithEmbeddedForm(HttpStatus, String, ProcessEntity, ProcessInstanceDTO)[1] expectedHttpStatus=200 OK, bpmnProcessId=StartProcessByForm, processEntity=TenantAwareTasklistEntity[id='1', tenantId='<default>'], providedProcessInstanceDTO=io.camunda.tasklist.webapp.graphql.entity.ProcessInstanceDTO@bfeb49e
io.camunda.tasklist.webapp.api.rest.v1.controllers.external.ProcessExternalControllerTest ‑ startProcessWithLinkedForm(HttpStatus, String, ProcessEntity, ProcessInstanceDTO)[1] expectedHttpStatus=200 OK, bpmnProcessId=StartProcessByForm, processEntity=TenantAwareTasklistEntity[id='1', tenantId='<default>'], providedProcessInstanceDTO=io.camunda.tasklist.webapp.graphql.entity.ProcessInstanceDTO@b461fc87
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginAndUsageOfGraphQlApi(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginAndUsageOfRestApi(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginFailedWithNoPermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginFailedWithNoReadPermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginSucceedWithNoWritePermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLoginSuccess(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationIT ‑ testLogout(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationIT$$Lambda/0x00007afb052f08d0@526d0d09
io.camunda.tasklist.webapp.security.sso.AuthenticationWithPersistentSessionsIT ‑ testLoginFailedWithNoPermissions(BiFunction)[1] orgExtractor=io.camunda.tasklist.webapp.security.sso.AuthenticationWithPersistentSessionsIT$$Lambda/0x00007a0de9312c48@38e75aa5
…

♻️ This comment has been updated with latest results.

@kristinkomschow kristinkomschow force-pushed the operate-6294-batch-ops-count branch 4 times, most recently from b3f16ef to f4ea6b7 Compare May 22, 2024 08:48
Copy link
Contributor

@matt-whiteman matt-whiteman left a comment

Choose a reason for hiding this comment

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

There are integration test failures in two files, please take a look at those. You can run integration tests locally with:

mvn clean install -PoperateItStage1

@kristinkomschow
Copy link
Contributor Author

The operateItStage1 tests passed on my local machine now.
One of the IT test failures was just a missing Bean that needed to be Mocked.
Another one caught two edge cases that were bugged (which I fixed):

  • BatchOperations without any finished/failed operations wouldn't show up
  • The metadata enrichment could mess up the sorting

final List<BatchOperationEntity> batchEntities) {

if (batchEntities.isEmpty()) {
return new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

A few suggestions here (applies to the OpensearchDataAggregator too):

  1. If there's a chance that batchEntities might be null and not just empty, use CollectionUtils.isEmpty() for the check

  2. Return List.of(), which creates an unmutable empty list instance. This makes it consistent with the toList() return value below, which also creates an unmutable list instance.

  3. If you do need to create a new concrete list type, consider if you actually want ArrayList vs LinkedList. The reason for this is, ArrayList actually allocates a block of memory behind the list bigger than the initial list size, and has to allocate a new block/copy elements as the list grows. The benefit to ArrayList (and the reason for this overhead) is if you ever have to index elements directly, it's constant time. If your list usage is only to iterate over the whole list, or add/remove elements from the end, consider a LinkedList. It's a very minor optimization but as we start scaling, it can end up making a difference.


@Conditional(ElasticsearchCondition.class)
@Component
public class ElasticsearchDataAggregator implements DataAggregator {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Would it make sense to make DataAggregator an abstract class instead of an interface and put the common code that checks for null and creates the dtos in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That definitely makes sense and I should have seen that myself to be honest. I changed that.


final Terms batchIdAggregation =
operationReader.getOperationsAggregatedByBatchOperationId(idList, metadataAggregation);
for (final Terms.Bucket bucket : batchIdAggregation.getBuckets()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any chance that batchIdAggregation can be null? Or batchIdAggregation.getBuckets() return null? (Same for OpensearchDataAggregator)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into this and no, this should not happen. When sending requests with aggregations the response should always contain the aggregations. They may be empty (with docCount==0), but shouldn't be null.
Same for the buckets.
I'll leave this as-is for now but will keep it in mind for test cases to verify.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, just wanted to doublecheck as we have had issues with random NPEs in edge cases with customers

@@ -28,6 +28,8 @@ public class BatchOperationDto {
private Integer instancesCount = 0;
private Integer operationsTotalCount = 0;
private Integer operationsFinishedCount = 0;
private Integer failedOperationsCount = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

hashCode() needs to be updated as well with these two new fields

@@ -199,6 +219,16 @@ public boolean equals(Object o) {
: that.operationsFinishedCount != null) {
return false;
}
if (failedOperationsCount != null
Copy link
Contributor

Choose a reason for hiding this comment

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

Intellij had a suggestion to use Object.equals for a lot of the fields in here (not just the new ones) and make the code a bit simpler

package io.camunda.operate.webapp.transform;

/*
* Copyright Camunda Services GmbH
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be the old license header, you might want to check to see if this is supposed to be in here.

@matt-whiteman
Copy link
Contributor

I left a few minor suggestions but approved otherwise. I'm not sure why codeQL is failing a check on a file you didn't change, that particular issue was scanned over a month ago. You may need to rebase from main and re-run all the checks.

@kristinkomschow kristinkomschow force-pushed the operate-6294-batch-ops-count branch 2 times, most recently from d416b6a to 51a2e98 Compare May 23, 2024 12:08
@matt-whiteman
Copy link
Contributor

LGTM, don't forget to rebase from main if you haven't yet to pick up the repository rename changes

@kristinkomschow kristinkomschow force-pushed the operate-6294-batch-ops-count branch 3 times, most recently from 4619361 to 07317cb Compare May 27, 2024 07:36
-added method to get failed/successful operation count to OperationReader
-added fields for operationsFailedCount and operationsCompletedCount to BatchOperationDto
-changed API call to add failed/successful operation count to response

closes camunda/operate/6294
…s count

-added method to get failed/successful operation count to OperationReader

# Conflicts:
#	operate/webapp/src/main/java/io/camunda/operate/webapp/opensearch/reader/OpensearchOperationReader.java
-Moved data transformation/aggregation to new class DataTransformer
-Changed search requests and interfaces to use nested aggregations
rather than multiple ID requests to elasticsearch/opensearch

# Conflicts:
#	operate/webapp/src/main/java/io/camunda/operate/webapp/opensearch/reader/OpensearchOperationReader.java
due to missing DataAggregator Bean
- fixed BatchOperations without finished/failed operations getting ignored
- fixed initial batch operation sorting getting messed up by metadata addition
- moved duplicated code to abstract class
- removed old license header
- adjusted extending classes of DataAggregator
@kristinkomschow kristinkomschow added this pull request to the merge queue May 27, 2024
Merged via the queue into main with commit 791f9a8 May 27, 2024
24 of 25 checks passed
@kristinkomschow kristinkomschow deleted the operate-6294-batch-ops-count branch May 27, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/operate Related to the Operate component/team component/tasklist Related to the Tasklist component/team component/zeebe Related to the Zeebe component/team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants