ergonomics

This commit is contained in:
Brandon Thomas committed 2023-10-10 18:01:06 -04:00
1 parent 68bc9d0bb0
commit 1742827ed9
2 files changed
+15 -7

No files matched your search

@@ -5,8 +5,6 @@ use log::info;
use errors::AnyhowResult;
pub fn delete_pods(pod_names: Vec<String>) -> AnyhowResult<()> {
//let pod_names = pod_names.join(" ");
let mut args = Vec::from(["delete".to_string(), "pods".to_string()]);
args.extend(pod_names);
+15 -5
View File
@@ -1,11 +1,13 @@
use std::ops::Index;
use std::thread;
use std::time::Duration;
use log::info;
use config::shared_constants::DEFAULT_RUST_LOG;
use errors::AnyhowResult;
use crate::delete_pods::delete_pods;
use crate::delete_pods::delete_pods;
use crate::list_pods::list_pods;
pub mod list_pods;
@@ -20,9 +22,12 @@ pub fn main() -> AnyhowResult<()> {
"Running",
];
const POD_STATUSES_TO_CLEAR : [&str; 3] = [
const POD_STATUSES_TO_ALWAYS_CLEAR : [&str; 2] = [
"Error",
"Evicted",
];
const POD_STATUSES_TO_SOMETIMES_CLEAR : [&str; 1] = [
"ContainerStatusUnknown",
];
@@ -30,15 +35,20 @@ pub fn main() -> AnyhowResult<()> {
let pods_to_clear = all_pods.iter()
.filter(|pod| !POD_STATUSES_TO_KEEP.contains(&pod.status.as_str()))
.filter(|pod| POD_STATUSES_TO_CLEAR.contains(&pod.status.as_str()))
.filter(|pod| POD_STATUSES_TO_ALWAYS_CLEAR.contains(&pod.status.as_str()))
.collect::<Vec<_>>();
info!("Clearing {} pods...", pods_to_clear.len());
info!("Clearing {} / {} pods...", pods_to_clear.len(), all_pods.len());
let wait_duration = Duration::from_secs(10);
info!("Clearing in {} seconds... (Last chance to cancel!)", wait_duration.as_secs());
thread::sleep(wait_duration);
let pod_names_to_clear = pods_to_clear.iter()
.map(|pod| pod.name.to_string())
.collect::<Vec<_>>();
//.join(" ");
info!("Clearing pods: {:?}", &pod_names_to_clear);