From 8883d8bc2ffafaea7bec8509a802b823d27ab012 Mon Sep 17 00:00:00 2001 From: Alexander Galibey <48586936+galibey@users.noreply.github.com> Date: Wed, 8 Nov 2023 13:29:38 +0400 Subject: [PATCH] fix: check if custom spu exists on start (#3668) --- crates/fluvio-cli/src/lib.rs | 6 +++--- crates/fluvio-cluster/src/start/local.rs | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/fluvio-cli/src/lib.rs b/crates/fluvio-cli/src/lib.rs index ba855298af..15e87fa27b 100644 --- a/crates/fluvio-cli/src/lib.rs +++ b/crates/fluvio-cli/src/lib.rs @@ -315,15 +315,15 @@ mod root { /// Search for a Fluvio plugin in the following places: /// - /// - In the system PATH /// - In the directory where the `fluvio` executable is located + /// - In the system PATH /// - In the `~/.fluvio/extensions/` directory fn find_plugin(name: &str) -> Option { let ext_dir = fluvio_extensions_dir().ok(); let self_exe = std::env::current_exe().ok(); let self_dir = self_exe.as_ref().and_then(|it| it.parent()); - which::which(name) - .or_else(|_| which::which_in(name, self_dir, ".")) + which::which_in(name, self_dir, ".") + .or_else(|_| which::which(name)) .or_else(|_| which::which_in(name, ext_dir, ".")) .ok() } diff --git a/crates/fluvio-cluster/src/start/local.rs b/crates/fluvio-cluster/src/start/local.rs index afd611e4c2..0c5604af3e 100644 --- a/crates/fluvio-cluster/src/start/local.rs +++ b/crates/fluvio-cluster/src/start/local.rs @@ -623,10 +623,18 @@ impl LocalInstaller { let spec = spu_process.spec(); let admin = fluvio.admin().await; let name = format!("custom-spu-{}", spu_process.id()); - admin - .create::(name, false, spec.to_owned().into()) - .await?; - + if admin + .list::(vec![name.clone()]) + .await? + .is_empty() + { + debug!(name, "create custom spu"); + admin + .create::(name, false, spec.to_owned().into()) + .await?; + } else { + debug!(name, "custom spu already exists"); + } spu_process.start().map_err(|err| err.into()) }