1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct JobStatus {
6 pub active: Option<i32>,
8
9 pub completed_indexes: Option<String>,
11
12 pub completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
14
15 pub conditions: Option<Vec<crate::api::batch::v1::JobCondition>>,
21
22 pub failed: Option<i32>,
24
25 pub failed_indexes: Option<String>,
29
30 pub ready: Option<i32>,
32
33 pub start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
37
38 pub succeeded: Option<i32>,
40
41 pub terminating: Option<i32>,
45
46 pub uncounted_terminated_pods: Option<crate::api::batch::v1::UncountedTerminatedPods>,
55}
56
57impl crate::DeepMerge for JobStatus {
58 fn merge_from(&mut self, other: Self) {
59 crate::DeepMerge::merge_from(&mut self.active, other.active);
60 crate::DeepMerge::merge_from(&mut self.completed_indexes, other.completed_indexes);
61 crate::DeepMerge::merge_from(&mut self.completion_time, other.completion_time);
62 crate::merge_strategies::list::map(
63 &mut self.conditions,
64 other.conditions,
65 &[|lhs, rhs| lhs.type_ == rhs.type_],
66 |current_item, other_item| {
67 crate::DeepMerge::merge_from(current_item, other_item);
68 },
69 );
70 crate::DeepMerge::merge_from(&mut self.failed, other.failed);
71 crate::DeepMerge::merge_from(&mut self.failed_indexes, other.failed_indexes);
72 crate::DeepMerge::merge_from(&mut self.ready, other.ready);
73 crate::DeepMerge::merge_from(&mut self.start_time, other.start_time);
74 crate::DeepMerge::merge_from(&mut self.succeeded, other.succeeded);
75 crate::DeepMerge::merge_from(&mut self.terminating, other.terminating);
76 crate::DeepMerge::merge_from(&mut self.uncounted_terminated_pods, other.uncounted_terminated_pods);
77 }
78}
79
80impl<'de> crate::serde::Deserialize<'de> for JobStatus {
81 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
82 #[allow(non_camel_case_types)]
83 enum Field {
84 Key_active,
85 Key_completed_indexes,
86 Key_completion_time,
87 Key_conditions,
88 Key_failed,
89 Key_failed_indexes,
90 Key_ready,
91 Key_start_time,
92 Key_succeeded,
93 Key_terminating,
94 Key_uncounted_terminated_pods,
95 Other,
96 }
97
98 impl<'de> crate::serde::Deserialize<'de> for Field {
99 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
100 struct Visitor;
101
102 impl crate::serde::de::Visitor<'_> for Visitor {
103 type Value = Field;
104
105 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
106 f.write_str("field identifier")
107 }
108
109 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
110 Ok(match v {
111 "active" => Field::Key_active,
112 "completedIndexes" => Field::Key_completed_indexes,
113 "completionTime" => Field::Key_completion_time,
114 "conditions" => Field::Key_conditions,
115 "failed" => Field::Key_failed,
116 "failedIndexes" => Field::Key_failed_indexes,
117 "ready" => Field::Key_ready,
118 "startTime" => Field::Key_start_time,
119 "succeeded" => Field::Key_succeeded,
120 "terminating" => Field::Key_terminating,
121 "uncountedTerminatedPods" => Field::Key_uncounted_terminated_pods,
122 _ => Field::Other,
123 })
124 }
125 }
126
127 deserializer.deserialize_identifier(Visitor)
128 }
129 }
130
131 struct Visitor;
132
133 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
134 type Value = JobStatus;
135
136 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
137 f.write_str("JobStatus")
138 }
139
140 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
141 let mut value_active: Option<i32> = None;
142 let mut value_completed_indexes: Option<String> = None;
143 let mut value_completion_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
144 let mut value_conditions: Option<Vec<crate::api::batch::v1::JobCondition>> = None;
145 let mut value_failed: Option<i32> = None;
146 let mut value_failed_indexes: Option<String> = None;
147 let mut value_ready: Option<i32> = None;
148 let mut value_start_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
149 let mut value_succeeded: Option<i32> = None;
150 let mut value_terminating: Option<i32> = None;
151 let mut value_uncounted_terminated_pods: Option<crate::api::batch::v1::UncountedTerminatedPods> = None;
152
153 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
154 match key {
155 Field::Key_active => value_active = crate::serde::de::MapAccess::next_value(&mut map)?,
156 Field::Key_completed_indexes => value_completed_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
157 Field::Key_completion_time => value_completion_time = crate::serde::de::MapAccess::next_value(&mut map)?,
158 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
159 Field::Key_failed => value_failed = crate::serde::de::MapAccess::next_value(&mut map)?,
160 Field::Key_failed_indexes => value_failed_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
161 Field::Key_ready => value_ready = crate::serde::de::MapAccess::next_value(&mut map)?,
162 Field::Key_start_time => value_start_time = crate::serde::de::MapAccess::next_value(&mut map)?,
163 Field::Key_succeeded => value_succeeded = crate::serde::de::MapAccess::next_value(&mut map)?,
164 Field::Key_terminating => value_terminating = crate::serde::de::MapAccess::next_value(&mut map)?,
165 Field::Key_uncounted_terminated_pods => value_uncounted_terminated_pods = crate::serde::de::MapAccess::next_value(&mut map)?,
166 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
167 }
168 }
169
170 Ok(JobStatus {
171 active: value_active,
172 completed_indexes: value_completed_indexes,
173 completion_time: value_completion_time,
174 conditions: value_conditions,
175 failed: value_failed,
176 failed_indexes: value_failed_indexes,
177 ready: value_ready,
178 start_time: value_start_time,
179 succeeded: value_succeeded,
180 terminating: value_terminating,
181 uncounted_terminated_pods: value_uncounted_terminated_pods,
182 })
183 }
184 }
185
186 deserializer.deserialize_struct(
187 "JobStatus",
188 &[
189 "active",
190 "completedIndexes",
191 "completionTime",
192 "conditions",
193 "failed",
194 "failedIndexes",
195 "ready",
196 "startTime",
197 "succeeded",
198 "terminating",
199 "uncountedTerminatedPods",
200 ],
201 Visitor,
202 )
203 }
204}
205
206impl crate::serde::Serialize for JobStatus {
207 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
208 let mut state = serializer.serialize_struct(
209 "JobStatus",
210 self.active.as_ref().map_or(0, |_| 1) +
211 self.completed_indexes.as_ref().map_or(0, |_| 1) +
212 self.completion_time.as_ref().map_or(0, |_| 1) +
213 self.conditions.as_ref().map_or(0, |_| 1) +
214 self.failed.as_ref().map_or(0, |_| 1) +
215 self.failed_indexes.as_ref().map_or(0, |_| 1) +
216 self.ready.as_ref().map_or(0, |_| 1) +
217 self.start_time.as_ref().map_or(0, |_| 1) +
218 self.succeeded.as_ref().map_or(0, |_| 1) +
219 self.terminating.as_ref().map_or(0, |_| 1) +
220 self.uncounted_terminated_pods.as_ref().map_or(0, |_| 1),
221 )?;
222 if let Some(value) = &self.active {
223 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "active", value)?;
224 }
225 if let Some(value) = &self.completed_indexes {
226 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completedIndexes", value)?;
227 }
228 if let Some(value) = &self.completion_time {
229 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "completionTime", value)?;
230 }
231 if let Some(value) = &self.conditions {
232 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
233 }
234 if let Some(value) = &self.failed {
235 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "failed", value)?;
236 }
237 if let Some(value) = &self.failed_indexes {
238 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "failedIndexes", value)?;
239 }
240 if let Some(value) = &self.ready {
241 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ready", value)?;
242 }
243 if let Some(value) = &self.start_time {
244 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startTime", value)?;
245 }
246 if let Some(value) = &self.succeeded {
247 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeeded", value)?;
248 }
249 if let Some(value) = &self.terminating {
250 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminating", value)?;
251 }
252 if let Some(value) = &self.uncounted_terminated_pods {
253 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "uncountedTerminatedPods", value)?;
254 }
255 crate::serde::ser::SerializeStruct::end(state)
256 }
257}
258
259#[cfg(feature = "schemars")]
260impl crate::schemars::JsonSchema for JobStatus {
261 fn schema_name() -> String {
262 "io.k8s.api.batch.v1.JobStatus".to_owned()
263 }
264
265 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
266 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
267 metadata: Some(Box::new(crate::schemars::schema::Metadata {
268 description: Some("JobStatus represents the current state of a Job.".to_owned()),
269 ..Default::default()
270 })),
271 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
272 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
273 properties: [
274 (
275 "active".to_owned(),
276 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
277 metadata: Some(Box::new(crate::schemars::schema::Metadata {
278 description: Some("The number of pending and running pods which are not terminating (without a deletionTimestamp). The value is zero for finished jobs.".to_owned()),
279 ..Default::default()
280 })),
281 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
282 format: Some("int32".to_owned()),
283 ..Default::default()
284 }),
285 ),
286 (
287 "completedIndexes".to_owned(),
288 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
289 metadata: Some(Box::new(crate::schemars::schema::Metadata {
290 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\".".to_owned()),
291 ..Default::default()
292 })),
293 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
294 ..Default::default()
295 }),
296 ),
297 (
298 "completionTime".to_owned(),
299 {
300 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>().into_object();
301 schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
302 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.".to_owned()),
303 ..Default::default()
304 }));
305 crate::schemars::schema::Schema::Object(schema_obj)
306 },
307 ),
308 (
309 "conditions".to_owned(),
310 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
311 metadata: Some(Box::new(crate::schemars::schema::Metadata {
312 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/".to_owned()),
313 ..Default::default()
314 })),
315 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
316 array: Some(Box::new(crate::schemars::schema::ArrayValidation {
317 items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::batch::v1::JobCondition>()))),
318 ..Default::default()
319 })),
320 ..Default::default()
321 }),
322 ),
323 (
324 "failed".to_owned(),
325 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
326 metadata: Some(Box::new(crate::schemars::schema::Metadata {
327 description: Some("The number of pods which reached phase Failed. The value increases monotonically.".to_owned()),
328 ..Default::default()
329 })),
330 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
331 format: Some("int32".to_owned()),
332 ..Default::default()
333 }),
334 ),
335 (
336 "failedIndexes".to_owned(),
337 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
338 metadata: Some(Box::new(crate::schemars::schema::Metadata {
339 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.\n\nThis field is beta-level. It can be used when the `JobBackoffLimitPerIndex` feature gate is enabled (enabled by default).".to_owned()),
340 ..Default::default()
341 })),
342 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
343 ..Default::default()
344 }),
345 ),
346 (
347 "ready".to_owned(),
348 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
349 metadata: Some(Box::new(crate::schemars::schema::Metadata {
350 description: Some("The number of active pods which have a Ready condition and are not terminating (without a deletionTimestamp).".to_owned()),
351 ..Default::default()
352 })),
353 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
354 format: Some("int32".to_owned()),
355 ..Default::default()
356 }),
357 ),
358 (
359 "startTime".to_owned(),
360 {
361 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>().into_object();
362 schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
363 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.".to_owned()),
364 ..Default::default()
365 }));
366 crate::schemars::schema::Schema::Object(schema_obj)
367 },
368 ),
369 (
370 "succeeded".to_owned(),
371 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
372 metadata: Some(Box::new(crate::schemars::schema::Metadata {
373 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.".to_owned()),
374 ..Default::default()
375 })),
376 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
377 format: Some("int32".to_owned()),
378 ..Default::default()
379 }),
380 ),
381 (
382 "terminating".to_owned(),
383 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
384 metadata: Some(Box::new(crate::schemars::schema::Metadata {
385 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).".to_owned()),
386 ..Default::default()
387 })),
388 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
389 format: Some("int32".to_owned()),
390 ..Default::default()
391 }),
392 ),
393 (
394 "uncountedTerminatedPods".to_owned(),
395 {
396 let mut schema_obj = __gen.subschema_for::<crate::api::batch::v1::UncountedTerminatedPods>().into_object();
397 schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
398 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.".to_owned()),
399 ..Default::default()
400 }));
401 crate::schemars::schema::Schema::Object(schema_obj)
402 },
403 ),
404 ].into(),
405 ..Default::default()
406 })),
407 ..Default::default()
408 })
409 }
410}