Skip to content

Commit 9263ca3

Browse files
committed
fix: use context provided by Expectation lamba to prevent hogging on a specific context/primary instance
Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
1 parent 6122e70 commit 9263ca3

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

docs/content/en/blog/releases/v5-2-release.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public class MyReconciler implements Reconciler<MyResource> {
9999

100100
@Override
101101
public UpdateControl<MyResource> reconcile(MyResource primary, Context<MyResource> context) {
102-
103102
// Exit early if expectation is not yet fulfilled or timed out
104103
if (expectationManager.ongoingExpectationPresent(primary, context)) {
105104
return UpdateControl.noUpdate();
@@ -109,7 +108,7 @@ public class MyReconciler implements Reconciler<MyResource> {
109108
if (deployment.isEmpty()) {
110109
createDeployment(primary, context);
111110
expectationManager.setExpectation(
112-
primary, Duration.ofSeconds(30), deploymentReadyExpectation(context));
111+
primary, Duration.ofSeconds(30), deploymentReadyExpectation());
113112
return UpdateControl.noUpdate();
114113
}
115114

docs/content/en/docs/documentation/reconciler.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ public class ExpectationReconciler implements Reconciler<ExpectationCustomResour
286286
@Override
287287
public UpdateControl<ExpectationCustomResource> reconcile(
288288
ExpectationCustomResource primary, Context<ExpectationCustomResource> context) {
289-
290289
// exiting asap if there is an expectation that is not timed out neither fulfilled yet
291290
if (expectationManager.ongoingExpectationPresent(primary, context)) {
292291
return UpdateControl.noUpdate();
@@ -296,7 +295,7 @@ public class ExpectationReconciler implements Reconciler<ExpectationCustomResour
296295
if (deployment.isEmpty()) {
297296
createDeployment(primary, context);
298297
expectationManager.setExpectation(
299-
primary, Duration.ofSeconds(timeout), deploymentReadyExpectation(context));
298+
primary, Duration.ofSeconds(timeout), deploymentReadyExpectation());
300299
return UpdateControl.noUpdate();
301300
} else {
302301
// checks if the expectation if it is fulfilled, and also removes it.
@@ -311,10 +310,6 @@ public class ExpectationReconciler implements Reconciler<ExpectationCustomResour
311310
}
312311
}
313312
return UpdateControl.noUpdate();
314-
315313
}
316314
}
317315
```
318-
319-
320-

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/expectation/ExpectationReconciler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public UpdateControl<ExpectationCustomResource> reconcile(
7474
createDeployment(primary, context);
7575
var set =
7676
expectationManager.checkAndSetExpectation(
77-
primary, context, Duration.ofSeconds(timeout), deploymentReadyExpectation(context));
77+
primary, context, Duration.ofSeconds(timeout), deploymentReadyExpectation());
7878
if (set) {
7979
return UpdateControl.noUpdate();
8080
}
@@ -143,11 +143,10 @@ private static void createDeployment(
143143
context.getClient().resource(deployment).serverSideApply();
144144
}
145145

146-
private static Expectation<ExpectationCustomResource> deploymentReadyExpectation(
147-
Context<ExpectationCustomResource> context) {
146+
private static Expectation<ExpectationCustomResource> deploymentReadyExpectation() {
148147
return Expectation.createExpectation(
149148
DEPLOYMENT_READY_EXPECTATION_NAME,
150-
(p, c) ->
149+
(primary, context) ->
151150
context
152151
.getSecondaryResource(Deployment.class)
153152
.map(

0 commit comments

Comments
 (0)