Skip to main content

k8s_openapi/v1_37/api/resource/v1alpha3/
pool_status.rs

1// Generated from definition io.k8s.api.resource.v1alpha3.PoolStatus
2
3/// PoolStatus contains status information for a single resource pool.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PoolStatus {
6    /// AllocatedDevices is the number of devices currently allocated to claims. A value of 0 means no devices are allocated. May be unset when validationError is set.
7    pub allocated_devices: Option<i32>,
8
9    /// AvailableDevices is the number of devices available for allocation. This equals TotalDevices - AllocatedDevices - UnavailableDevices. A value of 0 means no devices are currently available. May be unset when validationError is set.
10    pub available_devices: Option<i32>,
11
12    /// Driver is the DRA driver name for this pool. Must be a DNS subdomain (e.g., "gpu.example.com").
13    pub driver: std::string::String,
14
15    /// Generation is the pool generation observed across all ResourceSlices in this pool. Only the latest generation is reported. During a generation rollout, if not all slices at the latest generation have been published, the pool is included with a validationError and device counts unset.
16    pub generation: i64,
17
18    /// NodeName is the node this pool is associated with. When omitted, the pool is not associated with a specific node. Must be a valid DNS subdomain name (RFC1123).
19    pub node_name: Option<std::string::String>,
20
21    /// PartitionSummary reports allocatability per (attribute, partition type) for a partitionable pool that publishes SharedCounters. Each entry names the grouping attribute it was resolved from: the PartitionTypeAttribute declared by a device's own slice, or for devices whose slice declares none, the default named in the request. A pool that mixes partitions declared under different attributes reports each independently. When no slice declares an attribute and the request names no default, the pool reports no partition summary.
22    pub partition_summary: Option<std::vec::Vec<crate::api::resource::v1alpha3::PartitionTypeStatus>>,
23
24    /// PoolName is the name of the pool. Must be a valid resource pool name (DNS subdomains separated by "/").
25    pub pool_name: std::string::String,
26
27    /// ResourceSliceCount is the number of ResourceSlices that make up this pool. May be unset when validationError is set.
28    pub resource_slice_count: Option<i32>,
29
30    /// ShareableSummary reports aggregate capacity for a pool that contains devices with AllowMultipleAllocations. It is populated only when at least one device in the pool is shareable.
31    pub shareable_summary: Option<crate::api::resource::v1alpha3::ShareableSummaryStatus>,
32
33    /// TotalDevices is the total number of devices in the pool across all slices. A value of 0 means the pool has no devices. May be unset when validationError is set.
34    pub total_devices: Option<i32>,
35
36    /// UnavailableDevices is the number of devices that are not available due to taints or other conditions, but are not allocated. A value of 0 means all unallocated devices are available. May be unset when validationError is set.
37    pub unavailable_devices: Option<i32>,
38
39    /// ValidationError is set when the pool's data could not be fully validated (e.g., incomplete slice publication). When set, device count fields and ResourceSliceCount may be unset.
40    pub validation_error: Option<std::string::String>,
41}
42
43impl crate::DeepMerge for PoolStatus {
44    fn merge_from(&mut self, other: Self) {
45        crate::DeepMerge::merge_from(&mut self.allocated_devices, other.allocated_devices);
46        crate::DeepMerge::merge_from(&mut self.available_devices, other.available_devices);
47        crate::DeepMerge::merge_from(&mut self.driver, other.driver);
48        crate::DeepMerge::merge_from(&mut self.generation, other.generation);
49        crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
50        crate::merge_strategies::list::atomic(&mut self.partition_summary, other.partition_summary);
51        crate::DeepMerge::merge_from(&mut self.pool_name, other.pool_name);
52        crate::DeepMerge::merge_from(&mut self.resource_slice_count, other.resource_slice_count);
53        crate::DeepMerge::merge_from(&mut self.shareable_summary, other.shareable_summary);
54        crate::DeepMerge::merge_from(&mut self.total_devices, other.total_devices);
55        crate::DeepMerge::merge_from(&mut self.unavailable_devices, other.unavailable_devices);
56        crate::DeepMerge::merge_from(&mut self.validation_error, other.validation_error);
57    }
58}
59
60impl<'de> crate::serde::Deserialize<'de> for PoolStatus {
61    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
62        #[allow(non_camel_case_types)]
63        enum Field {
64            Key_allocated_devices,
65            Key_available_devices,
66            Key_driver,
67            Key_generation,
68            Key_node_name,
69            Key_partition_summary,
70            Key_pool_name,
71            Key_resource_slice_count,
72            Key_shareable_summary,
73            Key_total_devices,
74            Key_unavailable_devices,
75            Key_validation_error,
76            Other,
77        }
78
79        impl<'de> crate::serde::Deserialize<'de> for Field {
80            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
81                struct Visitor;
82
83                impl crate::serde::de::Visitor<'_> for Visitor {
84                    type Value = Field;
85
86                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
87                        f.write_str("field identifier")
88                    }
89
90                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
91                        Ok(match v {
92                            "allocatedDevices" => Field::Key_allocated_devices,
93                            "availableDevices" => Field::Key_available_devices,
94                            "driver" => Field::Key_driver,
95                            "generation" => Field::Key_generation,
96                            "nodeName" => Field::Key_node_name,
97                            "partitionSummary" => Field::Key_partition_summary,
98                            "poolName" => Field::Key_pool_name,
99                            "resourceSliceCount" => Field::Key_resource_slice_count,
100                            "shareableSummary" => Field::Key_shareable_summary,
101                            "totalDevices" => Field::Key_total_devices,
102                            "unavailableDevices" => Field::Key_unavailable_devices,
103                            "validationError" => Field::Key_validation_error,
104                            _ => Field::Other,
105                        })
106                    }
107                }
108
109                deserializer.deserialize_identifier(Visitor)
110            }
111        }
112
113        struct Visitor;
114
115        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
116            type Value = PoolStatus;
117
118            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
119                f.write_str("PoolStatus")
120            }
121
122            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
123                let mut value_allocated_devices: Option<i32> = None;
124                let mut value_available_devices: Option<i32> = None;
125                let mut value_driver: Option<std::string::String> = None;
126                let mut value_generation: Option<i64> = None;
127                let mut value_node_name: Option<std::string::String> = None;
128                let mut value_partition_summary: Option<std::vec::Vec<crate::api::resource::v1alpha3::PartitionTypeStatus>> = None;
129                let mut value_pool_name: Option<std::string::String> = None;
130                let mut value_resource_slice_count: Option<i32> = None;
131                let mut value_shareable_summary: Option<crate::api::resource::v1alpha3::ShareableSummaryStatus> = None;
132                let mut value_total_devices: Option<i32> = None;
133                let mut value_unavailable_devices: Option<i32> = None;
134                let mut value_validation_error: Option<std::string::String> = None;
135
136                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
137                    match key {
138                        Field::Key_allocated_devices => value_allocated_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
139                        Field::Key_available_devices => value_available_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
140                        Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
141                        Field::Key_generation => value_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
142                        Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
143                        Field::Key_partition_summary => value_partition_summary = crate::serde::de::MapAccess::next_value(&mut map)?,
144                        Field::Key_pool_name => value_pool_name = crate::serde::de::MapAccess::next_value(&mut map)?,
145                        Field::Key_resource_slice_count => value_resource_slice_count = crate::serde::de::MapAccess::next_value(&mut map)?,
146                        Field::Key_shareable_summary => value_shareable_summary = crate::serde::de::MapAccess::next_value(&mut map)?,
147                        Field::Key_total_devices => value_total_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
148                        Field::Key_unavailable_devices => value_unavailable_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
149                        Field::Key_validation_error => value_validation_error = crate::serde::de::MapAccess::next_value(&mut map)?,
150                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
151                    }
152                }
153
154                Ok(PoolStatus {
155                    allocated_devices: value_allocated_devices,
156                    available_devices: value_available_devices,
157                    driver: value_driver.unwrap_or_default(),
158                    generation: value_generation.unwrap_or_default(),
159                    node_name: value_node_name,
160                    partition_summary: value_partition_summary,
161                    pool_name: value_pool_name.unwrap_or_default(),
162                    resource_slice_count: value_resource_slice_count,
163                    shareable_summary: value_shareable_summary,
164                    total_devices: value_total_devices,
165                    unavailable_devices: value_unavailable_devices,
166                    validation_error: value_validation_error,
167                })
168            }
169        }
170
171        deserializer.deserialize_struct(
172            "PoolStatus",
173            &[
174                "allocatedDevices",
175                "availableDevices",
176                "driver",
177                "generation",
178                "nodeName",
179                "partitionSummary",
180                "poolName",
181                "resourceSliceCount",
182                "shareableSummary",
183                "totalDevices",
184                "unavailableDevices",
185                "validationError",
186            ],
187            Visitor,
188        )
189    }
190}
191
192impl crate::serde::Serialize for PoolStatus {
193    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
194        let mut state = serializer.serialize_struct(
195            "PoolStatus",
196            3 +
197            self.allocated_devices.as_ref().map_or(0, |_| 1) +
198            self.available_devices.as_ref().map_or(0, |_| 1) +
199            self.node_name.as_ref().map_or(0, |_| 1) +
200            self.partition_summary.as_ref().map_or(0, |_| 1) +
201            self.resource_slice_count.as_ref().map_or(0, |_| 1) +
202            self.shareable_summary.as_ref().map_or(0, |_| 1) +
203            self.total_devices.as_ref().map_or(0, |_| 1) +
204            self.unavailable_devices.as_ref().map_or(0, |_| 1) +
205            self.validation_error.as_ref().map_or(0, |_| 1),
206        )?;
207        if let Some(value) = &self.allocated_devices {
208            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatedDevices", value)?;
209        }
210        if let Some(value) = &self.available_devices {
211            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableDevices", value)?;
212        }
213        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
214        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "generation", &self.generation)?;
215        if let Some(value) = &self.node_name {
216            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", value)?;
217        }
218        if let Some(value) = &self.partition_summary {
219            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "partitionSummary", value)?;
220        }
221        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "poolName", &self.pool_name)?;
222        if let Some(value) = &self.resource_slice_count {
223            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceSliceCount", value)?;
224        }
225        if let Some(value) = &self.shareable_summary {
226            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "shareableSummary", value)?;
227        }
228        if let Some(value) = &self.total_devices {
229            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "totalDevices", value)?;
230        }
231        if let Some(value) = &self.unavailable_devices {
232            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unavailableDevices", value)?;
233        }
234        if let Some(value) = &self.validation_error {
235            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "validationError", value)?;
236        }
237        crate::serde::ser::SerializeStruct::end(state)
238    }
239}
240
241#[cfg(feature = "schemars")]
242impl crate::schemars::JsonSchema for PoolStatus {
243    fn schema_name() -> std::borrow::Cow<'static, str> {
244        "io.k8s.api.resource.v1alpha3.PoolStatus".into()
245    }
246
247    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
248        crate::schemars::json_schema!({
249            "description": "PoolStatus contains status information for a single resource pool.",
250            "type": "object",
251            "properties": {
252                "allocatedDevices": {
253                    "description": "AllocatedDevices is the number of devices currently allocated to claims. A value of 0 means no devices are allocated. May be unset when validationError is set.",
254                    "type": "integer",
255                    "format": "int32",
256                },
257                "availableDevices": {
258                    "description": "AvailableDevices is the number of devices available for allocation. This equals TotalDevices - AllocatedDevices - UnavailableDevices. A value of 0 means no devices are currently available. May be unset when validationError is set.",
259                    "type": "integer",
260                    "format": "int32",
261                },
262                "driver": {
263                    "description": "Driver is the DRA driver name for this pool. Must be a DNS subdomain (e.g., \"gpu.example.com\").",
264                    "type": "string",
265                },
266                "generation": {
267                    "description": "Generation is the pool generation observed across all ResourceSlices in this pool. Only the latest generation is reported. During a generation rollout, if not all slices at the latest generation have been published, the pool is included with a validationError and device counts unset.",
268                    "type": "integer",
269                    "format": "int64",
270                },
271                "nodeName": {
272                    "description": "NodeName is the node this pool is associated with. When omitted, the pool is not associated with a specific node. Must be a valid DNS subdomain name (RFC1123).",
273                    "type": "string",
274                },
275                "partitionSummary": {
276                    "description": "PartitionSummary reports allocatability per (attribute, partition type) for a partitionable pool that publishes SharedCounters. Each entry names the grouping attribute it was resolved from: the PartitionTypeAttribute declared by a device's own slice, or for devices whose slice declares none, the default named in the request. A pool that mixes partitions declared under different attributes reports each independently. When no slice declares an attribute and the request names no default, the pool reports no partition summary.",
277                    "type": "array",
278                    "items": (__gen.subschema_for::<crate::api::resource::v1alpha3::PartitionTypeStatus>()),
279                },
280                "poolName": {
281                    "description": "PoolName is the name of the pool. Must be a valid resource pool name (DNS subdomains separated by \"/\").",
282                    "type": "string",
283                },
284                "resourceSliceCount": {
285                    "description": "ResourceSliceCount is the number of ResourceSlices that make up this pool. May be unset when validationError is set.",
286                    "type": "integer",
287                    "format": "int32",
288                },
289                "shareableSummary": ({
290                    let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1alpha3::ShareableSummaryStatus>();
291                    schema_obj.ensure_object().insert("description".into(), "ShareableSummary reports aggregate capacity for a pool that contains devices with AllowMultipleAllocations. It is populated only when at least one device in the pool is shareable.".into());
292                    schema_obj
293                }),
294                "totalDevices": {
295                    "description": "TotalDevices is the total number of devices in the pool across all slices. A value of 0 means the pool has no devices. May be unset when validationError is set.",
296                    "type": "integer",
297                    "format": "int32",
298                },
299                "unavailableDevices": {
300                    "description": "UnavailableDevices is the number of devices that are not available due to taints or other conditions, but are not allocated. A value of 0 means all unallocated devices are available. May be unset when validationError is set.",
301                    "type": "integer",
302                    "format": "int32",
303                },
304                "validationError": {
305                    "description": "ValidationError is set when the pool's data could not be fully validated (e.g., incomplete slice publication). When set, device count fields and ResourceSliceCount may be unset.",
306                    "type": "string",
307                },
308            },
309            "required": [
310                "driver",
311                "generation",
312                "poolName",
313            ],
314        })
315    }
316}