k8s_openapi/v1_30/api/core/v1/
persistent_volume_claim_status.rs

1// Generated from definition io.k8s.api.core.v1.PersistentVolumeClaimStatus
2
3/// PersistentVolumeClaimStatus is the current status of a persistent volume claim.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PersistentVolumeClaimStatus {
6    /// accessModes contains the actual access modes the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1
7    pub access_modes: Option<Vec<String>>,
8
9    /// allocatedResourceStatuses stores status of resource being resized for the given PVC. Key names follow standard Kubernetes label syntax. Valid values are either:
10    ///     * Un-prefixed keys:
11    ///         - storage - the capacity of the volume.
12    ///     * Custom resources must use implementation-defined prefixed names such as "example.com/my-custom-resource"
13    /// Apart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.
14    ///
15    /// ClaimResourceStatus can be in any of following states:
16    ///     - ControllerResizeInProgress:
17    ///         State set when resize controller starts resizing the volume in control-plane.
18    ///     - ControllerResizeFailed:
19    ///         State set when resize has failed in resize controller with a terminal error.
20    ///     - NodeResizePending:
21    ///         State set when resize controller has finished resizing the volume but further resizing of
22    ///         volume is needed on the node.
23    ///     - NodeResizeInProgress:
24    ///         State set when kubelet starts resizing the volume.
25    ///     - NodeResizeFailed:
26    ///         State set when resizing has failed in kubelet with a terminal error. Transient errors don't set
27    ///         NodeResizeFailed.
28    /// For example: if expanding a PVC for more capacity - this field can be one of the following states:
29    ///     - pvc.status.allocatedResourceStatus\['storage'\] = "ControllerResizeInProgress"
30    ///      - pvc.status.allocatedResourceStatus\['storage'\] = "ControllerResizeFailed"
31    ///      - pvc.status.allocatedResourceStatus\['storage'\] = "NodeResizePending"
32    ///      - pvc.status.allocatedResourceStatus\['storage'\] = "NodeResizeInProgress"
33    ///      - pvc.status.allocatedResourceStatus\['storage'\] = "NodeResizeFailed"
34    /// When this field is not set, it means that no resize operation is in progress for the given PVC.
35    ///
36    /// A controller that receives PVC update with previously unknown resourceName or ClaimResourceStatus should ignore the update for the purpose it was designed. For example - a controller that only is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid resources associated with PVC.
37    ///
38    /// This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.
39    pub allocated_resource_statuses: Option<std::collections::BTreeMap<String, String>>,
40
41    /// allocatedResources tracks the resources allocated to a PVC including its capacity. Key names follow standard Kubernetes label syntax. Valid values are either:
42    ///     * Un-prefixed keys:
43    ///         - storage - the capacity of the volume.
44    ///     * Custom resources must use implementation-defined prefixed names such as "example.com/my-custom-resource"
45    /// Apart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.
46    ///
47    /// Capacity reported here may be larger than the actual capacity when a volume expansion operation is requested. For storage quota, the larger value from allocatedResources and PVC.spec.resources is used. If allocatedResources is not set, PVC.spec.resources alone is used for quota calculation. If a volume expansion capacity request is lowered, allocatedResources is only lowered if there are no expansion operations in progress and if the actual volume capacity is equal or lower than the requested capacity.
48    ///
49    /// A controller that receives PVC update with previously unknown resourceName should ignore the update for the purpose it was designed. For example - a controller that only is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid resources associated with PVC.
50    ///
51    /// This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.
52    pub allocated_resources: Option<std::collections::BTreeMap<String, crate::apimachinery::pkg::api::resource::Quantity>>,
53
54    /// capacity represents the actual resources of the underlying volume.
55    pub capacity: Option<std::collections::BTreeMap<String, crate::apimachinery::pkg::api::resource::Quantity>>,
56
57    /// conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'Resizing'.
58    pub conditions: Option<Vec<crate::api::core::v1::PersistentVolumeClaimCondition>>,
59
60    /// currentVolumeAttributesClassName is the current name of the VolumeAttributesClass the PVC is using. When unset, there is no VolumeAttributeClass applied to this PersistentVolumeClaim This is an alpha field and requires enabling VolumeAttributesClass feature.
61    pub current_volume_attributes_class_name: Option<String>,
62
63    /// ModifyVolumeStatus represents the status object of ControllerModifyVolume operation. When this is unset, there is no ModifyVolume operation being attempted. This is an alpha field and requires enabling VolumeAttributesClass feature.
64    pub modify_volume_status: Option<crate::api::core::v1::ModifyVolumeStatus>,
65
66    /// phase represents the current phase of PersistentVolumeClaim.
67    pub phase: Option<String>,
68}
69
70impl crate::DeepMerge for PersistentVolumeClaimStatus {
71    fn merge_from(&mut self, other: Self) {
72        crate::merge_strategies::list::atomic(&mut self.access_modes, other.access_modes);
73        crate::merge_strategies::map::granular(&mut self.allocated_resource_statuses, other.allocated_resource_statuses, |current_item, other_item| {
74            crate::DeepMerge::merge_from(current_item, other_item);
75        });
76        crate::merge_strategies::map::granular(&mut self.allocated_resources, other.allocated_resources, |current_item, other_item| {
77            crate::DeepMerge::merge_from(current_item, other_item);
78        });
79        crate::merge_strategies::map::granular(&mut self.capacity, other.capacity, |current_item, other_item| {
80            crate::DeepMerge::merge_from(current_item, other_item);
81        });
82        crate::merge_strategies::list::map(
83            &mut self.conditions,
84            other.conditions,
85            &[|lhs, rhs| lhs.type_ == rhs.type_],
86            |current_item, other_item| {
87                crate::DeepMerge::merge_from(current_item, other_item);
88            },
89        );
90        crate::DeepMerge::merge_from(&mut self.current_volume_attributes_class_name, other.current_volume_attributes_class_name);
91        crate::DeepMerge::merge_from(&mut self.modify_volume_status, other.modify_volume_status);
92        crate::DeepMerge::merge_from(&mut self.phase, other.phase);
93    }
94}
95
96impl<'de> crate::serde::Deserialize<'de> for PersistentVolumeClaimStatus {
97    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
98        #[allow(non_camel_case_types)]
99        enum Field {
100            Key_access_modes,
101            Key_allocated_resource_statuses,
102            Key_allocated_resources,
103            Key_capacity,
104            Key_conditions,
105            Key_current_volume_attributes_class_name,
106            Key_modify_volume_status,
107            Key_phase,
108            Other,
109        }
110
111        impl<'de> crate::serde::Deserialize<'de> for Field {
112            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
113                struct Visitor;
114
115                impl crate::serde::de::Visitor<'_> for Visitor {
116                    type Value = Field;
117
118                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
119                        f.write_str("field identifier")
120                    }
121
122                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
123                        Ok(match v {
124                            "accessModes" => Field::Key_access_modes,
125                            "allocatedResourceStatuses" => Field::Key_allocated_resource_statuses,
126                            "allocatedResources" => Field::Key_allocated_resources,
127                            "capacity" => Field::Key_capacity,
128                            "conditions" => Field::Key_conditions,
129                            "currentVolumeAttributesClassName" => Field::Key_current_volume_attributes_class_name,
130                            "modifyVolumeStatus" => Field::Key_modify_volume_status,
131                            "phase" => Field::Key_phase,
132                            _ => Field::Other,
133                        })
134                    }
135                }
136
137                deserializer.deserialize_identifier(Visitor)
138            }
139        }
140
141        struct Visitor;
142
143        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
144            type Value = PersistentVolumeClaimStatus;
145
146            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
147                f.write_str("PersistentVolumeClaimStatus")
148            }
149
150            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
151                let mut value_access_modes: Option<Vec<String>> = None;
152                let mut value_allocated_resource_statuses: Option<std::collections::BTreeMap<String, String>> = None;
153                let mut value_allocated_resources: Option<std::collections::BTreeMap<String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
154                let mut value_capacity: Option<std::collections::BTreeMap<String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
155                let mut value_conditions: Option<Vec<crate::api::core::v1::PersistentVolumeClaimCondition>> = None;
156                let mut value_current_volume_attributes_class_name: Option<String> = None;
157                let mut value_modify_volume_status: Option<crate::api::core::v1::ModifyVolumeStatus> = None;
158                let mut value_phase: Option<String> = None;
159
160                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
161                    match key {
162                        Field::Key_access_modes => value_access_modes = crate::serde::de::MapAccess::next_value(&mut map)?,
163                        Field::Key_allocated_resource_statuses => value_allocated_resource_statuses = crate::serde::de::MapAccess::next_value(&mut map)?,
164                        Field::Key_allocated_resources => value_allocated_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
165                        Field::Key_capacity => value_capacity = crate::serde::de::MapAccess::next_value(&mut map)?,
166                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
167                        Field::Key_current_volume_attributes_class_name => value_current_volume_attributes_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
168                        Field::Key_modify_volume_status => value_modify_volume_status = crate::serde::de::MapAccess::next_value(&mut map)?,
169                        Field::Key_phase => value_phase = crate::serde::de::MapAccess::next_value(&mut map)?,
170                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
171                    }
172                }
173
174                Ok(PersistentVolumeClaimStatus {
175                    access_modes: value_access_modes,
176                    allocated_resource_statuses: value_allocated_resource_statuses,
177                    allocated_resources: value_allocated_resources,
178                    capacity: value_capacity,
179                    conditions: value_conditions,
180                    current_volume_attributes_class_name: value_current_volume_attributes_class_name,
181                    modify_volume_status: value_modify_volume_status,
182                    phase: value_phase,
183                })
184            }
185        }
186
187        deserializer.deserialize_struct(
188            "PersistentVolumeClaimStatus",
189            &[
190                "accessModes",
191                "allocatedResourceStatuses",
192                "allocatedResources",
193                "capacity",
194                "conditions",
195                "currentVolumeAttributesClassName",
196                "modifyVolumeStatus",
197                "phase",
198            ],
199            Visitor,
200        )
201    }
202}
203
204impl crate::serde::Serialize for PersistentVolumeClaimStatus {
205    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
206        let mut state = serializer.serialize_struct(
207            "PersistentVolumeClaimStatus",
208            self.access_modes.as_ref().map_or(0, |_| 1) +
209            self.allocated_resource_statuses.as_ref().map_or(0, |_| 1) +
210            self.allocated_resources.as_ref().map_or(0, |_| 1) +
211            self.capacity.as_ref().map_or(0, |_| 1) +
212            self.conditions.as_ref().map_or(0, |_| 1) +
213            self.current_volume_attributes_class_name.as_ref().map_or(0, |_| 1) +
214            self.modify_volume_status.as_ref().map_or(0, |_| 1) +
215            self.phase.as_ref().map_or(0, |_| 1),
216        )?;
217        if let Some(value) = &self.access_modes {
218            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "accessModes", value)?;
219        }
220        if let Some(value) = &self.allocated_resource_statuses {
221            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatedResourceStatuses", value)?;
222        }
223        if let Some(value) = &self.allocated_resources {
224            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatedResources", value)?;
225        }
226        if let Some(value) = &self.capacity {
227            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "capacity", value)?;
228        }
229        if let Some(value) = &self.conditions {
230            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
231        }
232        if let Some(value) = &self.current_volume_attributes_class_name {
233            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "currentVolumeAttributesClassName", value)?;
234        }
235        if let Some(value) = &self.modify_volume_status {
236            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "modifyVolumeStatus", value)?;
237        }
238        if let Some(value) = &self.phase {
239            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "phase", value)?;
240        }
241        crate::serde::ser::SerializeStruct::end(state)
242    }
243}
244
245#[cfg(feature = "schemars")]
246impl crate::schemars::JsonSchema for PersistentVolumeClaimStatus {
247    fn schema_name() -> String {
248        "io.k8s.api.core.v1.PersistentVolumeClaimStatus".to_owned()
249    }
250
251    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
252        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
253            metadata: Some(Box::new(crate::schemars::schema::Metadata {
254                description: Some("PersistentVolumeClaimStatus is the current status of a persistent volume claim.".to_owned()),
255                ..Default::default()
256            })),
257            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
258            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
259                properties: [
260                    (
261                        "accessModes".to_owned(),
262                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
263                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
264                                description: Some("accessModes contains the actual access modes the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1".to_owned()),
265                                ..Default::default()
266                            })),
267                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
268                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
269                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
270                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
271                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
272                                        ..Default::default()
273                                    })
274                                ))),
275                                ..Default::default()
276                            })),
277                            ..Default::default()
278                        }),
279                    ),
280                    (
281                        "allocatedResourceStatuses".to_owned(),
282                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
283                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
284                                description: Some("allocatedResourceStatuses stores status of resource being resized for the given PVC. Key names follow standard Kubernetes label syntax. Valid values are either:\n\t* Un-prefixed keys:\n\t\t- storage - the capacity of the volume.\n\t* Custom resources must use implementation-defined prefixed names such as \"example.com/my-custom-resource\"\nApart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.\n\nClaimResourceStatus can be in any of following states:\n\t- ControllerResizeInProgress:\n\t\tState set when resize controller starts resizing the volume in control-plane.\n\t- ControllerResizeFailed:\n\t\tState set when resize has failed in resize controller with a terminal error.\n\t- NodeResizePending:\n\t\tState set when resize controller has finished resizing the volume but further resizing of\n\t\tvolume is needed on the node.\n\t- NodeResizeInProgress:\n\t\tState set when kubelet starts resizing the volume.\n\t- NodeResizeFailed:\n\t\tState set when resizing has failed in kubelet with a terminal error. Transient errors don't set\n\t\tNodeResizeFailed.\nFor example: if expanding a PVC for more capacity - this field can be one of the following states:\n\t- pvc.status.allocatedResourceStatus['storage'] = \"ControllerResizeInProgress\"\n     - pvc.status.allocatedResourceStatus['storage'] = \"ControllerResizeFailed\"\n     - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizePending\"\n     - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizeInProgress\"\n     - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizeFailed\"\nWhen this field is not set, it means that no resize operation is in progress for the given PVC.\n\nA controller that receives PVC update with previously unknown resourceName or ClaimResourceStatus should ignore the update for the purpose it was designed. For example - a controller that only is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid resources associated with PVC.\n\nThis is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.".to_owned()),
285                                ..Default::default()
286                            })),
287                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
288                            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
289                                additional_properties: Some(Box::new(
290                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
291                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
292                                        ..Default::default()
293                                    })
294                                )),
295                                ..Default::default()
296                            })),
297                            ..Default::default()
298                        }),
299                    ),
300                    (
301                        "allocatedResources".to_owned(),
302                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
303                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
304                                description: Some("allocatedResources tracks the resources allocated to a PVC including its capacity. Key names follow standard Kubernetes label syntax. Valid values are either:\n\t* Un-prefixed keys:\n\t\t- storage - the capacity of the volume.\n\t* Custom resources must use implementation-defined prefixed names such as \"example.com/my-custom-resource\"\nApart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.\n\nCapacity reported here may be larger than the actual capacity when a volume expansion operation is requested. For storage quota, the larger value from allocatedResources and PVC.spec.resources is used. If allocatedResources is not set, PVC.spec.resources alone is used for quota calculation. If a volume expansion capacity request is lowered, allocatedResources is only lowered if there are no expansion operations in progress and if the actual volume capacity is equal or lower than the requested capacity.\n\nA controller that receives PVC update with previously unknown resourceName should ignore the update for the purpose it was designed. For example - a controller that only is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid resources associated with PVC.\n\nThis is an alpha field and requires enabling RecoverVolumeExpansionFailure feature.".to_owned()),
305                                ..Default::default()
306                            })),
307                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
308                            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
309                                additional_properties: Some(Box::new(__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>())),
310                                ..Default::default()
311                            })),
312                            ..Default::default()
313                        }),
314                    ),
315                    (
316                        "capacity".to_owned(),
317                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
318                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
319                                description: Some("capacity represents the actual resources of the underlying volume.".to_owned()),
320                                ..Default::default()
321                            })),
322                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
323                            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
324                                additional_properties: Some(Box::new(__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>())),
325                                ..Default::default()
326                            })),
327                            ..Default::default()
328                        }),
329                    ),
330                    (
331                        "conditions".to_owned(),
332                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
333                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
334                                description: Some("conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'Resizing'.".to_owned()),
335                                ..Default::default()
336                            })),
337                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
338                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
339                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::PersistentVolumeClaimCondition>()))),
340                                ..Default::default()
341                            })),
342                            ..Default::default()
343                        }),
344                    ),
345                    (
346                        "currentVolumeAttributesClassName".to_owned(),
347                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
348                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
349                                description: Some("currentVolumeAttributesClassName is the current name of the VolumeAttributesClass the PVC is using. When unset, there is no VolumeAttributeClass applied to this PersistentVolumeClaim This is an alpha field and requires enabling VolumeAttributesClass feature.".to_owned()),
350                                ..Default::default()
351                            })),
352                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
353                            ..Default::default()
354                        }),
355                    ),
356                    (
357                        "modifyVolumeStatus".to_owned(),
358                        {
359                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ModifyVolumeStatus>().into_object();
360                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
361                                description: Some("ModifyVolumeStatus represents the status object of ControllerModifyVolume operation. When this is unset, there is no ModifyVolume operation being attempted. This is an alpha field and requires enabling VolumeAttributesClass feature.".to_owned()),
362                                ..Default::default()
363                            }));
364                            crate::schemars::schema::Schema::Object(schema_obj)
365                        },
366                    ),
367                    (
368                        "phase".to_owned(),
369                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
370                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
371                                description: Some("phase represents the current phase of PersistentVolumeClaim.".to_owned()),
372                                ..Default::default()
373                            })),
374                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
375                            ..Default::default()
376                        }),
377                    ),
378                ].into(),
379                ..Default::default()
380            })),
381            ..Default::default()
382        })
383    }
384}