k8s_openapi/v1_33/api/batch/v1/
job_status.rs

1// Generated from definition io.k8s.api.batch.v1.JobStatus
2
3/// JobStatus represents the current state of a Job.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct JobStatus {
6    /// The number of pending and running pods which are not terminating (without a deletionTimestamp). The value is zero for finished jobs.
7    pub active: Option<i32>,
8
9    /// completedIndexes holds the completed indexes when .spec.completionMode = "Indexed" in a text format. The indexes are represented as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as "1,3-5,7".
10    pub completed_indexes: Option<std::string::String>,
11
12    /// Represents time when the job was completed. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC. The completion time is set when the job finishes successfully, and only then. The value cannot be updated or removed. The value indicates the same or later point in time as the startTime field.
13    pub completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
14
15    /// The latest available observations of an object's current state. When a Job fails, one of the conditions will have type "Failed" and status true. When a Job is suspended, one of the conditions will have type "Suspended" and status true; when the Job is resumed, the status of this condition will become false. When a Job is completed, one of the conditions will have type "Complete" and status true.
16    ///
17    /// A job is considered finished when it is in a terminal condition, either "Complete" or "Failed". A Job cannot have both the "Complete" and "Failed" conditions. Additionally, it cannot be in the "Complete" and "FailureTarget" conditions. The "Complete", "Failed" and "FailureTarget" conditions cannot be disabled.
18    ///
19    /// More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
20    pub conditions: Option<std::vec::Vec<crate::api::batch::v1::JobCondition>>,
21
22    /// The number of pods which reached phase Failed. The value increases monotonically.
23    pub failed: Option<i32>,
24
25    /// FailedIndexes holds the failed indexes when spec.backoffLimitPerIndex is set. The indexes are represented in the text format analogous as for the `completedIndexes` field, ie. they are kept as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the failed indexes are 1, 3, 4, 5 and 7, they are represented as "1,3-5,7". The set of failed indexes cannot overlap with the set of completed indexes.
26    pub failed_indexes: Option<std::string::String>,
27
28    /// The number of active pods which have a Ready condition and are not terminating (without a deletionTimestamp).
29    pub ready: Option<i32>,
30
31    /// Represents time when the job controller started processing a job. When a Job is created in the suspended state, this field is not set until the first time it is resumed. This field is reset every time a Job is resumed from suspension. It is represented in RFC3339 form and is in UTC.
32    ///
33    /// Once set, the field can only be removed when the job is suspended. The field cannot be modified while the job is unsuspended or finished.
34    pub start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
35
36    /// The number of pods which reached phase Succeeded. The value increases monotonically for a given spec. However, it may decrease in reaction to scale down of elastic indexed jobs.
37    pub succeeded: Option<i32>,
38
39    /// The number of pods which are terminating (in phase Pending or Running and have a deletionTimestamp).
40    ///
41    /// This field is beta-level. The job controller populates the field when the feature gate JobPodReplacementPolicy is enabled (enabled by default).
42    pub terminating: Option<i32>,
43
44    /// uncountedTerminatedPods holds the UIDs of Pods that have terminated but the job controller hasn't yet accounted for in the status counters.
45    ///
46    /// The job controller creates pods with a finalizer. When a pod terminates (succeeded or failed), the controller does three steps to account for it in the job status:
47    ///
48    /// 1. Add the pod UID to the arrays in this field. 2. Remove the pod finalizer. 3. Remove the pod UID from the arrays while increasing the corresponding
49    ///     counter.
50    ///
51    /// Old jobs might not be tracked using this field, in which case the field remains null. The structure is empty for finished jobs.
52    pub uncounted_terminated_pods: Option<crate::api::batch::v1::UncountedTerminatedPods>,
53}
54
55impl crate::DeepMerge for JobStatus {
56    fn merge_from(&mut self, other: Self) {
57        crate::DeepMerge::merge_from(&mut self.active, other.active);
58        crate::DeepMerge::merge_from(&mut self.completed_indexes, other.completed_indexes);
59        crate::DeepMerge::merge_from(&mut self.completion_time, other.completion_time);
60        crate::merge_strategies::list::map(
61            &mut self.conditions,
62            other.conditions,
63            &[|lhs, rhs| lhs.type_ == rhs.type_],
64            |current_item, other_item| {
65                crate::DeepMerge::merge_from(current_item, other_item);
66            },
67        );
68        crate::DeepMerge::merge_from(&mut self.failed, other.failed);
69        crate::DeepMerge::merge_from(&mut self.failed_indexes, other.failed_indexes);
70        crate::DeepMerge::merge_from(&mut self.ready, other.ready);
71        crate::DeepMerge::merge_from(&mut self.start_time, other.start_time);
72        crate::DeepMerge::merge_from(&mut self.succeeded, other.succeeded);
73        crate::DeepMerge::merge_from(&mut self.terminating, other.terminating);
74        crate::DeepMerge::merge_from(&mut self.uncounted_terminated_pods, other.uncounted_terminated_pods);
75    }
76}
77
78impl<'de> crate::serde::Deserialize<'de> for JobStatus {
79    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
80        #[allow(non_camel_case_types)]
81        enum Field {
82            Key_active,
83            Key_completed_indexes,
84            Key_completion_time,
85            Key_conditions,
86            Key_failed,
87            Key_failed_indexes,
88            Key_ready,
89            Key_start_time,
90            Key_succeeded,
91            Key_terminating,
92            Key_uncounted_terminated_pods,
93            Other,
94        }
95
96        impl<'de> crate::serde::Deserialize<'de> for Field {
97            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
98                struct Visitor;
99
100                impl crate::serde::de::Visitor<'_> for Visitor {
101                    type Value = Field;
102
103                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
104                        f.write_str("field identifier")
105                    }
106
107                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
108                        Ok(match v {
109                            "active" => Field::Key_active,
110                            "completedIndexes" => Field::Key_completed_indexes,
111                            "completionTime" => Field::Key_completion_time,
112                            "conditions" => Field::Key_conditions,
113                            "failed" => Field::Key_failed,
114                            "failedIndexes" => Field::Key_failed_indexes,
115                            "ready" => Field::Key_ready,
116                            "startTime" => Field::Key_start_time,
117                            "succeeded" => Field::Key_succeeded,
118                            "terminating" => Field::Key_terminating,
119                            "uncountedTerminatedPods" => Field::Key_uncounted_terminated_pods,
120                            _ => Field::Other,
121                        })
122                    }
123                }
124
125                deserializer.deserialize_identifier(Visitor)
126            }
127        }
128
129        struct Visitor;
130
131        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
132            type Value = JobStatus;
133
134            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
135                f.write_str("JobStatus")
136            }
137
138            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
139                let mut value_active: Option<i32> = None;
140                let mut value_completed_indexes: Option<std::string::String> = None;
141                let mut value_completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
142                let mut value_conditions: Option<std::vec::Vec<crate::api::batch::v1::JobCondition>> = None;
143                let mut value_failed: Option<i32> = None;
144                let mut value_failed_indexes: Option<std::string::String> = None;
145                let mut value_ready: Option<i32> = None;
146                let mut value_start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
147                let mut value_succeeded: Option<i32> = None;
148                let mut value_terminating: Option<i32> = None;
149                let mut value_uncounted_terminated_pods: Option<crate::api::batch::v1::UncountedTerminatedPods> = None;
150
151                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
152                    match key {
153                        Field::Key_active => value_active = crate::serde::de::MapAccess::next_value(&mut map)?,
154                        Field::Key_completed_indexes => value_completed_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
155                        Field::Key_completion_time => value_completion_time = crate::serde::de::MapAccess::next_value(&mut map)?,
156                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
157                        Field::Key_failed => value_failed = crate::serde::de::MapAccess::next_value(&mut map)?,
158                        Field::Key_failed_indexes => value_failed_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
159                        Field::Key_ready => value_ready = crate::serde::de::MapAccess::next_value(&mut map)?,
160                        Field::Key_start_time => value_start_time = crate::serde::de::MapAccess::next_value(&mut map)?,
161                        Field::Key_succeeded => value_succeeded = crate::serde::de::MapAccess::next_value(&mut map)?,
162                        Field::Key_terminating => value_terminating = crate::serde::de::MapAccess::next_value(&mut map)?,
163                        Field::Key_uncounted_terminated_pods => value_uncounted_terminated_pods = crate::serde::de::MapAccess::next_value(&mut map)?,
164                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
165                    }
166                }
167
168                Ok(JobStatus {
169                    active: value_active,
170                    completed_indexes: value_completed_indexes,
171                    completion_time: value_completion_time,
172                    conditions: value_conditions,
173                    failed: value_failed,
174                    failed_indexes: value_failed_indexes,
175                    ready: value_ready,
176                    start_time: value_start_time,
177                    succeeded: value_succeeded,
178                    terminating: value_terminating,
179                    uncounted_terminated_pods: value_uncounted_terminated_pods,
180                })
181            }
182        }
183
184        deserializer.deserialize_struct(
185            "JobStatus",
186            &[
187                "active",
188                "completedIndexes",
189                "completionTime",
190                "conditions",
191                "failed",
192                "failedIndexes",
193                "ready",
194                "startTime",
195                "succeeded",
196                "terminating",
197                "uncountedTerminatedPods",
198            ],
199            Visitor,
200        )
201    }
202}
203
204impl crate::serde::Serialize for JobStatus {
205    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
206        let mut state = serializer.serialize_struct(
207            "JobStatus",
208            self.active.as_ref().map_or(0, |_| 1) +
209            self.completed_indexes.as_ref().map_or(0, |_| 1) +
210            self.completion_time.as_ref().map_or(0, |_| 1) +
211            self.conditions.as_ref().map_or(0, |_| 1) +
212            self.failed.as_ref().map_or(0, |_| 1) +
213            self.failed_indexes.as_ref().map_or(0, |_| 1) +
214            self.ready.as_ref().map_or(0, |_| 1) +
215            self.start_time.as_ref().map_or(0, |_| 1) +
216            self.succeeded.as_ref().map_or(0, |_| 1) +
217            self.terminating.as_ref().map_or(0, |_| 1) +
218            self.uncounted_terminated_pods.as_ref().map_or(0, |_| 1),
219        )?;
220        if let Some(value) = &self.active {
221            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "active", value)?;
222        }
223        if let Some(value) = &self.completed_indexes {
224            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completedIndexes", value)?;
225        }
226        if let Some(value) = &self.completion_time {
227            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completionTime", value)?;
228        }
229        if let Some(value) = &self.conditions {
230            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
231        }
232        if let Some(value) = &self.failed {
233            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "failed", value)?;
234        }
235        if let Some(value) = &self.failed_indexes {
236            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "failedIndexes", value)?;
237        }
238        if let Some(value) = &self.ready {
239            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ready", value)?;
240        }
241        if let Some(value) = &self.start_time {
242            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startTime", value)?;
243        }
244        if let Some(value) = &self.succeeded {
245            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeeded", value)?;
246        }
247        if let Some(value) = &self.terminating {
248            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminating", value)?;
249        }
250        if let Some(value) = &self.uncounted_terminated_pods {
251            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "uncountedTerminatedPods", value)?;
252        }
253        crate::serde::ser::SerializeStruct::end(state)
254    }
255}
256
257#[cfg(feature = "schemars")]
258impl crate::schemars::JsonSchema for JobStatus {
259    fn schema_name() -> std::string::String {
260        "io.k8s.api.batch.v1.JobStatus".into()
261    }
262
263    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
264        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
265            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
266                description: Some("JobStatus represents the current state of a Job.".into()),
267                ..Default::default()
268            })),
269            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
270            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
271                properties: [
272                    (
273                        "active".into(),
274                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
275                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
276                                description: Some("The number of pending and running pods which are not terminating (without a deletionTimestamp). The value is zero for finished jobs.".into()),
277                                ..Default::default()
278                            })),
279                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
280                            format: Some("int32".into()),
281                            ..Default::default()
282                        }),
283                    ),
284                    (
285                        "completedIndexes".into(),
286                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
287                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
288                                description: Some("completedIndexes holds the completed indexes when .spec.completionMode = \"Indexed\" in a text format. The indexes are represented as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\".".into()),
289                                ..Default::default()
290                            })),
291                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
292                            ..Default::default()
293                        }),
294                    ),
295                    (
296                        "completionTime".into(),
297                        {
298                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>().into_object();
299                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
300                                description: Some("Represents time when the job was completed. It is not guaranteed to be set in happens-before order across separate operations. It is represented in RFC3339 form and is in UTC. The completion time is set when the job finishes successfully, and only then. The value cannot be updated or removed. The value indicates the same or later point in time as the startTime field.".into()),
301                                ..Default::default()
302                            }));
303                            crate::schemars::schema::Schema::Object(schema_obj)
304                        },
305                    ),
306                    (
307                        "conditions".into(),
308                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
309                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
310                                description: Some("The latest available observations of an object's current state. When a Job fails, one of the conditions will have type \"Failed\" and status true. When a Job is suspended, one of the conditions will have type \"Suspended\" and status true; when the Job is resumed, the status of this condition will become false. When a Job is completed, one of the conditions will have type \"Complete\" and status true.\n\nA job is considered finished when it is in a terminal condition, either \"Complete\" or \"Failed\". A Job cannot have both the \"Complete\" and \"Failed\" conditions. Additionally, it cannot be in the \"Complete\" and \"FailureTarget\" conditions. The \"Complete\", \"Failed\" and \"FailureTarget\" conditions cannot be disabled.\n\nMore info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/".into()),
311                                ..Default::default()
312                            })),
313                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
314                            array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
315                                items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::batch::v1::JobCondition>()))),
316                                ..Default::default()
317                            })),
318                            ..Default::default()
319                        }),
320                    ),
321                    (
322                        "failed".into(),
323                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
324                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
325                                description: Some("The number of pods which reached phase Failed. The value increases monotonically.".into()),
326                                ..Default::default()
327                            })),
328                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
329                            format: Some("int32".into()),
330                            ..Default::default()
331                        }),
332                    ),
333                    (
334                        "failedIndexes".into(),
335                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
336                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
337                                description: Some("FailedIndexes holds the failed indexes when spec.backoffLimitPerIndex is set. The indexes are represented in the text format analogous as for the `completedIndexes` field, ie. they are kept as decimal integers separated by commas. The numbers are listed in increasing order. Three or more consecutive numbers are compressed and represented by the first and last element of the series, separated by a hyphen. For example, if the failed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\". The set of failed indexes cannot overlap with the set of completed indexes.".into()),
338                                ..Default::default()
339                            })),
340                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
341                            ..Default::default()
342                        }),
343                    ),
344                    (
345                        "ready".into(),
346                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
347                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
348                                description: Some("The number of active pods which have a Ready condition and are not terminating (without a deletionTimestamp).".into()),
349                                ..Default::default()
350                            })),
351                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
352                            format: Some("int32".into()),
353                            ..Default::default()
354                        }),
355                    ),
356                    (
357                        "startTime".into(),
358                        {
359                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>().into_object();
360                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
361                                description: Some("Represents time when the job controller started processing a job. When a Job is created in the suspended state, this field is not set until the first time it is resumed. This field is reset every time a Job is resumed from suspension. It is represented in RFC3339 form and is in UTC.\n\nOnce set, the field can only be removed when the job is suspended. The field cannot be modified while the job is unsuspended or finished.".into()),
362                                ..Default::default()
363                            }));
364                            crate::schemars::schema::Schema::Object(schema_obj)
365                        },
366                    ),
367                    (
368                        "succeeded".into(),
369                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
370                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
371                                description: Some("The number of pods which reached phase Succeeded. The value increases monotonically for a given spec. However, it may decrease in reaction to scale down of elastic indexed jobs.".into()),
372                                ..Default::default()
373                            })),
374                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
375                            format: Some("int32".into()),
376                            ..Default::default()
377                        }),
378                    ),
379                    (
380                        "terminating".into(),
381                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
382                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
383                                description: Some("The number of pods which are terminating (in phase Pending or Running and have a deletionTimestamp).\n\nThis field is beta-level. The job controller populates the field when the feature gate JobPodReplacementPolicy is enabled (enabled by default).".into()),
384                                ..Default::default()
385                            })),
386                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
387                            format: Some("int32".into()),
388                            ..Default::default()
389                        }),
390                    ),
391                    (
392                        "uncountedTerminatedPods".into(),
393                        {
394                            let mut schema_obj = __gen.subschema_for::<crate::api::batch::v1::UncountedTerminatedPods>().into_object();
395                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
396                                description: Some("uncountedTerminatedPods holds the UIDs of Pods that have terminated but the job controller hasn't yet accounted for in the status counters.\n\nThe job controller creates pods with a finalizer. When a pod terminates (succeeded or failed), the controller does three steps to account for it in the job status:\n\n1. Add the pod UID to the arrays in this field. 2. Remove the pod finalizer. 3. Remove the pod UID from the arrays while increasing the corresponding\n    counter.\n\nOld jobs might not be tracked using this field, in which case the field remains null. The structure is empty for finished jobs.".into()),
397                                ..Default::default()
398                            }));
399                            crate::schemars::schema::Schema::Object(schema_obj)
400                        },
401                    ),
402                ].into(),
403                ..Default::default()
404            })),
405            ..Default::default()
406        })
407    }
408}