@@ -573,7 +573,8 @@ func TestPodStore(t *testing.T) {
573
573
StartedAt : metav1.Time {
574
574
Time : time .Unix (1501777018 , 0 ),
575
575
},
576
- Reason : "OOMKilled" ,
576
+ Reason : "OOMKilled" ,
577
+ ExitCode : 137 ,
577
578
},
578
579
},
579
580
},
@@ -648,12 +649,14 @@ func TestPodStore(t *testing.T) {
648
649
},
649
650
},
650
651
Want : `
652
+ # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state.
651
653
# HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state.
652
654
# HELP kube_pod_container_status_running Describes whether the container is currently in running state.
653
655
# HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
654
656
# HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
655
657
# HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
656
658
# HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state.
659
+ # TYPE kube_pod_container_status_last_terminated_exitcode gauge
657
660
# TYPE kube_pod_container_status_last_terminated_reason gauge
658
661
# TYPE kube_pod_container_status_running gauge
659
662
# TYPE kube_pod_container_status_terminated gauge
@@ -678,6 +681,10 @@ func TestPodStore(t *testing.T) {
678
681
"kube_pod_container_status_last_terminated_reason" ,
679
682
"kube_pod_container_status_last_terminated_reason" ,
680
683
"kube_pod_container_status_last_terminated_reason" ,
684
+ "kube_pod_container_status_last_terminated_exitcode" ,
685
+ "kube_pod_container_status_last_terminated_exitcode" ,
686
+ "kube_pod_container_status_last_terminated_exitcode" ,
687
+ "kube_pod_container_status_last_terminated_exitcode" ,
681
688
},
682
689
},
683
690
{
@@ -709,7 +716,8 @@ func TestPodStore(t *testing.T) {
709
716
},
710
717
LastTerminationState : v1.ContainerState {
711
718
Terminated : & v1.ContainerStateTerminated {
712
- Reason : "OOMKilled" ,
719
+ Reason : "OOMKilled" ,
720
+ ExitCode : 137 ,
713
721
},
714
722
},
715
723
},
@@ -718,13 +726,15 @@ func TestPodStore(t *testing.T) {
718
726
},
719
727
Want : `
720
728
# HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state.
729
+ # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state.
721
730
# HELP kube_pod_container_status_running Describes whether the container is currently in running state.
722
731
# HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
723
732
# HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
724
733
# HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
725
734
# HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state.
726
735
# HELP kube_pod_container_state_started Start time in unix timestamp for a pod container.
727
736
# TYPE kube_pod_container_status_last_terminated_reason gauge
737
+ # TYPE kube_pod_container_status_last_terminated_exitcode gauge
728
738
# TYPE kube_pod_container_status_running gauge
729
739
# TYPE kube_pod_container_status_terminated gauge
730
740
# TYPE kube_pod_container_status_terminated_reason gauge
@@ -736,9 +746,11 @@ func TestPodStore(t *testing.T) {
736
746
kube_pod_container_status_terminated{container="container7",namespace="ns6",pod="pod6",uid="uid6"} 0
737
747
kube_pod_container_status_waiting{container="container7",namespace="ns6",pod="pod6",uid="uid6"} 0
738
748
kube_pod_container_status_last_terminated_reason{container="container7",namespace="ns6",pod="pod6",reason="OOMKilled",uid="uid6"} 1
749
+ kube_pod_container_status_last_terminated_exitcode{container="container7",namespace="ns6",pod="pod6",uid="uid6"} 137
739
750
` ,
740
751
MetricNames : []string {
741
752
"kube_pod_container_status_last_terminated_reason" ,
753
+ "kube_pod_container_status_last_terminated_exitcode" ,
742
754
"kube_pod_container_status_running" ,
743
755
"kube_pod_container_state_started" ,
744
756
"kube_pod_container_status_terminated" ,
@@ -774,21 +786,24 @@ func TestPodStore(t *testing.T) {
774
786
},
775
787
LastTerminationState : v1.ContainerState {
776
788
Terminated : & v1.ContainerStateTerminated {
777
- Reason : "DeadlineExceeded" ,
789
+ Reason : "DeadlineExceeded" ,
790
+ ExitCode : 143 ,
778
791
},
779
792
},
780
793
},
781
794
},
782
795
},
783
796
},
784
797
Want : `
798
+ # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state.
785
799
# HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state.
786
800
# HELP kube_pod_container_status_running Describes whether the container is currently in running state.
787
801
# HELP kube_pod_container_state_started Start time in unix timestamp for a pod container.
788
802
# HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
789
803
# HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
790
804
# HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
791
805
# HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state.
806
+ # TYPE kube_pod_container_status_last_terminated_exitcode gauge
792
807
# TYPE kube_pod_container_status_last_terminated_reason gauge
793
808
# TYPE kube_pod_container_status_running gauge
794
809
# TYPE kube_pod_container_state_started gauge
@@ -797,6 +812,7 @@ func TestPodStore(t *testing.T) {
797
812
# TYPE kube_pod_container_status_waiting gauge
798
813
# TYPE kube_pod_container_status_waiting_reason gauge
799
814
kube_pod_container_state_started{container="container7",namespace="ns7",pod="pod7",uid="uid7"} 1.501777018e+09
815
+ kube_pod_container_status_last_terminated_exitcode{container="container7",namespace="ns7",pod="pod7",uid="uid7"} 143
800
816
kube_pod_container_status_last_terminated_reason{container="container7",namespace="ns7",pod="pod7",reason="DeadlineExceeded",uid="uid7"} 1
801
817
kube_pod_container_status_running{container="container7",namespace="ns7",pod="pod7",uid="uid7"} 1
802
818
kube_pod_container_status_terminated{container="container7",namespace="ns7",pod="pod7",uid="uid7"} 0
@@ -809,6 +825,7 @@ func TestPodStore(t *testing.T) {
809
825
"kube_pod_container_status_terminated_reason" ,
810
826
"kube_pod_container_status_waiting" ,
811
827
"kube_pod_container_status_last_terminated_reason" ,
828
+ "kube_pod_container_status_last_terminated_exitcode" ,
812
829
},
813
830
},
814
831
{
@@ -2019,7 +2036,8 @@ func BenchmarkPodStore(b *testing.B) {
2019
2036
},
2020
2037
LastTerminationState : v1.ContainerState {
2021
2038
Terminated : & v1.ContainerStateTerminated {
2022
- Reason : "OOMKilled" ,
2039
+ Reason : "OOMKilled" ,
2040
+ ExitCode : 137 ,
2023
2041
},
2024
2042
},
2025
2043
},
@@ -2035,7 +2053,8 @@ func BenchmarkPodStore(b *testing.B) {
2035
2053
},
2036
2054
LastTerminationState : v1.ContainerState {
2037
2055
Terminated : & v1.ContainerStateTerminated {
2038
- Reason : "OOMKilled" ,
2056
+ Reason : "OOMKilled" ,
2057
+ ExitCode : 137 ,
2039
2058
},
2040
2059
},
2041
2060
},
@@ -2051,15 +2070,16 @@ func BenchmarkPodStore(b *testing.B) {
2051
2070
},
2052
2071
LastTerminationState : v1.ContainerState {
2053
2072
Terminated : & v1.ContainerStateTerminated {
2054
- Reason : "OOMKilled" ,
2073
+ Reason : "OOMKilled" ,
2074
+ ExitCode : 137 ,
2055
2075
},
2056
2076
},
2057
2077
},
2058
2078
},
2059
2079
},
2060
2080
}
2061
2081
2062
- expectedFamilies := 46
2082
+ expectedFamilies := 47
2063
2083
for n := 0 ; n < b .N ; n ++ {
2064
2084
families := f (pod )
2065
2085
if len (families ) != expectedFamilies {
0 commit comments