Skip to content

Commit

Permalink
Rework error code for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Aug 11, 2024
1 parent 26f19e9 commit 599579e
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,19 @@ impl DefaultExecutor {
let ids = ids.split("\n").collect::<Vec<&str>>();


let mut failed = false;
for id in ids {
let failures: Vec<_> = ids.iter().filter_map(|id|{
match self.remove_pod(id, grace_period) {
Ok(_) => {}
Ok(_) => None,
Err(e) => {
eprintln!("{}", e);
failed = true;
Some(e)
}
};
}
}
}).collect();

if failed {
return Err(anyhow!("failures when removing pods for deployment").into());
if !failures.is_empty() {
let mut err = anyhow!("failures when removing pods for deployment");
err = failures.iter().fold(err, |a, b| a.context(b.to_string()));
return Err(err.into());
}
Ok(())
}
Expand All @@ -322,19 +322,19 @@ impl DefaultExecutor {
let ids = ids.split("\n").collect::<Vec<&str>>();


let mut failed = false;
for id in ids {
let failures: Vec<_> = ids.iter().filter_map(|id|{
match self.remove_pod(id, grace_period) {
Ok(_) => {}
Ok(_) => None,
Err(e) => {
eprintln!("{}", e);
failed = true;
Some(e)
}
};
}
}
}).collect();

if failed {
return Err(anyhow!("failures when removing pods for daemonset").into());
if !failures.is_empty() {
let mut err = anyhow!("failures when removing pods for daemonset");
err = failures.iter().fold(err, |a, b| a.context(b.to_string()));
return Err(err.into());
}
Ok(())
}
Expand Down

0 comments on commit 599579e

Please sign in to comment.