Skip to main content

k8s_openapi/v1_37/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    pub terminating: Option<i32>,
41
42    /// uncountedTerminatedPods holds the UIDs of Pods that have terminated but the job controller hasn't yet accounted for in the status counters.
43    ///
44    /// 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:
45    ///
46    /// 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
47    ///     counter.
48    ///
49    /// Old jobs might not be tracked using this field, in which case the field remains null. The structure is empty for finished jobs.
50    pub uncounted_terminated_pods: Option<crate::api::batch::v1::UncountedTerminatedPods>,
51}
52
53impl crate::DeepMerge for JobStatus {
54    fn merge_from(&mut self, other: Self) {
55        crate::DeepMerge::merge_from(&mut self.active, other.active);
56        crate::DeepMerge::merge_from(&mut self.completed_indexes, other.completed_indexes);
57        crate::DeepMerge::merge_from(&mut self.completion_time, other.completion_time);
58        crate::merge_strategies::list::map(
59            &mut self.conditions,
60            other.conditions,
61            &[|lhs, rhs| lhs.type_ == rhs.type_],
62            |current_item, other_item| {
63                crate::DeepMerge::merge_from(current_item, other_item);
64            },
65        );
66        crate::DeepMerge::merge_from(&mut self.failed, other.failed);
67        crate::DeepMerge::merge_from(&mut self.failed_indexes, other.failed_indexes);
68        crate::DeepMerge::merge_from(&mut self.ready, other.ready);
69        crate::DeepMerge::merge_from(&mut self.start_time, other.start_time);
70        crate::DeepMerge::merge_from(&mut self.succeeded, other.succeeded);
71        crate::DeepMerge::merge_from(&mut self.terminating, other.terminating);
72        crate::DeepMerge::merge_from(&mut self.uncounted_terminated_pods, other.uncounted_terminated_pods);
73    }
74}
75
76impl<'de> crate::serde::Deserialize<'de> for JobStatus {
77    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
78        #[allow(non_camel_case_types)]
79        enum Field {
80            Key_active,
81            Key_completed_indexes,
82            Key_completion_time,
83            Key_conditions,
84            Key_failed,
85            Key_failed_indexes,
86            Key_ready,
87            Key_start_time,
88            Key_succeeded,
89            Key_terminating,
90            Key_uncounted_terminated_pods,
91            Other,
92        }
93
94        impl<'de> crate::serde::Deserialize<'de> for Field {
95            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
96                struct Visitor;
97
98                impl crate::serde::de::Visitor<'_> for Visitor {
99                    type Value = Field;
100
101                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
102                        f.write_str("field identifier")
103                    }
104
105                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
106                        Ok(match v {
107                            "active" => Field::Key_active,
108                            "completedIndexes" => Field::Key_completed_indexes,
109                            "completionTime" => Field::Key_completion_time,
110                            "conditions" => Field::Key_conditions,
111                            "failed" => Field::Key_failed,
112                            "failedIndexes" => Field::Key_failed_indexes,
113                            "ready" => Field::Key_ready,
114                            "startTime" => Field::Key_start_time,
115                            "succeeded" => Field::Key_succeeded,
116                            "terminating" => Field::Key_terminating,
117                            "uncountedTerminatedPods" => Field::Key_uncounted_terminated_pods,
118                            _ => Field::Other,
119                        })
120                    }
121                }
122
123                deserializer.deserialize_identifier(Visitor)
124            }
125        }
126
127        struct Visitor;
128
129        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
130            type Value = JobStatus;
131
132            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
133                f.write_str("JobStatus")
134            }
135
136            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
137                let mut value_active: Option<i32> = None;
138                let mut value_completed_indexes: Option<std::string::String> = None;
139                let mut value_completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
140                let mut value_conditions: Option<std::vec::Vec<crate::api::batch::v1::JobCondition>> = None;
141                let mut value_failed: Option<i32> = None;
142                let mut value_failed_indexes: Option<std::string::String> = None;
143                let mut value_ready: Option<i32> = None;
144                let mut value_start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
145                let mut value_succeeded: Option<i32> = None;
146                let mut value_terminating: Option<i32> = None;
147                let mut value_uncounted_terminated_pods: Option<crate::api::batch::v1::UncountedTerminatedPods> = None;
148
149                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
150                    match key {
151                        Field::Key_active => value_active = crate::serde::de::MapAccess::next_value(&mut map)?,
152                        Field::Key_completed_indexes => value_completed_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
153                        Field::Key_completion_time => value_completion_time = crate::serde::de::MapAccess::next_value(&mut map)?,
154                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
155                        Field::Key_failed => value_failed = crate::serde::de::MapAccess::next_value(&mut map)?,
156                        Field::Key_failed_indexes => value_failed_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
157                        Field::Key_ready => value_ready = crate::serde::de::MapAccess::next_value(&mut map)?,
158                        Field::Key_start_time => value_start_time = crate::serde::de::MapAccess::next_value(&mut map)?,
159                        Field::Key_succeeded => value_succeeded = crate::serde::de::MapAccess::next_value(&mut map)?,
160                        Field::Key_terminating => value_terminating = crate::serde::de::MapAccess::next_value(&mut map)?,
161                        Field::Key_uncounted_terminated_pods => value_uncounted_terminated_pods = crate::serde::de::MapAccess::next_value(&mut map)?,
162                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
163                    }
164                }
165
166                Ok(JobStatus {
167                    active: value_active,
168                    completed_indexes: value_completed_indexes,
169                    completion_time: value_completion_time,
170                    conditions: value_conditions,
171                    failed: value_failed,
172                    failed_indexes: value_failed_indexes,
173                    ready: value_ready,
174                    start_time: value_start_time,
175                    succeeded: value_succeeded,
176                    terminating: value_terminating,
177                    uncounted_terminated_pods: value_uncounted_terminated_pods,
178                })
179            }
180        }
181
182        deserializer.deserialize_struct(
183            "JobStatus",
184            &[
185                "active",
186                "completedIndexes",
187                "completionTime",
188                "conditions",
189                "failed",
190                "failedIndexes",
191                "ready",
192                "startTime",
193                "succeeded",
194                "terminating",
195                "uncountedTerminatedPods",
196            ],
197            Visitor,
198        )
199    }
200}
201
202impl crate::serde::Serialize for JobStatus {
203    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
204        let mut state = serializer.serialize_struct(
205            "JobStatus",
206            self.active.as_ref().map_or(0, |_| 1) +
207            self.completed_indexes.as_ref().map_or(0, |_| 1) +
208            self.completion_time.as_ref().map_or(0, |_| 1) +
209            self.conditions.as_ref().map_or(0, |_| 1) +
210            self.failed.as_ref().map_or(0, |_| 1) +
211            self.failed_indexes.as_ref().map_or(0, |_| 1) +
212            self.ready.as_ref().map_or(0, |_| 1) +
213            self.start_time.as_ref().map_or(0, |_| 1) +
214            self.succeeded.as_ref().map_or(0, |_| 1) +
215            self.terminating.as_ref().map_or(0, |_| 1) +
216            self.uncounted_terminated_pods.as_ref().map_or(0, |_| 1),
217        )?;
218        if let Some(value) = &self.active {
219            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "active", value)?;
220        }
221        if let Some(value) = &self.completed_indexes {
222            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completedIndexes", value)?;
223        }
224        if let Some(value) = &self.completion_time {
225            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completionTime", value)?;
226        }
227        if let Some(value) = &self.conditions {
228            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
229        }
230        if let Some(value) = &self.failed {
231            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "failed", value)?;
232        }
233        if let Some(value) = &self.failed_indexes {
234            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "failedIndexes", value)?;
235        }
236        if let Some(value) = &self.ready {
237            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ready", value)?;
238        }
239        if let Some(value) = &self.start_time {
240            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startTime", value)?;
241        }
242        if let Some(value) = &self.succeeded {
243            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeeded", value)?;
244        }
245        if let Some(value) = &self.terminating {
246            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminating", value)?;
247        }
248        if let Some(value) = &self.uncounted_terminated_pods {
249            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "uncountedTerminatedPods", value)?;
250        }
251        crate::serde::ser::SerializeStruct::end(state)
252    }
253}
254
255#[cfg(feature = "schemars")]
256impl crate::schemars::JsonSchema for JobStatus {
257    fn schema_name() -> std::borrow::Cow<'static, str> {
258        "io.k8s.api.batch.v1.JobStatus".into()
259    }
260
261    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
262        crate::schemars::json_schema!({
263            "description": "JobStatus represents the current state of a Job.",
264            "type": "object",
265            "properties": {
266                "active": {
267                    "description": "The number of pending and running pods which are not terminating (without a deletionTimestamp). The value is zero for finished jobs.",
268                    "type": "integer",
269                    "format": "int32",
270                },
271                "completedIndexes": {
272                    "description": "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\".",
273                    "type": "string",
274                },
275                "completionTime": ({
276                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
277                    schema_obj.ensure_object().insert("description".into(), "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());
278                    schema_obj
279                }),
280                "conditions": {
281                    "description": "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/",
282                    "type": "array",
283                    "items": (__gen.subschema_for::<crate::api::batch::v1::JobCondition>()),
284                },
285                "failed": {
286                    "description": "The number of pods which reached phase Failed. The value increases monotonically.",
287                    "type": "integer",
288                    "format": "int32",
289                },
290                "failedIndexes": {
291                    "description": "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.",
292                    "type": "string",
293                },
294                "ready": {
295                    "description": "The number of active pods which have a Ready condition and are not terminating (without a deletionTimestamp).",
296                    "type": "integer",
297                    "format": "int32",
298                },
299                "startTime": ({
300                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
301                    schema_obj.ensure_object().insert("description".into(), "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());
302                    schema_obj
303                }),
304                "succeeded": {
305                    "description": "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.",
306                    "type": "integer",
307                    "format": "int32",
308                },
309                "terminating": {
310                    "description": "The number of pods which are terminating (in phase Pending or Running and have a deletionTimestamp).",
311                    "type": "integer",
312                    "format": "int32",
313                },
314                "uncountedTerminatedPods": ({
315                    let mut schema_obj = __gen.subschema_for::<crate::api::batch::v1::UncountedTerminatedPods>();
316                    schema_obj.ensure_object().insert("description".into(), "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());
317                    schema_obj
318                }),
319            },
320        })
321    }
322}