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

Fixes command progress status #24850

Merged
merged 1 commit into from
Mar 12, 2024
Merged

Conversation

avpinchuk
Copy link
Contributor

@avpinchuk avpinchuk commented Mar 10, 2024

Fixes a long-term bug.

This error can affect any progress status that creates a child statuses.

ProgressStatusComplexITest.executeVeryComplexCommand() may fail spuriosly with the next error:

[ERROR] org.glassfish.main.admin.test.progress.ProgressStatusComplexITest.executeVeryComplexCommand -- Time elapsed: 7.687 s <<< FAILURE!
java.lang.AssertionError: 

Expected: <5>
     but: was <6>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at org.glassfish.main.admin.test.progress.ProgressStatusComplexITest.executeVeryComplexCommand(ProgressStatusComplexITest.java:88)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

and wrong progress status:

...
 62%: complex.child2: progress child2, remaining 2
 62%: complex.child2: progress child2, remaining 1
 63%: complex.child2: progress child2, remaining 0
100%: complex.child2: progress child2, remaining 0
All done

The reason is the wrong state event to create progress status parent:

InboundEvent{name='ProgressStatus/state', id='null', data={"progress-status":{"name":"complex","id":"17","total-step-count":20,"current-step-count":0,"complete":false,"children":[{"name":"child1","id":"17.1","allocated-steps":5,"total-step-count":10,"current-step-count":0,"complete":false,"children":[{"name":"child12","id":"17.1.2","allocated-steps":5,"total-step-count":-1,"current-step-count":0,"complete":false},{"name":"child11","id":"17.1.1","allocated-steps":5,"total-step-count":5,"current-step-count":0,"complete":false}]},{"name":"child3","id":"17.3","allocated-steps":6,"total-step-count":112,"current-step-count":0,"complete":false},{"name":"child2","id":"17.2","allocated-steps":5,"total-step-count":50,"current-step-count":0,"complete":false,"children":[{"name":"child21","id":"17.2.1","allocated-steps":10,"total-step-count":25,"current-step-count":0,"complete":false},{"name":"child24","id":"17.2.4","allocated-steps":15,"total-step-count":25,"current-step-count":0,"complete":false},{"name":"child22","id":"17.2.2","allocated-steps":10,"total-step-count":25,"current-step-count":0,"complete":false},{"name":"child23","id":"17.2.3","allocated-steps":10,"total-step-count":25,"current-step-count":0,"complete":false}]}]}}}

As a result, children are created when state event parsed. Then the same children are created with one of the ProgressStatus.createChild() methods. As a consequense, we have more children and the completion percentage is calculated incorrectly.

Whereas a proper state event should look like this:

InboundEvent{name='ProgressStatus/state', id='null', data={"progress-status":{"name":"complex","id":"17","total-step-count":-1,"current-step-count":0,"complete":false}}}

Wrong state event send when event broker setting up:

eventBroker.fireEvent(EVENT_PROGRESSSTATUS_STATE, this);

Due to the asynchronous nature of the event sending by Jersey, multiple children may be added to parent progress status between the state event being queued and the write actually taking place.

As a solution, we pass an empty copy of the parent progress status to send the correct state event.

Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>
@avpinchuk avpinchuk added the bug Something isn't working label Mar 10, 2024
@avpinchuk avpinchuk added this to the 7.0.14 milestone Mar 10, 2024
@avpinchuk avpinchuk self-assigned this Mar 10, 2024
@avpinchuk avpinchuk marked this pull request as ready for review March 10, 2024 22:20
Copy link
Contributor

@dmatej dmatej left a comment

Choose a reason for hiding this comment

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

Good catch!

@hs536 hs536 merged commit 3e5203c into eclipse-ee4j:master Mar 12, 2024
2 checks passed
@avpinchuk avpinchuk deleted the progress-status branch April 16, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants