Skip to content

Conversation

@Donnerbart
Copy link
Contributor

@Donnerbart Donnerbart commented Dec 3, 2025

From my understanding it's not optimal to use the context from the current reconciliation in Expectation.createExpectation(). This will hog on that specific instance, including the (cloned) primary resource instance that is internally stored in DefaultContext. This could have a bad impact on GC, and I think it could even lead to bugs when context.getPrimaryResource() is used in the expectation (since that primary resource might have outdated data).

The Expectation.createExpectation(name, predicate) provides the primary and context, that should be preferred to be used.

Fixed the integration test and references in the documentation and blog post. Also fixed all warnings in the test and re-ordered the methods by their usage in the code. Fixed the time unit for the timeout (from seconds to millis).

Copilot AI review requested due to automatic review settings December 3, 2025 13:41
@openshift-ci openshift-ci bot requested review from csviri and xstefank December 3, 2025 13:41
Copilot finished reviewing on behalf of Donnerbart December 3, 2025 13:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Expectation integration test by fixing an anti-pattern where the reconciliation context was incorrectly captured in the createExpectation() closure. The fix prevents potential memory issues and bugs related to stale primary resource data.

Key changes:

  • Removed context parameter from deploymentReadyExpectation() method to use lambda-provided context instead of captured outer context
  • Fixed spelling error: renamed pathchStatusWithMessage to patchStatusWithMessage
  • Improved code quality: better variable naming (ddeployment), long literal fix (30000l30000L), comment improvements, method reordering

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/expectation/ExpectationReconciler.java Fixed expectation method to use lambda-provided context, corrected spelling, improved variable names and comments, reordered methods
docs/content/en/docs/documentation/reconciler.md Updated documentation to remove context parameter from deploymentReadyExpectation() call
docs/content/en/blog/releases/v5-2-release.md Updated blog post example to remove context parameter from deploymentReadyExpectation() call

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
…a specific context/primary instance

Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
@Donnerbart Donnerbart force-pushed the improvement/improve-expectation-integration-test branch from 9263ca3 to 204d438 Compare December 3, 2025 13:56
Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
@Donnerbart Donnerbart force-pushed the improvement/improve-expectation-integration-test branch from 204d438 to 12284d6 Compare December 3, 2025 14:58
@Donnerbart Donnerbart requested a review from Copilot December 3, 2025 14:58
Copilot finished reviewing on behalf of Donnerbart December 3, 2025 15:01
Copy link
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@csviri
Copy link
Collaborator

csviri commented Dec 3, 2025

From my understanding it's not optimal to use the context from the current reconciliation in Expectation.createExpectation(). This will hog on that specific instance, including the (cloned) primary resource instance that is internally stored in DefaultContext. This could have a bad impact on GC, and I think it could even lead to bugs when context.getPrimaryResource() is used in the expectation (since that primary resource might have outdated data).
The Expectation.createExpectation(name, predicate) provides the primary and context, that should be preferred to be used.

Absolutely, nice catch, thank you!

@csviri csviri merged commit 5d12dc2 into operator-framework:main Dec 3, 2025
31 checks passed
@Donnerbart Donnerbart deleted the improvement/improve-expectation-integration-test branch December 3, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants