Skip to content

Commit eae6280

Browse files
committed
refactor: Run all futures concurrently, exit on error
1 parent 3b64e51 commit eae6280

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

rust/operator-binary/src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crd::{
88
APP_NAME, OPERATOR_NAME, ZookeeperCluster, ZookeeperClusterVersion, ZookeeperZnode,
99
ZookeeperZnodeVersion, v1alpha1,
1010
};
11-
use futures::{StreamExt, pin_mut};
11+
use futures::{FutureExt, StreamExt};
1212
use stackable_operator::{
1313
YamlSchema,
1414
cli::{Command, RunArguments},
@@ -92,7 +92,8 @@ async fn main() -> anyhow::Result<()> {
9292

9393
let eos_checker =
9494
EndOfSupportChecker::new(built_info::BUILT_TIME_UTC, maintenance.end_of_support)?
95-
.run();
95+
.run()
96+
.map(anyhow::Ok);
9697

9798
let product_config = product_config.load(&[
9899
"deploy/config-spec/properties.yaml",
@@ -155,7 +156,8 @@ async fn main() -> anyhow::Result<()> {
155156
.await;
156157
}
157158
},
158-
);
159+
)
160+
.map(anyhow::Ok);
159161

160162
let znode_controller = Controller::new(
161163
watch_namespace.get_api::<DeserializeGuard<v1alpha1::ZookeeperZnode>>(&client),
@@ -218,12 +220,11 @@ async fn main() -> anyhow::Result<()> {
218220
.await;
219221
}
220222
},
221-
);
223+
)
224+
.map(anyhow::Ok);
222225

223-
pin_mut!(zk_controller, znode_controller);
224226
// kube-runtime's Controller will tokio::spawn each reconciliation, so this only concerns the internal watch machinery
225-
let controller_futures = futures::future::select(zk_controller, znode_controller);
226-
tokio::join!(controller_futures, eos_checker);
227+
futures::try_join!(zk_controller, znode_controller, eos_checker)?;
227228
}
228229
}
229230

0 commit comments

Comments
 (0)