@@ -3,6 +3,7 @@ import { Box } from '@mui/material';
3
3
import React from 'react' ;
4
4
import { useTranslation } from 'react-i18next' ;
5
5
import { ApiError } from '../../lib/k8s/apiProxy' ;
6
+ import { KubeContainerStatus } from '../../lib/k8s/cluster' ;
6
7
import Pod from '../../lib/k8s/pod' ;
7
8
import { METRIC_REFETCH_INTERVAL_MS , PodMetrics } from '../../lib/k8s/PodMetrics' ;
8
9
import { parseCpu , parseRam , unparseCpu , unparseRam } from '../../lib/units' ;
@@ -30,17 +31,34 @@ export function makePodStatusLabel(pod: Pod) {
30
31
}
31
32
}
32
33
34
+ const containerStatuses = pod . status ?. containerStatuses || [ ] ;
35
+ const containerIndicators = containerStatuses . map ( ( cs , index ) => {
36
+ const { color, tooltip } = getContainerDisplayStatus ( cs ) ;
37
+ return (
38
+ < LightTooltip title = { tooltip } key = { index } >
39
+ < Icon icon = "mdi:circle" style = { { color } } width = "1rem" height = "1rem" />
40
+ </ LightTooltip >
41
+ ) ;
42
+ } ) ;
43
+
33
44
return (
34
- < LightTooltip title = { tooltip } interactive >
35
- < Box display = "inline" >
36
- < StatusLabel status = { status } >
37
- { reason }
38
- { ( status === 'warning' || status === 'error' ) && (
39
- < Icon aria-label = "hidden" icon = "mdi:alert-outline" width = "1.2rem" height = "1.2rem" />
40
- ) }
41
- </ StatusLabel >
42
- </ Box >
43
- </ LightTooltip >
45
+ < Box display = "flex" alignItems = "center" gap = { 1 } >
46
+ < LightTooltip title = { tooltip } interactive >
47
+ < Box display = "inline" >
48
+ < StatusLabel status = { status } >
49
+ { reason }
50
+ { ( status === 'warning' || status === 'error' ) && (
51
+ < Icon aria-label = "hidden" icon = "mdi:alert-outline" width = "1.2rem" height = "1.2rem" />
52
+ ) }
53
+ </ StatusLabel >
54
+ </ Box >
55
+ </ LightTooltip >
56
+ { containerIndicators . length > 0 && (
57
+ < Box display = "flex" gap = { 0.5 } >
58
+ { containerIndicators }
59
+ </ Box >
60
+ ) }
61
+ </ Box >
44
62
) ;
45
63
}
46
64
@@ -60,6 +78,56 @@ function getReadinessGatesStatus(pods: Pod) {
60
78
return readinessGatesMap ;
61
79
}
62
80
81
+ function getContainerDisplayStatus ( container : KubeContainerStatus ) {
82
+ const state = container . state || { } ;
83
+ let color = 'grey' ;
84
+ let label = '' ;
85
+ const tooltipLines : string [ ] = [ `Name: ${ container . name } ` ] ;
86
+
87
+ if ( state . waiting ) {
88
+ color = 'orange' ;
89
+ label = 'Waiting' ;
90
+ if ( state . waiting . reason ) {
91
+ tooltipLines . push ( `Reason: ${ state . waiting . reason } ` ) ;
92
+ }
93
+ } else if ( state . terminated ) {
94
+ color = 'green' ;
95
+ label = 'Terminated' ;
96
+ if ( state . terminated . reason ) {
97
+ tooltipLines . push ( `Reason: ${ state . terminated . reason } ` ) ;
98
+ }
99
+ if ( state . terminated . exitCode !== undefined ) {
100
+ tooltipLines . push ( `Exit Code: ${ state . terminated . exitCode } ` ) ;
101
+ }
102
+ if ( state . terminated . startedAt ) {
103
+ tooltipLines . push ( `Started: ${ new Date ( state . terminated . startedAt ) . toLocaleString ( ) } ` ) ;
104
+ }
105
+ if ( state . terminated . finishedAt ) {
106
+ tooltipLines . push ( `Finished: ${ new Date ( state . terminated . finishedAt ) . toLocaleString ( ) } ` ) ;
107
+ }
108
+ if ( container . restartCount > 0 ) {
109
+ tooltipLines . push ( `Restarts: ${ container . restartCount } ` ) ;
110
+ }
111
+ } else if ( state . running ) {
112
+ color = 'green' ;
113
+ label = 'Running' ;
114
+ if ( state . running . startedAt ) {
115
+ tooltipLines . push ( `Started: ${ new Date ( state . running . startedAt ) . toLocaleString ( ) } ` ) ;
116
+ }
117
+ if ( container . restartCount > 0 ) {
118
+ tooltipLines . push ( `Restarts: ${ container . restartCount } ` ) ;
119
+ }
120
+ }
121
+
122
+ tooltipLines . splice ( 1 , 0 , `Status: ${ label } ` ) ;
123
+
124
+ return {
125
+ color,
126
+ label,
127
+ tooltip : < span style = { { whiteSpace : 'pre-line' } } > { tooltipLines . join ( '\n' ) } </ span > ,
128
+ } ;
129
+ }
130
+
63
131
export interface PodListProps {
64
132
pods : Pod [ ] | null ;
65
133
metrics : PodMetrics [ ] | null ;
0 commit comments