Skip to main content

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

1// Generated from definition io.k8s.api.scheduling.v1beta1.PodGroupSpec
2
3/// PodGroupSpec defines the desired state of a PodGroup.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodGroupSpec {
6    /// disruptionMode defines the mode in which a given PodGroup can be disrupted. Controllers are expected to fill this field by copying it from a PodGroupTemplate. One of Single, All. Defaults to Single if unset. This field is immutable.
7    pub disruption_mode: Option<crate::api::scheduling::v1beta1::DisruptionMode>,
8
9    /// parentCompositePodGroupName contains the name of the parent composite pod group within the same namespace as this pod group. If it's nil, then this pod group is a root of a workload's hierarchy. This field is used only when the CompositePodGroup feature gate is enabled. This field is immutable.
10    pub parent_composite_pod_group_name: Option<std::string::String>,
11
12    /// preemptionPolicy is the Policy for preempting pods/podgroups with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. When Priority Admission Controller is enabled, it populates this field from PriorityClassName, and defaults to PreemptLowerPriority if value is unset in PriorityClass. This field is immutable. This field is available only when the PodGroupPreemptionPolicy feature gate is enabled.
13    pub preemption_policy: Option<std::string::String>,
14
15    /// priority is the value of priority of this pod group. Various system components use this field to find the priority of the pod group. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. This field is immutable.
16    pub priority: Option<i32>,
17
18    /// priorityClassName defines the priority that should be considered when scheduling this pod group. Controllers are expected to fill this field by copying it from a PodGroupTemplate. Otherwise, it is validated and resolved similarly to the PriorityClassName on PodGroupTemplate (i.e. if no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, the pod group's priority will be zero). This field is immutable.
19    pub priority_class_name: Option<std::string::String>,
20
21    /// resourceClaims defines which ResourceClaims may be shared among Pods in the group. Pods consume the devices allocated to a PodGroup's claim by defining a claim in its own Spec.ResourceClaims that matches the PodGroup's claim exactly. The claim must have the same name and refer to the same ResourceClaim or ResourceClaimTemplate.
22    ///
23    /// This is a beta-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.
24    ///
25    /// This field is immutable.
26    pub resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaim>>,
27
28    /// schedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroup. Controllers are expected to fill this field by copying it from a PodGroupTemplate. This field is immutable. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.
29    pub scheduling_constraints: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints>,
30
31    /// schedulingPolicy defines the scheduling policy for this instance of the PodGroup. Controllers are expected to fill this field by copying it from a PodGroupTemplate.
32    pub scheduling_policy: crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy,
33
34    /// workloadRef references an optional PodGroup template within the Workload object that was used to create the PodGroup. This field is immutable.
35    pub workload_ref: Option<crate::api::scheduling::v1beta1::WorkloadReference>,
36}
37
38impl crate::DeepMerge for PodGroupSpec {
39    fn merge_from(&mut self, other: Self) {
40        crate::DeepMerge::merge_from(&mut self.disruption_mode, other.disruption_mode);
41        crate::DeepMerge::merge_from(&mut self.parent_composite_pod_group_name, other.parent_composite_pod_group_name);
42        crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
43        crate::DeepMerge::merge_from(&mut self.priority, other.priority);
44        crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
45        crate::merge_strategies::list::map(
46            &mut self.resource_claims,
47            other.resource_claims,
48            &[|lhs, rhs| lhs.name == rhs.name],
49            |current_item, other_item| {
50                crate::DeepMerge::merge_from(current_item, other_item);
51            },
52        );
53        crate::DeepMerge::merge_from(&mut self.scheduling_constraints, other.scheduling_constraints);
54        crate::DeepMerge::merge_from(&mut self.scheduling_policy, other.scheduling_policy);
55        crate::DeepMerge::merge_from(&mut self.workload_ref, other.workload_ref);
56    }
57}
58
59impl<'de> crate::serde::Deserialize<'de> for PodGroupSpec {
60    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
61        #[allow(non_camel_case_types)]
62        enum Field {
63            Key_disruption_mode,
64            Key_parent_composite_pod_group_name,
65            Key_preemption_policy,
66            Key_priority,
67            Key_priority_class_name,
68            Key_resource_claims,
69            Key_scheduling_constraints,
70            Key_scheduling_policy,
71            Key_workload_ref,
72            Other,
73        }
74
75        impl<'de> crate::serde::Deserialize<'de> for Field {
76            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
77                struct Visitor;
78
79                impl crate::serde::de::Visitor<'_> for Visitor {
80                    type Value = Field;
81
82                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83                        f.write_str("field identifier")
84                    }
85
86                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
87                        Ok(match v {
88                            "disruptionMode" => Field::Key_disruption_mode,
89                            "parentCompositePodGroupName" => Field::Key_parent_composite_pod_group_name,
90                            "preemptionPolicy" => Field::Key_preemption_policy,
91                            "priority" => Field::Key_priority,
92                            "priorityClassName" => Field::Key_priority_class_name,
93                            "resourceClaims" => Field::Key_resource_claims,
94                            "schedulingConstraints" => Field::Key_scheduling_constraints,
95                            "schedulingPolicy" => Field::Key_scheduling_policy,
96                            "workloadRef" => Field::Key_workload_ref,
97                            _ => Field::Other,
98                        })
99                    }
100                }
101
102                deserializer.deserialize_identifier(Visitor)
103            }
104        }
105
106        struct Visitor;
107
108        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
109            type Value = PodGroupSpec;
110
111            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
112                f.write_str("PodGroupSpec")
113            }
114
115            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
116                let mut value_disruption_mode: Option<crate::api::scheduling::v1beta1::DisruptionMode> = None;
117                let mut value_parent_composite_pod_group_name: Option<std::string::String> = None;
118                let mut value_preemption_policy: Option<std::string::String> = None;
119                let mut value_priority: Option<i32> = None;
120                let mut value_priority_class_name: Option<std::string::String> = None;
121                let mut value_resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1beta1::PodGroupResourceClaim>> = None;
122                let mut value_scheduling_constraints: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints> = None;
123                let mut value_scheduling_policy: Option<crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy> = None;
124                let mut value_workload_ref: Option<crate::api::scheduling::v1beta1::WorkloadReference> = None;
125
126                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
127                    match key {
128                        Field::Key_disruption_mode => value_disruption_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
129                        Field::Key_parent_composite_pod_group_name => value_parent_composite_pod_group_name = crate::serde::de::MapAccess::next_value(&mut map)?,
130                        Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
131                        Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
132                        Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
133                        Field::Key_resource_claims => value_resource_claims = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Key_scheduling_constraints => value_scheduling_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
135                        Field::Key_scheduling_policy => value_scheduling_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
136                        Field::Key_workload_ref => value_workload_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
137                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
138                    }
139                }
140
141                Ok(PodGroupSpec {
142                    disruption_mode: value_disruption_mode,
143                    parent_composite_pod_group_name: value_parent_composite_pod_group_name,
144                    preemption_policy: value_preemption_policy,
145                    priority: value_priority,
146                    priority_class_name: value_priority_class_name,
147                    resource_claims: value_resource_claims,
148                    scheduling_constraints: value_scheduling_constraints,
149                    scheduling_policy: value_scheduling_policy.unwrap_or_default(),
150                    workload_ref: value_workload_ref,
151                })
152            }
153        }
154
155        deserializer.deserialize_struct(
156            "PodGroupSpec",
157            &[
158                "disruptionMode",
159                "parentCompositePodGroupName",
160                "preemptionPolicy",
161                "priority",
162                "priorityClassName",
163                "resourceClaims",
164                "schedulingConstraints",
165                "schedulingPolicy",
166                "workloadRef",
167            ],
168            Visitor,
169        )
170    }
171}
172
173impl crate::serde::Serialize for PodGroupSpec {
174    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
175        let mut state = serializer.serialize_struct(
176            "PodGroupSpec",
177            1 +
178            self.disruption_mode.as_ref().map_or(0, |_| 1) +
179            self.parent_composite_pod_group_name.as_ref().map_or(0, |_| 1) +
180            self.preemption_policy.as_ref().map_or(0, |_| 1) +
181            self.priority.as_ref().map_or(0, |_| 1) +
182            self.priority_class_name.as_ref().map_or(0, |_| 1) +
183            self.resource_claims.as_ref().map_or(0, |_| 1) +
184            self.scheduling_constraints.as_ref().map_or(0, |_| 1) +
185            self.workload_ref.as_ref().map_or(0, |_| 1),
186        )?;
187        if let Some(value) = &self.disruption_mode {
188            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionMode", value)?;
189        }
190        if let Some(value) = &self.parent_composite_pod_group_name {
191            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "parentCompositePodGroupName", value)?;
192        }
193        if let Some(value) = &self.preemption_policy {
194            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
195        }
196        if let Some(value) = &self.priority {
197            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
198        }
199        if let Some(value) = &self.priority_class_name {
200            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
201        }
202        if let Some(value) = &self.resource_claims {
203            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaims", value)?;
204        }
205        if let Some(value) = &self.scheduling_constraints {
206            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingConstraints", value)?;
207        }
208        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingPolicy", &self.scheduling_policy)?;
209        if let Some(value) = &self.workload_ref {
210            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "workloadRef", value)?;
211        }
212        crate::serde::ser::SerializeStruct::end(state)
213    }
214}
215
216#[cfg(feature = "schemars")]
217impl crate::schemars::JsonSchema for PodGroupSpec {
218    fn schema_name() -> std::borrow::Cow<'static, str> {
219        "io.k8s.api.scheduling.v1beta1.PodGroupSpec".into()
220    }
221
222    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
223        crate::schemars::json_schema!({
224            "description": "PodGroupSpec defines the desired state of a PodGroup.",
225            "type": "object",
226            "properties": {
227                "disruptionMode": ({
228                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::DisruptionMode>();
229                    schema_obj.ensure_object().insert("description".into(), "disruptionMode defines the mode in which a given PodGroup can be disrupted. Controllers are expected to fill this field by copying it from a PodGroupTemplate. One of Single, All. Defaults to Single if unset. This field is immutable.".into());
230                    schema_obj
231                }),
232                "parentCompositePodGroupName": {
233                    "description": "parentCompositePodGroupName contains the name of the parent composite pod group within the same namespace as this pod group. If it's nil, then this pod group is a root of a workload's hierarchy. This field is used only when the CompositePodGroup feature gate is enabled. This field is immutable.",
234                    "type": "string",
235                },
236                "preemptionPolicy": {
237                    "description": "preemptionPolicy is the Policy for preempting pods/podgroups with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. When Priority Admission Controller is enabled, it populates this field from PriorityClassName, and defaults to PreemptLowerPriority if value is unset in PriorityClass. This field is immutable. This field is available only when the PodGroupPreemptionPolicy feature gate is enabled.",
238                    "type": "string",
239                },
240                "priority": {
241                    "description": "priority is the value of priority of this pod group. Various system components use this field to find the priority of the pod group. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. This field is immutable.",
242                    "type": "integer",
243                    "format": "int32",
244                },
245                "priorityClassName": {
246                    "description": "priorityClassName defines the priority that should be considered when scheduling this pod group. Controllers are expected to fill this field by copying it from a PodGroupTemplate. Otherwise, it is validated and resolved similarly to the PriorityClassName on PodGroupTemplate (i.e. if no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, the pod group's priority will be zero). This field is immutable.",
247                    "type": "string",
248                },
249                "resourceClaims": {
250                    "description": "resourceClaims defines which ResourceClaims may be shared among Pods in the group. Pods consume the devices allocated to a PodGroup's claim by defining a claim in its own Spec.ResourceClaims that matches the PodGroup's claim exactly. The claim must have the same name and refer to the same ResourceClaim or ResourceClaimTemplate.\n\nThis is a beta-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.\n\nThis field is immutable.",
251                    "type": "array",
252                    "items": (__gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupResourceClaim>()),
253                },
254                "schedulingConstraints": ({
255                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupSchedulingConstraints>();
256                    schema_obj.ensure_object().insert("description".into(), "schedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroup. Controllers are expected to fill this field by copying it from a PodGroupTemplate. This field is immutable. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.".into());
257                    schema_obj
258                }),
259                "schedulingPolicy": ({
260                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::PodGroupSchedulingPolicy>();
261                    schema_obj.ensure_object().insert("description".into(), "schedulingPolicy defines the scheduling policy for this instance of the PodGroup. Controllers are expected to fill this field by copying it from a PodGroupTemplate.".into());
262                    schema_obj
263                }),
264                "workloadRef": ({
265                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1beta1::WorkloadReference>();
266                    schema_obj.ensure_object().insert("description".into(), "workloadRef references an optional PodGroup template within the Workload object that was used to create the PodGroup. This field is immutable.".into());
267                    schema_obj
268                }),
269            },
270            "required": [
271                "schedulingPolicy",
272            ],
273        })
274    }
275}