@@ -573,7 +573,8 @@ func TestPodStore(t *testing.T) {
573573 StartedAt : metav1.Time {
574574 Time : time .Unix (1501777018 , 0 ),
575575 },
576- Reason : "OOMKilled" ,
576+ Reason : "OOMKilled" ,
577+ ExitCode : 137 ,
577578 },
578579 },
579580 },
@@ -648,12 +649,14 @@ func TestPodStore(t *testing.T) {
648649 },
649650 },
650651 Want : `
652+ # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state.
651653 # HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state.
652654 # HELP kube_pod_container_status_running Describes whether the container is currently in running state.
653655 # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
654656 # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
655657 # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
656658 # 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
657660 # TYPE kube_pod_container_status_last_terminated_reason gauge
658661 # TYPE kube_pod_container_status_running gauge
659662 # TYPE kube_pod_container_status_terminated gauge
@@ -678,6 +681,10 @@ func TestPodStore(t *testing.T) {
678681 "kube_pod_container_status_last_terminated_reason" ,
679682 "kube_pod_container_status_last_terminated_reason" ,
680683 "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" ,
681688 },
682689 },
683690 {
@@ -709,7 +716,8 @@ func TestPodStore(t *testing.T) {
709716 },
710717 LastTerminationState : v1.ContainerState {
711718 Terminated : & v1.ContainerStateTerminated {
712- Reason : "OOMKilled" ,
719+ Reason : "OOMKilled" ,
720+ ExitCode : 137 ,
713721 },
714722 },
715723 },
@@ -718,13 +726,15 @@ func TestPodStore(t *testing.T) {
718726 },
719727 Want : `
720728 # 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.
721730 # HELP kube_pod_container_status_running Describes whether the container is currently in running state.
722731 # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
723732 # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
724733 # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
725734 # HELP kube_pod_container_status_waiting_reason Describes the reason the container is currently in waiting state.
726735 # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container.
727736 # TYPE kube_pod_container_status_last_terminated_reason gauge
737+ # TYPE kube_pod_container_status_last_terminated_exitcode gauge
728738 # TYPE kube_pod_container_status_running gauge
729739 # TYPE kube_pod_container_status_terminated gauge
730740 # TYPE kube_pod_container_status_terminated_reason gauge
@@ -736,9 +746,11 @@ func TestPodStore(t *testing.T) {
736746 kube_pod_container_status_terminated{container="container7",namespace="ns6",pod="pod6",uid="uid6"} 0
737747 kube_pod_container_status_waiting{container="container7",namespace="ns6",pod="pod6",uid="uid6"} 0
738748 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
739750 ` ,
740751 MetricNames : []string {
741752 "kube_pod_container_status_last_terminated_reason" ,
753+ "kube_pod_container_status_last_terminated_exitcode" ,
742754 "kube_pod_container_status_running" ,
743755 "kube_pod_container_state_started" ,
744756 "kube_pod_container_status_terminated" ,
@@ -774,21 +786,24 @@ func TestPodStore(t *testing.T) {
774786 },
775787 LastTerminationState : v1.ContainerState {
776788 Terminated : & v1.ContainerStateTerminated {
777- Reason : "DeadlineExceeded" ,
789+ Reason : "DeadlineExceeded" ,
790+ ExitCode : 143 ,
778791 },
779792 },
780793 },
781794 },
782795 },
783796 },
784797 Want : `
798+ # HELP kube_pod_container_status_last_terminated_exitcode Describes the exit code for the last container in terminated state.
785799 # HELP kube_pod_container_status_last_terminated_reason Describes the last reason the container was in terminated state.
786800 # HELP kube_pod_container_status_running Describes whether the container is currently in running state.
787801 # HELP kube_pod_container_state_started Start time in unix timestamp for a pod container.
788802 # HELP kube_pod_container_status_terminated Describes whether the container is currently in terminated state.
789803 # HELP kube_pod_container_status_terminated_reason Describes the reason the container is currently in terminated state.
790804 # HELP kube_pod_container_status_waiting Describes whether the container is currently in waiting state.
791805 # 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
792807 # TYPE kube_pod_container_status_last_terminated_reason gauge
793808 # TYPE kube_pod_container_status_running gauge
794809 # TYPE kube_pod_container_state_started gauge
@@ -797,6 +812,7 @@ func TestPodStore(t *testing.T) {
797812 # TYPE kube_pod_container_status_waiting gauge
798813 # TYPE kube_pod_container_status_waiting_reason gauge
799814 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
800816 kube_pod_container_status_last_terminated_reason{container="container7",namespace="ns7",pod="pod7",reason="DeadlineExceeded",uid="uid7"} 1
801817 kube_pod_container_status_running{container="container7",namespace="ns7",pod="pod7",uid="uid7"} 1
802818 kube_pod_container_status_terminated{container="container7",namespace="ns7",pod="pod7",uid="uid7"} 0
@@ -809,6 +825,7 @@ func TestPodStore(t *testing.T) {
809825 "kube_pod_container_status_terminated_reason" ,
810826 "kube_pod_container_status_waiting" ,
811827 "kube_pod_container_status_last_terminated_reason" ,
828+ "kube_pod_container_status_last_terminated_exitcode" ,
812829 },
813830 },
814831 {
@@ -2019,7 +2036,8 @@ func BenchmarkPodStore(b *testing.B) {
20192036 },
20202037 LastTerminationState : v1.ContainerState {
20212038 Terminated : & v1.ContainerStateTerminated {
2022- Reason : "OOMKilled" ,
2039+ Reason : "OOMKilled" ,
2040+ ExitCode : 137 ,
20232041 },
20242042 },
20252043 },
@@ -2035,7 +2053,8 @@ func BenchmarkPodStore(b *testing.B) {
20352053 },
20362054 LastTerminationState : v1.ContainerState {
20372055 Terminated : & v1.ContainerStateTerminated {
2038- Reason : "OOMKilled" ,
2056+ Reason : "OOMKilled" ,
2057+ ExitCode : 137 ,
20392058 },
20402059 },
20412060 },
@@ -2051,15 +2070,16 @@ func BenchmarkPodStore(b *testing.B) {
20512070 },
20522071 LastTerminationState : v1.ContainerState {
20532072 Terminated : & v1.ContainerStateTerminated {
2054- Reason : "OOMKilled" ,
2073+ Reason : "OOMKilled" ,
2074+ ExitCode : 137 ,
20552075 },
20562076 },
20572077 },
20582078 },
20592079 },
20602080 }
20612081
2062- expectedFamilies := 46
2082+ expectedFamilies := 47
20632083 for n := 0 ; n < b .N ; n ++ {
20642084 families := f (pod )
20652085 if len (families ) != expectedFamilies {
0 commit comments