Skip to main content

k8s_openapi/v1_36/api/policy/v1/
pod_disruption_budget_status.rs

1// Generated from definition io.k8s.api.policy.v1.PodDisruptionBudgetStatus
2
3/// PodDisruptionBudgetStatus represents information about the status of a PodDisruptionBudget. Status may trail the actual state of a system.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodDisruptionBudgetStatus {
6    /// Conditions contain conditions for PDB. The disruption controller sets the DisruptionAllowed condition. The following are known values for the reason field (additional reasons could be added in the future): - SyncFailed: The controller encountered an error and wasn't able to compute
7    ///               the number of allowed disruptions. Therefore no disruptions are
8    ///               allowed and the status of the condition will be False.
9    /// - InsufficientPods: The number of pods are either at or below the number
10    ///                     required by the PodDisruptionBudget. No disruptions are
11    ///                     allowed and the status of the condition will be False.
12    /// - SufficientPods: There are more pods than required by the PodDisruptionBudget.
13    ///                   The condition will be True, and the number of allowed
14    ///                   disruptions are provided by the disruptionsAllowed property.
15    pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
16
17    /// current number of healthy pods
18    pub current_healthy: Option<i32>,
19
20    /// minimum desired number of healthy pods
21    pub desired_healthy: Option<i32>,
22
23    /// DisruptedPods contains information about pods whose eviction was processed by the API server eviction subresource handler but has not yet been observed by the PodDisruptionBudget controller. A pod will be in this map from the time when the API server processed the eviction request to the time when the pod is seen by PDB controller as having been marked for deletion (or after a timeout). The key in the map is the name of the pod and the value is the time when the API server processed the eviction request. If the deletion didn't occur and a pod is still there it will be removed from the list automatically by PodDisruptionBudget controller after some time. If everything goes smooth this map should be empty for the most of the time. Large number of entries in the map may indicate problems with pod deletions.
24    pub disrupted_pods: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::apis::meta::v1::Time>>,
25
26    /// Number of pod disruptions that are currently allowed.
27    pub disruptions_allowed: Option<i32>,
28
29    /// total number of pods counted by this disruption budget
30    pub expected_pods: Option<i32>,
31
32    /// Most recent generation observed when updating this PDB status. DisruptionsAllowed and other status information is valid only if observedGeneration equals to PDB's object generation.
33    pub observed_generation: Option<i64>,
34}
35
36impl crate::DeepMerge for PodDisruptionBudgetStatus {
37    fn merge_from(&mut self, other: Self) {
38        crate::merge_strategies::list::map(
39            &mut self.conditions,
40            other.conditions,
41            &[|lhs, rhs| lhs.type_ == rhs.type_],
42            |current_item, other_item| {
43                crate::DeepMerge::merge_from(current_item, other_item);
44            },
45        );
46        crate::DeepMerge::merge_from(&mut self.current_healthy, other.current_healthy);
47        crate::DeepMerge::merge_from(&mut self.desired_healthy, other.desired_healthy);
48        crate::merge_strategies::map::granular(&mut self.disrupted_pods, other.disrupted_pods, |current_item, other_item| {
49            crate::DeepMerge::merge_from(current_item, other_item);
50        });
51        crate::DeepMerge::merge_from(&mut self.disruptions_allowed, other.disruptions_allowed);
52        crate::DeepMerge::merge_from(&mut self.expected_pods, other.expected_pods);
53        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
54    }
55}
56
57impl<'de> crate::serde::Deserialize<'de> for PodDisruptionBudgetStatus {
58    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
59        #[allow(non_camel_case_types)]
60        enum Field {
61            Key_conditions,
62            Key_current_healthy,
63            Key_desired_healthy,
64            Key_disrupted_pods,
65            Key_disruptions_allowed,
66            Key_expected_pods,
67            Key_observed_generation,
68            Other,
69        }
70
71        impl<'de> crate::serde::Deserialize<'de> for Field {
72            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
73                struct Visitor;
74
75                impl crate::serde::de::Visitor<'_> for Visitor {
76                    type Value = Field;
77
78                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
79                        f.write_str("field identifier")
80                    }
81
82                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
83                        Ok(match v {
84                            "conditions" => Field::Key_conditions,
85                            "currentHealthy" => Field::Key_current_healthy,
86                            "desiredHealthy" => Field::Key_desired_healthy,
87                            "disruptedPods" => Field::Key_disrupted_pods,
88                            "disruptionsAllowed" => Field::Key_disruptions_allowed,
89                            "expectedPods" => Field::Key_expected_pods,
90                            "observedGeneration" => Field::Key_observed_generation,
91                            _ => Field::Other,
92                        })
93                    }
94                }
95
96                deserializer.deserialize_identifier(Visitor)
97            }
98        }
99
100        struct Visitor;
101
102        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
103            type Value = PodDisruptionBudgetStatus;
104
105            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
106                f.write_str("PodDisruptionBudgetStatus")
107            }
108
109            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
110                let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
111                let mut value_current_healthy: Option<i32> = None;
112                let mut value_desired_healthy: Option<i32> = None;
113                let mut value_disrupted_pods: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::apis::meta::v1::Time>> = None;
114                let mut value_disruptions_allowed: Option<i32> = None;
115                let mut value_expected_pods: Option<i32> = None;
116                let mut value_observed_generation: Option<i64> = None;
117
118                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
119                    match key {
120                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
121                        Field::Key_current_healthy => value_current_healthy = crate::serde::de::MapAccess::next_value(&mut map)?,
122                        Field::Key_desired_healthy => value_desired_healthy = crate::serde::de::MapAccess::next_value(&mut map)?,
123                        Field::Key_disrupted_pods => value_disrupted_pods = crate::serde::de::MapAccess::next_value(&mut map)?,
124                        Field::Key_disruptions_allowed => value_disruptions_allowed = crate::serde::de::MapAccess::next_value(&mut map)?,
125                        Field::Key_expected_pods => value_expected_pods = crate::serde::de::MapAccess::next_value(&mut map)?,
126                        Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
127                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
128                    }
129                }
130
131                Ok(PodDisruptionBudgetStatus {
132                    conditions: value_conditions,
133                    current_healthy: value_current_healthy,
134                    desired_healthy: value_desired_healthy,
135                    disrupted_pods: value_disrupted_pods,
136                    disruptions_allowed: value_disruptions_allowed,
137                    expected_pods: value_expected_pods,
138                    observed_generation: value_observed_generation,
139                })
140            }
141        }
142
143        deserializer.deserialize_struct(
144            "PodDisruptionBudgetStatus",
145            &[
146                "conditions",
147                "currentHealthy",
148                "desiredHealthy",
149                "disruptedPods",
150                "disruptionsAllowed",
151                "expectedPods",
152                "observedGeneration",
153            ],
154            Visitor,
155        )
156    }
157}
158
159impl crate::serde::Serialize for PodDisruptionBudgetStatus {
160    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
161        let mut state = serializer.serialize_struct(
162            "PodDisruptionBudgetStatus",
163            self.conditions.as_ref().map_or(0, |_| 1) +
164            self.current_healthy.as_ref().map_or(0, |_| 1) +
165            self.desired_healthy.as_ref().map_or(0, |_| 1) +
166            self.disrupted_pods.as_ref().map_or(0, |_| 1) +
167            self.disruptions_allowed.as_ref().map_or(0, |_| 1) +
168            self.expected_pods.as_ref().map_or(0, |_| 1) +
169            self.observed_generation.as_ref().map_or(0, |_| 1),
170        )?;
171        if let Some(value) = &self.conditions {
172            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
173        }
174        if let Some(value) = &self.current_healthy {
175            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "currentHealthy", value)?;
176        }
177        if let Some(value) = &self.desired_healthy {
178            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "desiredHealthy", value)?;
179        }
180        if let Some(value) = &self.disrupted_pods {
181            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptedPods", value)?;
182        }
183        if let Some(value) = &self.disruptions_allowed {
184            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionsAllowed", value)?;
185        }
186        if let Some(value) = &self.expected_pods {
187            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "expectedPods", value)?;
188        }
189        if let Some(value) = &self.observed_generation {
190            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
191        }
192        crate::serde::ser::SerializeStruct::end(state)
193    }
194}
195
196#[cfg(feature = "schemars")]
197impl crate::schemars::JsonSchema for PodDisruptionBudgetStatus {
198    fn schema_name() -> std::borrow::Cow<'static, str> {
199        "io.k8s.api.policy.v1.PodDisruptionBudgetStatus".into()
200    }
201
202    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
203        crate::schemars::json_schema!({
204            "description": "PodDisruptionBudgetStatus represents information about the status of a PodDisruptionBudget. Status may trail the actual state of a system.",
205            "type": "object",
206            "properties": {
207                "conditions": {
208                    "description": "Conditions contain conditions for PDB. The disruption controller sets the DisruptionAllowed condition. The following are known values for the reason field (additional reasons could be added in the future): - SyncFailed: The controller encountered an error and wasn't able to compute\n              the number of allowed disruptions. Therefore no disruptions are\n              allowed and the status of the condition will be False.\n- InsufficientPods: The number of pods are either at or below the number\n                    required by the PodDisruptionBudget. No disruptions are\n                    allowed and the status of the condition will be False.\n- SufficientPods: There are more pods than required by the PodDisruptionBudget.\n                  The condition will be True, and the number of allowed\n                  disruptions are provided by the disruptionsAllowed property.",
209                    "type": "array",
210                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
211                },
212                "currentHealthy": {
213                    "description": "current number of healthy pods",
214                    "type": "integer",
215                    "format": "int32",
216                },
217                "desiredHealthy": {
218                    "description": "minimum desired number of healthy pods",
219                    "type": "integer",
220                    "format": "int32",
221                },
222                "disruptedPods": {
223                    "description": "DisruptedPods contains information about pods whose eviction was processed by the API server eviction subresource handler but has not yet been observed by the PodDisruptionBudget controller. A pod will be in this map from the time when the API server processed the eviction request to the time when the pod is seen by PDB controller as having been marked for deletion (or after a timeout). The key in the map is the name of the pod and the value is the time when the API server processed the eviction request. If the deletion didn't occur and a pod is still there it will be removed from the list automatically by PodDisruptionBudget controller after some time. If everything goes smooth this map should be empty for the most of the time. Large number of entries in the map may indicate problems with pod deletions.",
224                    "type": "object",
225                    "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>()),
226                },
227                "disruptionsAllowed": {
228                    "description": "Number of pod disruptions that are currently allowed.",
229                    "type": "integer",
230                    "format": "int32",
231                },
232                "expectedPods": {
233                    "description": "total number of pods counted by this disruption budget",
234                    "type": "integer",
235                    "format": "int32",
236                },
237                "observedGeneration": {
238                    "description": "Most recent generation observed when updating this PDB status. DisruptionsAllowed and other status information is valid only if observedGeneration equals to PDB's object generation.",
239                    "type": "integer",
240                    "format": "int64",
241                },
242            },
243        })
244    }
245}
246
247#[cfg(feature = "schemars08")]
248impl crate::schemars08::JsonSchema for PodDisruptionBudgetStatus {
249    fn schema_name() -> std::string::String {
250        "io.k8s.api.policy.v1.PodDisruptionBudgetStatus".into()
251    }
252
253    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
254        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
255            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
256                description: Some("PodDisruptionBudgetStatus represents information about the status of a PodDisruptionBudget. Status may trail the actual state of a system.".into()),
257                ..Default::default()
258            })),
259            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
260            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
261                properties: [
262                    (
263                        "conditions".into(),
264                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
265                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
266                                description: Some("Conditions contain conditions for PDB. The disruption controller sets the DisruptionAllowed condition. The following are known values for the reason field (additional reasons could be added in the future): - SyncFailed: The controller encountered an error and wasn't able to compute\n              the number of allowed disruptions. Therefore no disruptions are\n              allowed and the status of the condition will be False.\n- InsufficientPods: The number of pods are either at or below the number\n                    required by the PodDisruptionBudget. No disruptions are\n                    allowed and the status of the condition will be False.\n- SufficientPods: There are more pods than required by the PodDisruptionBudget.\n                  The condition will be True, and the number of allowed\n                  disruptions are provided by the disruptionsAllowed property.".into()),
267                                ..Default::default()
268                            })),
269                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
270                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
271                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()))),
272                                ..Default::default()
273                            })),
274                            ..Default::default()
275                        }),
276                    ),
277                    (
278                        "currentHealthy".into(),
279                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
280                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
281                                description: Some("current number of healthy pods".into()),
282                                ..Default::default()
283                            })),
284                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
285                            format: Some("int32".into()),
286                            ..Default::default()
287                        }),
288                    ),
289                    (
290                        "desiredHealthy".into(),
291                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
292                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
293                                description: Some("minimum desired number of healthy pods".into()),
294                                ..Default::default()
295                            })),
296                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
297                            format: Some("int32".into()),
298                            ..Default::default()
299                        }),
300                    ),
301                    (
302                        "disruptedPods".into(),
303                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
304                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
305                                description: Some("DisruptedPods contains information about pods whose eviction was processed by the API server eviction subresource handler but has not yet been observed by the PodDisruptionBudget controller. A pod will be in this map from the time when the API server processed the eviction request to the time when the pod is seen by PDB controller as having been marked for deletion (or after a timeout). The key in the map is the name of the pod and the value is the time when the API server processed the eviction request. If the deletion didn't occur and a pod is still there it will be removed from the list automatically by PodDisruptionBudget controller after some time. If everything goes smooth this map should be empty for the most of the time. Large number of entries in the map may indicate problems with pod deletions.".into()),
306                                ..Default::default()
307                            })),
308                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
309                            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
310                                additional_properties: Some(std::boxed::Box::new(__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>())),
311                                ..Default::default()
312                            })),
313                            ..Default::default()
314                        }),
315                    ),
316                    (
317                        "disruptionsAllowed".into(),
318                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
319                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
320                                description: Some("Number of pod disruptions that are currently allowed.".into()),
321                                ..Default::default()
322                            })),
323                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
324                            format: Some("int32".into()),
325                            ..Default::default()
326                        }),
327                    ),
328                    (
329                        "expectedPods".into(),
330                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
331                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
332                                description: Some("total number of pods counted by this disruption budget".into()),
333                                ..Default::default()
334                            })),
335                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
336                            format: Some("int32".into()),
337                            ..Default::default()
338                        }),
339                    ),
340                    (
341                        "observedGeneration".into(),
342                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
343                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
344                                description: Some("Most recent generation observed when updating this PDB status. DisruptionsAllowed and other status information is valid only if observedGeneration equals to PDB's object generation.".into()),
345                                ..Default::default()
346                            })),
347                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
348                            format: Some("int64".into()),
349                            ..Default::default()
350                        }),
351                    ),
352                ].into(),
353                ..Default::default()
354            })),
355            ..Default::default()
356        })
357    }
358}