#
k8s_openapi/v1_35/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: i32,
    19
    20    /// minimum desired number of healthy pods
    21    pub desired_healthy: 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: i32,
    28
    29    /// total number of pods counted by this disruption budget
    30    pub expected_pods: 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.unwrap_or_default(),
    134                    desired_healthy: value_desired_healthy.unwrap_or_default(),
    135                    disrupted_pods: value_disrupted_pods,
    136                    disruptions_allowed: value_disruptions_allowed.unwrap_or_default(),
    137                    expected_pods: value_expected_pods.unwrap_or_default(),
    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            4 +
    164            self.conditions.as_ref().map_or(0, |_| 1) +
    165            self.disrupted_pods.as_ref().map_or(0, |_| 1) +
    166            self.observed_generation.as_ref().map_or(0, |_| 1),
    167        )?;
    168        if let Some(value) = &self.conditions {
    169            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
    170        }
    171        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "currentHealthy", &self.current_healthy)?;
    172        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "desiredHealthy", &self.desired_healthy)?;
    173        if let Some(value) = &self.disrupted_pods {
    174            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptedPods", value)?;
    175        }
    176        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionsAllowed", &self.disruptions_allowed)?;
    177        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "expectedPods", &self.expected_pods)?;
    178        if let Some(value) = &self.observed_generation {
    179            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
    180        }
    181        crate::serde::ser::SerializeStruct::end(state)
    182    }
    183}
    184
    185#[cfg(feature = "schemars")]
    186impl crate::schemars::JsonSchema for PodDisruptionBudgetStatus {
    187    fn schema_name() -> std::borrow::Cow<'static, str> {
    188        "io.k8s.api.policy.v1.PodDisruptionBudgetStatus".into()
    189    }
    190
    191    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    192        crate::schemars::json_schema!({
    193            "description": "PodDisruptionBudgetStatus represents information about the status of a PodDisruptionBudget. Status may trail the actual state of a system.",
    194            "type": "object",
    195            "properties": {
    196                "conditions": {
    197                    "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.",
    198                    "type": "array",
    199                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
    200                },
    201                "currentHealthy": {
    202                    "description": "current number of healthy pods",
    203                    "type": "integer",
    204                    "format": "int32",
    205                },
    206                "desiredHealthy": {
    207                    "description": "minimum desired number of healthy pods",
    208                    "type": "integer",
    209                    "format": "int32",
    210                },
    211                "disruptedPods": {
    212                    "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.",
    213                    "type": "object",
    214                    "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>()),
    215                },
    216                "disruptionsAllowed": {
    217                    "description": "Number of pod disruptions that are currently allowed.",
    218                    "type": "integer",
    219                    "format": "int32",
    220                },
    221                "expectedPods": {
    222                    "description": "total number of pods counted by this disruption budget",
    223                    "type": "integer",
    224                    "format": "int32",
    225                },
    226                "observedGeneration": {
    227                    "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.",
    228                    "type": "integer",
    229                    "format": "int64",
    230                },
    231            },
    232            "required": [
    233                "currentHealthy",
    234                "desiredHealthy",
    235                "disruptionsAllowed",
    236                "expectedPods",
    237            ],
    238        })
    239    }
    240}