@@ -31,6 +31,7 @@ import (
3131var (
3232 depl1Replicas int32 = 200
3333 depl2Replicas int32 = 5
34+ depl3Replicas int32 = 1
3435
3536 depl1MaxUnavailable = intstr .FromInt (10 )
3637 depl2MaxUnavailable = intstr .FromString ("25%" )
@@ -98,8 +99,8 @@ func TestDeploymentStore(t *testing.T) {
9899 UpdatedReplicas : 2 ,
99100 ObservedGeneration : 111 ,
100101 Conditions : []v1.DeploymentCondition {
101- {Type : v1 .DeploymentAvailable , Status : corev1 .ConditionTrue },
102- {Type : v1 .DeploymentProgressing , Status : corev1 .ConditionTrue },
102+ {Type : v1 .DeploymentAvailable , Status : corev1 .ConditionTrue , Reason : "MinimumReplicasAvailable" },
103+ {Type : v1 .DeploymentProgressing , Status : corev1 .ConditionTrue , Reason : "NewReplicaSetAvailable" },
103104 },
104105 },
105106 Spec : v1.DeploymentSpec {
@@ -126,12 +127,12 @@ func TestDeploymentStore(t *testing.T) {
126127 kube_deployment_status_replicas_updated{deployment="depl1",namespace="ns1"} 2
127128 kube_deployment_status_replicas{deployment="depl1",namespace="ns1"} 15
128129 kube_deployment_status_replicas_ready{deployment="depl1",namespace="ns1"} 10
129- kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Available ",status="true"} 1
130- kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Progressing ",status="true "} 1
131- kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Available ",status="false "} 0
132- kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Progressing ",status="false "} 0
133- kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Available ",status="unknown "} 0
134- kube_deployment_status_condition{deployment="depl1",namespace="ns1",condition="Progressing ",status="unknown"} 0
130+ kube_deployment_status_condition{condition="Available", deployment="depl1",namespace="ns1",reason="MinimumReplicasAvailable ",status="true"} 1
131+ kube_deployment_status_condition{condition="Available", deployment="depl1",namespace="ns1",reason="MinimumReplicasAvailable ",status="false "} 0
132+ kube_deployment_status_condition{condition="Available", deployment="depl1",namespace="ns1",reason="MinimumReplicasAvailable ",status="unknown "} 0
133+ kube_deployment_status_condition{condition="Progressing", deployment="depl1",namespace="ns1",reason="NewReplicaSetAvailable ",status="true "} 1
134+ kube_deployment_status_condition{condition="Progressing", deployment="depl1",namespace="ns1",reason="NewReplicaSetAvailable ",status="false "} 0
135+ kube_deployment_status_condition{condition="Progressing", deployment="depl1",namespace="ns1",reason="NewReplicaSetAvailable ",status="unknown"} 0
135136` ,
136137 },
137138 {
@@ -152,9 +153,9 @@ func TestDeploymentStore(t *testing.T) {
152153 UpdatedReplicas : 1 ,
153154 ObservedGeneration : 1111 ,
154155 Conditions : []v1.DeploymentCondition {
155- {Type : v1 .DeploymentAvailable , Status : corev1 .ConditionFalse },
156- {Type : v1 .DeploymentProgressing , Status : corev1 .ConditionFalse },
157- {Type : v1 .DeploymentReplicaFailure , Status : corev1 .ConditionTrue },
156+ {Type : v1 .DeploymentAvailable , Status : corev1 .ConditionFalse , Reason : "MinimumReplicasUnavailable" },
157+ {Type : v1 .DeploymentProgressing , Status : corev1 .ConditionFalse , Reason : "ProgressDeadlineExceeded" },
158+ {Type : v1 .DeploymentReplicaFailure , Status : corev1 .ConditionTrue , Reason : "ReplicaSetCreateError" },
158159 },
159160 },
160161 Spec : v1.DeploymentSpec {
@@ -180,15 +181,49 @@ func TestDeploymentStore(t *testing.T) {
180181 kube_deployment_status_replicas_updated{deployment="depl2",namespace="ns2"} 1
181182 kube_deployment_status_replicas{deployment="depl2",namespace="ns2"} 10
182183 kube_deployment_status_replicas_ready{deployment="depl2",namespace="ns2"} 5
183- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Available",status="true"} 0
184- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Progressing",status="true"} 0
185- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="ReplicaFailure",status="true"} 1
186- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Available",status="false"} 1
187- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Progressing",status="false"} 1
188- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="ReplicaFailure",status="false"} 0
189- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Available",status="unknown"} 0
190- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="Progressing",status="unknown"} 0
191- kube_deployment_status_condition{deployment="depl2",namespace="ns2",condition="ReplicaFailure",status="unknown"} 0
184+ kube_deployment_status_condition{condition="Available",deployment="depl2",namespace="ns2",reason="MinimumReplicasUnavailable",status="true"} 0
185+ kube_deployment_status_condition{condition="Available",deployment="depl2",namespace="ns2",reason="MinimumReplicasUnavailable",status="false"} 1
186+ kube_deployment_status_condition{condition="Available",deployment="depl2",namespace="ns2",reason="MinimumReplicasUnavailable",status="unknown"} 0
187+ kube_deployment_status_condition{condition="Progressing",deployment="depl2",namespace="ns2",reason="ProgressDeadlineExceeded",status="true"} 0
188+ kube_deployment_status_condition{condition="Progressing",deployment="depl2",namespace="ns2",reason="ProgressDeadlineExceeded",status="false"} 1
189+ kube_deployment_status_condition{condition="Progressing",deployment="depl2",namespace="ns2",reason="ProgressDeadlineExceeded",status="unknown"} 0
190+ kube_deployment_status_condition{condition="ReplicaFailure",deployment="depl2",namespace="ns2",reason="ReplicaSetCreateError",status="true"} 1
191+ kube_deployment_status_condition{condition="ReplicaFailure",deployment="depl2",namespace="ns2",reason="ReplicaSetCreateError",status="false"} 0
192+ kube_deployment_status_condition{condition="ReplicaFailure",deployment="depl2",namespace="ns2",reason="ReplicaSetCreateError",status="unknown"} 0
193+ ` ,
194+ },
195+ {
196+ Obj : & v1.Deployment {
197+ ObjectMeta : metav1.ObjectMeta {
198+ Name : "depl3" ,
199+ Namespace : "ns3" ,
200+ },
201+ Status : v1.DeploymentStatus {
202+ Conditions : []v1.DeploymentCondition {
203+ {Type : v1 .DeploymentAvailable , Status : corev1 .ConditionFalse , Reason : "ThisReasonIsNotAllowed" },
204+ {Type : v1 .DeploymentProgressing , Status : corev1 .ConditionTrue },
205+ },
206+ },
207+ Spec : v1.DeploymentSpec {
208+ Replicas : & depl3Replicas ,
209+ },
210+ },
211+ Want : metadata + `
212+ kube_deployment_metadata_generation{deployment="depl3",namespace="ns3"} 0
213+ kube_deployment_spec_paused{deployment="depl3",namespace="ns3"} 0
214+ kube_deployment_spec_replicas{deployment="depl3",namespace="ns3"} 1
215+ kube_deployment_status_condition{condition="Available",deployment="depl3",namespace="ns3",reason="unknown",status="true"} 0
216+ kube_deployment_status_condition{condition="Available",deployment="depl3",namespace="ns3",reason="unknown",status="false"} 1
217+ kube_deployment_status_condition{condition="Available",deployment="depl3",namespace="ns3",reason="unknown",status="unknown"} 0
218+ kube_deployment_status_observed_generation{deployment="depl3",namespace="ns3"} 0
219+ kube_deployment_status_replicas{deployment="depl3",namespace="ns3"} 0
220+ kube_deployment_status_replicas_available{deployment="depl3",namespace="ns3"} 0
221+ kube_deployment_status_replicas_ready{deployment="depl3",namespace="ns3"} 0
222+ kube_deployment_status_replicas_unavailable{deployment="depl3",namespace="ns3"} 0
223+ kube_deployment_status_replicas_updated{deployment="depl3",namespace="ns3"} 0
224+ kube_deployment_status_condition{condition="Progressing",deployment="depl3",namespace="ns3",reason="",status="false"} 0
225+ kube_deployment_status_condition{condition="Progressing",deployment="depl3",namespace="ns3",reason="",status="true"} 1
226+ kube_deployment_status_condition{condition="Progressing",deployment="depl3",namespace="ns3",reason="",status="unknown"} 0
192227` ,
193228 },
194229 }
0 commit comments