Skip to content

Commit

Permalink
Add RestartPolicy::None to kill failed processes
Browse files Browse the repository at this point in the history
  • Loading branch information
pophilpo committed Dec 12, 2023
1 parent 22c908d commit e915a6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/config/retry_delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub struct RetryDelay(f64);

impl RetryDelay {
pub const NONE: RetryDelay = RetryDelay(0.0);
pub const NEVER: RetryDelay = RetryDelay(-1.0);

pub fn from_secs(delay: f64) -> Self {
Self(delay.max(0.0))
Expand Down
7 changes: 2 additions & 5 deletions src/kubectl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ impl Kubectl {
1 => {
// Kill the process if the exit code is 1
out_tx
.send(ChildEvent::Exit(
id,
status,
RestartPolicy::WillRestartIn(RetryDelay::NEVER)
))
.send(ChildEvent::Exit(id, status, RestartPolicy::None))
.ok();
break 'new_process Err(anyhow!("Command returned status code 1"));
}
Expand Down Expand Up @@ -327,6 +323,7 @@ pub enum ChildEvent {
#[derive(Debug)]
pub enum RestartPolicy {
WillRestartIn(RetryDelay),
None,
}

#[derive(Debug, thiserror::Error)]
Expand Down
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,14 @@ fn start_output_loop_thread(out_rx: Receiver<ChildEvent>) -> JoinHandle<()> {
"{id}: Process exited with {} - retrying immediately",
status
);
} else {
eprintln!(
"{id}: Process exited with {} - shutting process down",
status
);
}
}
RestartPolicy::None => {
eprintln!(
"{id}: Process exited with {} - shutting process down",
status
);
}
}
}
ChildEvent::Error(id, error) => {
Expand Down

0 comments on commit e915a6c

Please sign in to comment.