Skip to content

Commit

Permalink
fix(supportability): skip logs for pending pods
Browse files Browse the repository at this point in the history
Signed-off-by: sinhaashish <[email protected]>
  • Loading branch information
sinhaashish committed Dec 2, 2024
1 parent ed25e5a commit fe4d8ab
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions k8s/supportability/src/collect/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ impl LogCollection {

let mut hostname = None;
if is_host_name_required(service_name.clone()) {
let status = pod.status.clone().ok_or_else(|| {
K8sResourceError::invalid_k8s_resource_value(format!(
"Pod status not found in pod {:?} resource",
pod.metadata.name
))
})?;

let phase = status.phase.as_ref().ok_or_else(|| {
K8sResourceError::invalid_k8s_resource_value(format!(
"Pod phase not found in pod {:?} resource",
pod.metadata.name
))
})?;

if phase == "Pending" {
log(format!(
"Skipping the pod in pending state: {:?}",
pod.metadata.name
));
continue;
}

let node_name = pod
.spec
.clone()
Expand Down

0 comments on commit fe4d8ab

Please sign in to comment.