Skip to content

Commit c51fa82

Browse files
committed
Refactoring + fixing more bugs
Signed-off-by: Kyle Liberti <kliberti@redhat.com>
1 parent f5bb766 commit c51fa82

File tree

11 files changed

+241
-366
lines changed

11 files changed

+241
-366
lines changed

cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaRebalanceAssemblyOperator.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,19 @@ private static Future<MapAndStatus<ConfigMap, KafkaRebalanceStatus>> updateProgr
343343

344344
if (existingConfigMap == null && desiredConfigMap == null) {
345345
return Future.succeededFuture(desiredStatusAndMap);
346-
} else if (existingConfigMap != null && desiredStatusAndMap.getLoadMap() != null) {
347-
// Ensure desiredConfigMap retains broker load information if it exists.
348-
desiredConfigMap.getData().put(BROKER_LOAD_KEY, existingConfigMap.getData().get(BROKER_LOAD_KEY));
349-
} else if (desiredConfigMap == null) {
350-
desiredStatusAndMap.setLoadMap(existingConfigMap);
351-
desiredConfigMap = existingConfigMap;
352346
}
353347

354-
// Add progress information to KafkaRebalance resource status and ConfigMap.
348+
if (existingConfigMap != null) {
349+
if (desiredConfigMap == null) {
350+
desiredStatusAndMap.setLoadMap(existingConfigMap);
351+
desiredConfigMap = existingConfigMap;
352+
} else {
353+
// Ensure desiredConfigMap retains broker load information if it exists.
354+
desiredConfigMap.getData().put(BROKER_LOAD_KEY, existingConfigMap.getData().get(BROKER_LOAD_KEY));
355+
}
356+
}
357+
358+
// Add progress information to `KafkaRebalance` resource status and ConfigMap.
355359
desiredStatus.setProgress(Map.of(REBALANCE_PROGRESS_CONFIG_MAP_KEY, configMapName));
356360
KafkaRebalanceConfigMapUtils.updateRebalanceConfigMap(reconciliation, desiredState, host, cruiseControlPort, apiClient, desiredConfigMap)
357361
.onFailure(exception -> {

cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/KafkaRebalanceAssemblyOperatorProgressTest.java

Lines changed: 105 additions & 96 deletions
Large diffs are not rendered by default.

cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/KafkaRebalanceAssemblyOperatorTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public void testNewToPendingProposalToProposalReadyRemoveDisks(VertxTestContext
254254
private void krNewToPendingProposalToProposalReady(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
255255
// Set up the rebalance endpoint with the number of pending calls before a response is received.
256256
cruiseControlServer.setupCCRebalanceResponse(1, endpoint, verbose);
257-
cruiseControlServer.setupCCUserTasksResponseNoGoals(1, 0);
257+
cruiseControlServer.setupCCUserTasksResponseNoGoals(1, 0, false);
258258

259259
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
260260
crdCreateKafka();
@@ -416,7 +416,7 @@ public void testNewToPendingProposalToStoppedAndRefreshRemoveDisks(VertxTestCont
416416
private void krNewToPendingProposalToStoppedAndRefresh(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
417417
// Set up the rebalance endpoint with the number of pending calls before a response is received.
418418
cruiseControlServer.setupCCRebalanceResponse(2, endpoint, verbose);
419-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
419+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
420420

421421
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
422422
crdCreateKafka();
@@ -560,7 +560,7 @@ public void testAutoApprovalNewToReadyRemoveDisks(VertxTestContext context) thro
560560
private void krNewToProposalReadyToRebalancingToReady(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
561561
// Set up the rebalance and user tasks endpoints with the number of pending calls before a response is received.
562562
cruiseControlServer.setupCCRebalanceResponse(0, endpoint, verbose);
563-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
563+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
564564

565565
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
566566
crdCreateKafka();
@@ -643,7 +643,7 @@ public void testNewToProposalReadyToReconciliationPausedRemoveDisks(VertxTestCon
643643
private void krNewToProposalReadyToReconciliationPaused(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
644644
// Set up the rebalance and user tasks endpoints with the number of pending calls before a response is received.
645645
cruiseControlServer.setupCCRebalanceResponse(0, endpoint, verbose);
646-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
646+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
647647

648648
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
649649
crdCreateKafka();
@@ -731,7 +731,7 @@ public void testNewToProposalReadyToRebalancingToReadyThenRefreshRemoveDisks(Ver
731731
private void krNewToProposalReadyToRebalancingToReadyThenRefresh(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
732732
// Set up the rebalance and user tasks endpoints with the number of pending calls before a response is received.
733733
cruiseControlServer.setupCCRebalanceResponse(0, endpoint, verbose);
734-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
734+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
735735

736736
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
737737
crdCreateKafka();
@@ -802,7 +802,7 @@ public void krNewToProposalReadyToRebalancingToRefresh(VertxTestContext context)
802802

803803
// Set up the rebalance and user tasks endpoints with the number of pending calls before a response is received.
804804
cruiseControlServer.setupCCRebalanceResponse(0, CruiseControlEndpoints.REMOVE_BROKER, "true");
805-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
805+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
806806
cruiseControlServer.setupCCStopResponse();
807807

808808
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
@@ -1133,7 +1133,7 @@ public void testNewToPendingProposalDeleteRemoveDisks(VertxTestContext context)
11331133
private void krNewToPendingProposalDelete(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
11341134
// Set up the rebalance endpoint with the number of pending calls before a response is received.
11351135
cruiseControlServer.setupCCRebalanceResponse(1, endpoint, verbose);
1136-
cruiseControlServer.setupCCUserTasksResponseNoGoals(1, 0);
1136+
cruiseControlServer.setupCCUserTasksResponseNoGoals(1, 0, false);
11371137

11381138
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();
11391139
crdCreateKafka();
@@ -1328,7 +1328,7 @@ public void testNewToProposalReadyToRebalancingToStoppedRemoveDisks(VertxTestCon
13281328
private void krNewToProposalReadyToRebalancingToStopped(VertxTestContext context, CruiseControlEndpoints endpoint, KafkaRebalance kr, String verbose) throws IOException, URISyntaxException {
13291329
// Set up the rebalance and user tasks endpoints with the number of pending calls before a response is received.
13301330
cruiseControlServer.setupCCRebalanceResponse(0, endpoint, verbose);
1331-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 2);
1331+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 2, false);
13321332
cruiseControlServer.setupCCStopResponse();
13331333

13341334
Crds.kafkaRebalanceOperation(client).inNamespace(namespace).resource(kr).create();

cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/KafkaRebalanceStateMachineTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ public void testRebalancingCompletedRemoveDisks(Vertx vertx, VertxTestContext co
11351135
}
11361136

11371137
private void krRebalancingCompleted(Vertx vertx, VertxTestContext context, KafkaRebalance kcRebalance) throws IOException, URISyntaxException {
1138-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
1138+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
11391139

11401140
checkTransition(vertx, context,
11411141
KafkaRebalanceState.Rebalancing, KafkaRebalanceState.Ready,
@@ -1188,7 +1188,7 @@ private void krRebalancingPendingThenExecution(Vertx vertx, VertxTestContext con
11881188
// This tests that the optimization proposal is added correctly if it was not ready when the rebalance(dryrun=false) was called.
11891189
// The first poll should see active and then the second should see in execution and add the optimization and cancel the timer
11901190
// so that the status is updated.
1191-
cruiseControlServer.setupCCUserTasksResponseNoGoals(activeCalls, inExecutionCalls);
1191+
cruiseControlServer.setupCCUserTasksResponseNoGoals(activeCalls, inExecutionCalls, false);
11921192

11931193
checkTransition(vertx, context,
11941194
KafkaRebalanceState.Rebalancing, KafkaRebalanceState.Rebalancing,
@@ -1240,7 +1240,7 @@ public void testRebalancingToStoppedRemoveDisks(Vertx vertx, VertxTestContext co
12401240
}
12411241

12421242
private void krRebalancingToStopped(Vertx vertx, VertxTestContext context, KafkaRebalance kcRebalance) throws IOException, URISyntaxException {
1243-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
1243+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
12441244
cruiseControlServer.setupCCStopResponse();
12451245

12461246
checkTransition(vertx, context,

cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/resource/cruisecontrol/CruiseControlClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testCCRebalanceProposalNotReady() throws IOException, URISyntaxExcep
122122
@Test
123123
public void testCCGetRebalanceUserTask() throws IOException, URISyntaxException {
124124

125-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0);
125+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, 0, false);
126126

127127
CruiseControlApi client = cruiseControlClientProvider();
128128
String userTaskID = MockCruiseControl.REBALANCE_NO_GOALS_RESPONSE_UTID;
@@ -495,7 +495,7 @@ public void testMockCCServerPendingCallsOverride() throws IOException, URISyntax
495495
int pendingCalls1 = 2;
496496
int pendingCalls2 = 4;
497497

498-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, pendingCalls1);
498+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, pendingCalls1, false);
499499

500500
CompletableFuture<CruiseControlUserTasksResponse> statusFuture = client.getUserTaskStatus(Reconciliation.DUMMY_RECONCILIATION, HOST, cruiseControlPort, userTaskID);
501501

@@ -518,7 +518,7 @@ public void testMockCCServerPendingCallsOverride() throws IOException, URISyntax
518518
statusFuture = statusFuture.thenCompose(response -> {
519519
try {
520520
cruiseControlServer.reset();
521-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, pendingCalls2);
521+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, pendingCalls2, false);
522522
} catch (IOException | URISyntaxException e) {
523523
return CompletableFuture.failedFuture(e);
524524
}
@@ -545,7 +545,7 @@ public void testMockCCServerPendingCallsOverride() throws IOException, URISyntax
545545
}
546546

547547
private void runTest(String userTaskID, int pendingCalls) throws IOException, URISyntaxException {
548-
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, pendingCalls);
548+
cruiseControlServer.setupCCUserTasksResponseNoGoals(0, pendingCalls, false);
549549

550550
CruiseControlApi client = cruiseControlClientProvider();
551551

0 commit comments

Comments
 (0)