|
22 | 22 | import io.strimzi.operator.common.Util; |
23 | 23 | import io.strimzi.operator.common.model.PasswordGenerator; |
24 | 24 | import io.vertx.core.CompositeFuture; |
25 | | -import io.vertx.core.Context; |
26 | 25 | import io.vertx.core.Future; |
27 | 26 | import io.vertx.core.Promise; |
28 | 27 | import io.vertx.core.Vertx; |
@@ -83,7 +82,7 @@ public static void main(String[] args) { |
83 | 82 | KubernetesClient client = new OperatorKubernetesClientBuilder("strimzi-cluster-operator", strimziVersion).build(); |
84 | 83 |
|
85 | 84 | startHealthServer(vertx, metricsProvider) |
86 | | - .compose(i -> leaderElection(client, config, shutdownHook)) |
| 85 | + .compose(i -> leaderElection(vertx, client, config, shutdownHook)) |
87 | 86 | .compose(i -> createPlatformFeaturesAvailability(vertx, client)) |
88 | 87 | .compose(pfa -> deployClusterOperatorVerticles(vertx, client, metricsProvider, pfa, config, shutdownHook)) |
89 | 88 | .onComplete(res -> { |
@@ -210,21 +209,21 @@ static CompositeFuture deployClusterOperatorVerticles(Vertx vertx, KubernetesCli |
210 | 209 | * |
211 | 210 | * When the leader election is disabled, it just completes the future without waiting for anything. |
212 | 211 | * |
| 212 | + * @param vertx Vert.x instance |
213 | 213 | * @param client Kubernetes client |
214 | 214 | * @param config Cluster Operator configuration |
215 | 215 | * @param shutdownHook Shutdown hook to register leader election shutdown |
216 | 216 | */ |
217 | | - private static Future<Void> leaderElection(KubernetesClient client, ClusterOperatorConfig config, ShutdownHook shutdownHook) { |
| 217 | + private static Future<Void> leaderElection(Vertx vertx, KubernetesClient client, ClusterOperatorConfig config, ShutdownHook shutdownHook) { |
218 | 218 | Promise<Void> leader = Promise.promise(); |
219 | | - Context context = Vertx.currentContext(); |
220 | 219 |
|
221 | 220 | if (config.getLeaderElectionConfig() != null) { |
222 | 221 | LeaderElectionManager leaderElection = new LeaderElectionManager( |
223 | 222 | client, config.getLeaderElectionConfig(), |
224 | 223 | () -> { |
225 | 224 | // New leader => complete the future |
226 | 225 | LOGGER.info("I'm the new leader"); |
227 | | - context.runOnContext(v -> leader.complete()); |
| 226 | + vertx.runOnContext(v -> leader.complete()); |
228 | 227 | }, |
229 | 228 | isShuttingDown -> { |
230 | 229 | // Not a leader anymore |
|
0 commit comments