Skip to content

Commit

Permalink
chore: fix xline handle start_cmd splitting
Browse files Browse the repository at this point in the history
Signed-off-by: iGxnon <[email protected]>
  • Loading branch information
iGxnon committed Oct 23, 2023
1 parent d94d973 commit 3af8b28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions operator-api/src/xline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::process::{Child, Command};
#[async_trait]
pub trait XlineHandle: Debug + Send + Sync + 'static {
/// start a xline node
async fn start(&mut self) -> anyhow::Result<()>; // we truly dont care about what failure happened when start, it just failed
async fn start(&mut self) -> anyhow::Result<()>; // we dont care about what failure happened when start, it just failed

/// kill a xline node
async fn kill(&mut self) -> anyhow::Result<()>;
Expand All @@ -37,11 +37,15 @@ impl LocalXlineHandle {
#[async_trait]
impl XlineHandle for LocalXlineHandle {
async fn start(&mut self) -> anyhow::Result<()> {
if let Some((exe, args)) = self.start_cmd.split_once(' ') {
let proc = Command::new(exe).args(args.split(' ')).spawn()?;
self.child_proc = Some(proc);
}
unreachable!("the start_cmd must be valid");
let mut cmds = self.start_cmd.split_whitespace();
let Some((exe, args)) = cmds
.next()
.map(|exe| (exe, cmds.collect::<Vec<_>>())) else {
unreachable!("the start_cmd must be valid");
};
let proc = Command::new(exe).args(args).spawn()?;
self.child_proc = Some(proc);
Ok(())
}

async fn kill(&mut self) -> anyhow::Result<()> {
Expand Down Expand Up @@ -119,7 +123,7 @@ impl K8sXlineHandle {
#[async_trait]
impl XlineHandle for K8sXlineHandle {
async fn start(&mut self) -> anyhow::Result<()> {
let start_cmd: Vec<&str> = self.start_cmd.split(' ').collect();
let start_cmd: Vec<&str> = self.start_cmd.split_whitespace().collect();
let process = self
.pods_api
.exec(
Expand Down
2 changes: 1 addition & 1 deletion sidecar/src/xline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl XlineHandle {
backup,
health_client,
engine,
client: None, // TODO maybe we could initialize the client here when xline#423 is merged
client: None,
xline_members,
is_healthy_retries: 5,
inner,
Expand Down

0 comments on commit 3af8b28

Please sign in to comment.