diff --git a/crates/cli/kubectl_pod_cleanup/src/delete_pods.rs b/crates/cli/kubectl_pod_cleanup/src/delete_pods.rs index 95bfcaf736..1f5dd06990 100644 --- a/crates/cli/kubectl_pod_cleanup/src/delete_pods.rs +++ b/crates/cli/kubectl_pod_cleanup/src/delete_pods.rs @@ -1,6 +1,5 @@ use std::process::Command; -use itertools::Itertools; use log::info; use rand::prelude::IteratorRandom; use rand::thread_rng; diff --git a/crates/cli/kubectl_pod_cleanup/src/list_pods.rs b/crates/cli/kubectl_pod_cleanup/src/list_pods.rs index 98ea17169f..acb762caba 100644 --- a/crates/cli/kubectl_pod_cleanup/src/list_pods.rs +++ b/crates/cli/kubectl_pod_cleanup/src/list_pods.rs @@ -18,46 +18,9 @@ pub struct PodInfo { pub age: String, } -//#[derive(Clone, Debug)] -//pub enum PodStatus { -// Running, -// -// Completed, -// ContainerStatusUnknown, -// CrashLoopBackOff, -// Error, -// Evicted, -// /// eg. Init:ContainerStatusUnknown -// InitContainerStatusUnknown, -// /// eg. Init:ErrImagePull -// InitErrImagePull, -// InitError, -// InitImagePullBackoff, -// /// eg. Init:2/3 -// InitPartial, -// NodeAffinity, -// NodeShutdown, -// OOMKilled, -// /// eg. OutOfnvidia.com/gpu -// OutOfGpu, -// Pending, -// PodInitializing, -// Terminated, -// Terminating, -// UnexpectedAdmissionError, -// -// OtherStatus(String), -//} - pub fn list_pods() -> AnyhowResult> { info!("kube-pod-cleanup"); - // Returns, eg. - // NAME READY STATUS RESTARTS AGE - // analytics-job-b8cbf88bd-c5ghc 1/1 Running 0 90d - // storyteller-obs-7d6df4b678-xprsq 1/1 Running 0 90d - // storyteller-web-8566f9bdc5-247d4 0/1 Error 0 6d11h - // storyteller-web-8566f9bdc5-25lw6 0/1 Evicted 0 2d15h let output = Command::new("kubectl") .args(["get", "pods"]) .output()?; @@ -79,12 +42,11 @@ fn parse_pod_status_output(stdout: &str) -> AnyhowResult> { .map(|line| line.trim().to_string()) .collect::>(); - // NB: We skip the first line as that's the header. Ok(lines.iter() .filter_map(|line| { LIST_POD_REGEX.captures(line) }) - .skip(1) + .skip(1) // NB: We skip the first line as that's the header. .map(|captures| { let name = captures.index(1); let ready = captures.index(2); diff --git a/crates/cli/kubectl_pod_cleanup/src/main.rs b/crates/cli/kubectl_pod_cleanup/src/main.rs index 9963f53927..f09f0b5d2a 100644 --- a/crates/cli/kubectl_pod_cleanup/src/main.rs +++ b/crates/cli/kubectl_pod_cleanup/src/main.rs @@ -39,9 +39,10 @@ pub fn main() -> AnyhowResult<()> { "Running", ]; - const POD_STATUSES_TO_ALWAYS_CLEAR : [&str; 11] = [ + const POD_STATUSES_TO_ALWAYS_CLEAR : [&str; 18] = [ "Completed", "ContainerStatusUnknown", // TODO: Maybe don't include? + "CrashLoopBackOff", "ErrImagePull", "Error", "Evicted", @@ -50,11 +51,20 @@ pub fn main() -> AnyhowResult<()> { "Init:Error", "Init:ImagePullBackOff", "Init:OOMKilled", + "NodeAffinity", + "NodeShutdown", "OOMKilled", + "OutOfnvidia.com/gpu", + "Terminated", + "Terminating", + "UnexpectedAdmissionError", ]; - const POD_STATUSES_TO_SOMETIMES_CLEAR : [&str; 2] = [ + const POD_STATUSES_TO_SOMETIMES_CLEAR : [&str; 5] = [ "Init:1/2", + "Init:1/3", + "Init:2/3", + "Pending", "PodInitializing", //"ContainerStatusUnknown", //"Init:ContainerStatusUnknown",