Skip to content

Commit e8a79d9

Browse files
authored
Use context from existing Vert.x instance during CO startup (#12151)
Signed-off-by: Jakub Scholz <www@scholzj.com>
1 parent 1305b13 commit e8a79d9

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • cluster-operator/src/main/java/io/strimzi/operator/cluster

cluster-operator/src/main/java/io/strimzi/operator/cluster/Main.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.strimzi.operator.common.Util;
2323
import io.strimzi.operator.common.model.PasswordGenerator;
2424
import io.vertx.core.CompositeFuture;
25-
import io.vertx.core.Context;
2625
import io.vertx.core.Future;
2726
import io.vertx.core.Promise;
2827
import io.vertx.core.Vertx;
@@ -83,7 +82,7 @@ public static void main(String[] args) {
8382
KubernetesClient client = new OperatorKubernetesClientBuilder("strimzi-cluster-operator", strimziVersion).build();
8483

8584
startHealthServer(vertx, metricsProvider)
86-
.compose(i -> leaderElection(client, config, shutdownHook))
85+
.compose(i -> leaderElection(vertx, client, config, shutdownHook))
8786
.compose(i -> createPlatformFeaturesAvailability(vertx, client))
8887
.compose(pfa -> deployClusterOperatorVerticles(vertx, client, metricsProvider, pfa, config, shutdownHook))
8988
.onComplete(res -> {
@@ -210,21 +209,21 @@ static CompositeFuture deployClusterOperatorVerticles(Vertx vertx, KubernetesCli
210209
*
211210
* When the leader election is disabled, it just completes the future without waiting for anything.
212211
*
212+
* @param vertx Vert.x instance
213213
* @param client Kubernetes client
214214
* @param config Cluster Operator configuration
215215
* @param shutdownHook Shutdown hook to register leader election shutdown
216216
*/
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) {
218218
Promise<Void> leader = Promise.promise();
219-
Context context = Vertx.currentContext();
220219

221220
if (config.getLeaderElectionConfig() != null) {
222221
LeaderElectionManager leaderElection = new LeaderElectionManager(
223222
client, config.getLeaderElectionConfig(),
224223
() -> {
225224
// New leader => complete the future
226225
LOGGER.info("I'm the new leader");
227-
context.runOnContext(v -> leader.complete());
226+
vertx.runOnContext(v -> leader.complete());
228227
},
229228
isShuttingDown -> {
230229
// Not a leader anymore

0 commit comments

Comments
 (0)