Skip to main content

k8s_openapi/v1_37/api/scheduling/v1beta1/
pod_group_status.rs

1// Generated from definition io.k8s.api.scheduling.v1beta1.PodGroupStatus
2
3/// PodGroupStatus represents information about the status of a pod group.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodGroupStatus {
6    /// conditions represent the latest observations of the PodGroup's state.
7    ///
8    /// Known condition types: - "PodGroupInitiallyScheduled": Indicates whether the scheduling requirement has been satisfied. Once this condition transitions to True, it serves as a terminal state and will never revert to False, even if pods are subsequently evicted and group constraints are no longer met. - "DisruptionTarget": Indicates whether the PodGroup is about to be terminated
9    ///   due to disruption such as preemption.
10    ///
11    /// Known reasons for the PodGroupInitiallyScheduled condition: - "Unschedulable": The PodGroup cannot be scheduled due to resource constraints,
12    ///   affinity/anti-affinity rules, or insufficient capacity for the gang.
13    /// - "SchedulerError": The PodGroup cannot be scheduled due to some internal error
14    ///   that happened during scheduling, for example due to nodeAffinity parsing errors.
15    ///
16    /// Known reasons for the DisruptionTarget condition: - "PreemptionByScheduler": The PodGroup was preempted by the scheduler to make room for
17    ///   higher-priority PodGroups or Pods.
18    pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
19
20    /// resourceClaimStatuses is status of resource claims.
21    pub resource_claim_statuses: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaimStatus>>,
22}
23
24impl crate::DeepMerge for PodGroupStatus {
25    fn merge_from(&mut self, other: Self) {
26        crate::merge_strategies::list::map(
27            &mut self.conditions,
28            other.conditions,
29            &[|lhs, rhs| lhs.type_ == rhs.type_],
30            |current_item, other_item| {
31                crate::DeepMerge::merge_from(current_item, other_item);
32            },
33        );
34        crate::merge_strategies::list::map(
35            &mut self.resource_claim_statuses,
36            other.resource_claim_statuses,
37            &[|lhs, rhs| lhs.name == rhs.name],
38            |current_item, other_item| {
39                crate::DeepMerge::merge_from(current_item, other_item);
40            },
41        );
42    }
43}
44
45impl<'de> crate::serde::Deserialize<'de> for PodGroupStatus {
46    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
47        #[allow(non_camel_case_types)]
48        enum Field {
49            Key_conditions,
50            Key_resource_claim_statuses,
51            Other,
52        }
53
54        impl<'de> crate::serde::Deserialize<'de> for Field {
55            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
56                struct Visitor;
57
58                impl crate::serde::de::Visitor<'_> for Visitor {
59                    type Value = Field;
60
61                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
62                        f.write_str("field identifier")
63                    }
64
65                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
66                        Ok(match v {
67                            "conditions" => Field::Key_conditions,
68                            "resourceClaimStatuses" => Field::Key_resource_claim_statuses,
69                            _ => Field::Other,
70                        })
71                    }
72                }
73
74                deserializer.deserialize_identifier(Visitor)
75            }
76        }
77
78        struct Visitor;
79
80        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
81            type Value = PodGroupStatus;
82
83            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
84                f.write_str("PodGroupStatus")
85            }
86
87            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
88                let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
89                let mut value_resource_claim_statuses: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaimStatus>> = None;
90
91                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
92                    match key {
93                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
94                        Field::Key_resource_claim_statuses => value_resource_claim_statuses = crate::serde::de::MapAccess::next_value(&mut map)?,
95                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
96                    }
97                }
98
99                Ok(PodGroupStatus {
100                    conditions: value_conditions,
101                    resource_claim_statuses: value_resource_claim_statuses,
102                })
103            }
104        }
105
106        deserializer.deserialize_struct(
107            "PodGroupStatus",
108            &[
109                "conditions",
110                "resourceClaimStatuses",
111            ],
112            Visitor,
113        )
114    }
115}
116
117impl crate::serde::Serialize for PodGroupStatus {
118    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
119        let mut state = serializer.serialize_struct(
120            "PodGroupStatus",
121            self.conditions.as_ref().map_or(0, |_| 1) +
122            self.resource_claim_statuses.as_ref().map_or(0, |_| 1),
123        )?;
124        if let Some(value) = &self.conditions {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
126        }
127        if let Some(value) = &self.resource_claim_statuses {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaimStatuses", value)?;
129        }
130        crate::serde::ser::SerializeStruct::end(state)
131    }
132}
133
134#[cfg(feature = "schemars")]
135impl crate::schemars::JsonSchema for PodGroupStatus {
136    fn schema_name() -> std::borrow::Cow<'static, str> {
137        "io.k8s.api.scheduling.v1beta1.PodGroupStatus".into()
138    }
139
140    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
141        crate::schemars::json_schema!({
142            "description": "PodGroupStatus represents information about the status of a pod group.",
143            "type": "object",
144            "properties": {
145                "conditions": {
146                    "description": "conditions represent the latest observations of the PodGroup's state.\n\nKnown condition types: - \"PodGroupInitiallyScheduled\": Indicates whether the scheduling requirement has been satisfied. Once this condition transitions to True, it serves as a terminal state and will never revert to False, even if pods are subsequently evicted and group constraints are no longer met. - \"DisruptionTarget\": Indicates whether the PodGroup is about to be terminated\n  due to disruption such as preemption.\n\nKnown reasons for the PodGroupInitiallyScheduled condition: - \"Unschedulable\": The PodGroup cannot be scheduled due to resource constraints,\n  affinity/anti-affinity rules, or insufficient capacity for the gang.\n- \"SchedulerError\": The PodGroup cannot be scheduled due to some internal error\n  that happened during scheduling, for example due to nodeAffinity parsing errors.\n\nKnown reasons for the DisruptionTarget condition: - \"PreemptionByScheduler\": The PodGroup was preempted by the scheduler to make room for\n  higher-priority PodGroups or Pods.",
147                    "type": "array",
148                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
149                },
150                "resourceClaimStatuses": {
151                    "description": "resourceClaimStatuses is status of resource claims.",
152                    "type": "array",
153                    "items": (__gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupResourceClaimStatus>()),
154                },
155            },
156        })
157    }
158}