@@ -1350,13 +1350,23 @@ async fn detect_cluster_type(&self) -> Result<String, AppError> {
13501350
13511351 let mut pod_infos = Vec :: new ( ) ;
13521352 for pod in pod_list. items {
1353+ // Skip pods that are marked for deletion (Terminating state)
1354+ if pod. metadata . deletion_timestamp . is_some ( ) {
1355+ continue ;
1356+ }
1357+
13531358 if let Some ( name) = & pod. metadata . name {
13541359 let status = if let Some ( pod_status) = & pod. status {
13551360 pod_status. phase . clone ( ) . unwrap_or_else ( || "Unknown" . to_string ( ) )
13561361 } else {
13571362 "Unknown" . to_string ( )
13581363 } ;
13591364
1365+ // Only include pods that are not in Terminating state
1366+ if status == "Terminating" {
1367+ continue ;
1368+ }
1369+
13601370 let ready = if let Some ( pod_status) = & pod. status {
13611371 pod_status. container_statuses
13621372 . as_ref ( )
@@ -1387,6 +1397,65 @@ async fn detect_cluster_type(&self) -> Result<String, AppError> {
13871397
13881398 Ok ( pod_infos)
13891399}
1400+
1401+ /// Get all pods for deployment including terminating ones (for debugging)
1402+ pub async fn get_deployment_pods_all ( & self , deployment_id : & Uuid ) -> Result < Vec < PodInfo > , AppError > {
1403+ use k8s_openapi:: api:: core:: v1:: Pod ;
1404+ use kube:: api:: { Api , ListParams } ;
1405+
1406+ let pods: Api < Pod > = Api :: namespaced ( self . client . clone ( ) , & self . namespace ) ;
1407+ let lp = ListParams :: default ( ) . labels ( & format ! ( "deployment-id={}" , deployment_id) ) ;
1408+
1409+ let pod_list = pods
1410+ . list ( & lp)
1411+ . await
1412+ . map_err ( |e| AppError :: internal ( & format ! ( "Failed to list pods: {}" , e) ) ) ?;
1413+
1414+ let mut pod_infos = Vec :: new ( ) ;
1415+ for pod in pod_list. items {
1416+ if let Some ( name) = & pod. metadata . name {
1417+ let status = if let Some ( pod_status) = & pod. status {
1418+ // Check if pod is marked for deletion
1419+ if pod. metadata . deletion_timestamp . is_some ( ) {
1420+ "Terminating" . to_string ( )
1421+ } else {
1422+ pod_status. phase . clone ( ) . unwrap_or_else ( || "Unknown" . to_string ( ) )
1423+ }
1424+ } else {
1425+ "Unknown" . to_string ( )
1426+ } ;
1427+
1428+ let ready = if let Some ( pod_status) = & pod. status {
1429+ pod_status. container_statuses
1430+ . as_ref ( )
1431+ . map ( |statuses| statuses. iter ( ) . all ( |cs| cs. ready ) )
1432+ . unwrap_or ( false )
1433+ } else {
1434+ false
1435+ } ;
1436+
1437+ pod_infos. push ( PodInfo {
1438+ name : name. clone ( ) ,
1439+ status,
1440+ ready,
1441+ restart_count : if let Some ( pod_status) = & pod. status {
1442+ pod_status. container_statuses
1443+ . as_ref ( )
1444+ . map ( |statuses| statuses. iter ( ) . map ( |cs| cs. restart_count ) . sum ( ) )
1445+ . unwrap_or ( 0 )
1446+ } else {
1447+ 0
1448+ } ,
1449+ node_name : pod. spec . as_ref ( ) . and_then ( |s| s. node_name . clone ( ) ) ,
1450+ created_at : pod. metadata . creation_timestamp
1451+ . map ( |ts| ts. 0 . format ( "%Y-%m-%d %H:%M:%S UTC" ) . to_string ( ) ) ,
1452+ } ) ;
1453+ }
1454+ }
1455+
1456+ Ok ( pod_infos)
1457+ }
1458+
13901459pub async fn get_pod_logs (
13911460 & self ,
13921461 pod_name : & str ,
0 commit comments