#
k8s_openapi/v1_35/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<std::vec::Vec<std::string::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    pub allocated_resource_statuses: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
    38
    39    /// allocatedResources tracks the resources allocated to a PVC including its capacity. Key names follow standard Kubernetes label syntax. Valid values are either:
    40    ///     * Un-prefixed keys:
    41    ///         - storage - the capacity of the volume.
    42    ///     * Custom resources must use implementation-defined prefixed names such as "example.com/my-custom-resource"
    43    /// Apart from above values - keys that are unprefixed or have kubernetes.io prefix are considered reserved and hence may not be used.
    44    ///
    45    /// 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.
    46    ///
    47    /// 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.
    48    pub allocated_resources: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>>,
    49
    50    /// capacity represents the actual resources of the underlying volume.
    51    pub capacity: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>>,
    52
    53    /// conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'Resizing'.
    54    pub conditions: Option<std::vec::Vec<crate::api::core::v1::PersistentVolumeClaimCondition>>,
    55
    56    /// currentVolumeAttributesClassName is the current name of the VolumeAttributesClass the PVC is using. When unset, there is no VolumeAttributeClass applied to this PersistentVolumeClaim
    57    pub current_volume_attributes_class_name: Option<std::string::String>,
    58
    59    /// ModifyVolumeStatus represents the status object of ControllerModifyVolume operation. When this is unset, there is no ModifyVolume operation being attempted.
    60    pub modify_volume_status: Option<crate::api::core::v1::ModifyVolumeStatus>,
    61
    62    /// phase represents the current phase of PersistentVolumeClaim.
    63    pub phase: Option<std::string::String>,
    64}
    65
    66impl crate::DeepMerge for PersistentVolumeClaimStatus {
    67    fn merge_from(&mut self, other: Self) {
    68        crate::merge_strategies::list::atomic(&mut self.access_modes, other.access_modes);
    69        crate::merge_strategies::map::granular(&mut self.allocated_resource_statuses, other.allocated_resource_statuses, |current_item, other_item| {
    70            crate::DeepMerge::merge_from(current_item, other_item);
    71        });
    72        crate::merge_strategies::map::granular(&mut self.allocated_resources, other.allocated_resources, |current_item, other_item| {
    73            crate::DeepMerge::merge_from(current_item, other_item);
    74        });
    75        crate::merge_strategies::map::granular(&mut self.capacity, other.capacity, |current_item, other_item| {
    76            crate::DeepMerge::merge_from(current_item, other_item);
    77        });
    78        crate::merge_strategies::list::map(
    79            &mut self.conditions,
    80            other.conditions,
    81            &[|lhs, rhs| lhs.type_ == rhs.type_],
    82            |current_item, other_item| {
    83                crate::DeepMerge::merge_from(current_item, other_item);
    84            },
    85        );
    86        crate::DeepMerge::merge_from(&mut self.current_volume_attributes_class_name, other.current_volume_attributes_class_name);
    87        crate::DeepMerge::merge_from(&mut self.modify_volume_status, other.modify_volume_status);
    88        crate::DeepMerge::merge_from(&mut self.phase, other.phase);
    89    }
    90}
    91
    92impl<'de> crate::serde::Deserialize<'de> for PersistentVolumeClaimStatus {
    93    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    94        #[allow(non_camel_case_types)]
    95        enum Field {
    96            Key_access_modes,
    97            Key_allocated_resource_statuses,
    98            Key_allocated_resources,
    99            Key_capacity,
    100            Key_conditions,
    101            Key_current_volume_attributes_class_name,
    102            Key_modify_volume_status,
    103            Key_phase,
    104            Other,
    105        }
    106
    107        impl<'de> crate::serde::Deserialize<'de> for Field {
    108            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    109                struct Visitor;
    110
    111                impl crate::serde::de::Visitor<'_> for Visitor {
    112                    type Value = Field;
    113
    114                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    115                        f.write_str("field identifier")
    116                    }
    117
    118                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    119                        Ok(match v {
    120                            "accessModes" => Field::Key_access_modes,
    121                            "allocatedResourceStatuses" => Field::Key_allocated_resource_statuses,
    122                            "allocatedResources" => Field::Key_allocated_resources,
    123                            "capacity" => Field::Key_capacity,
    124                            "conditions" => Field::Key_conditions,
    125                            "currentVolumeAttributesClassName" => Field::Key_current_volume_attributes_class_name,
    126                            "modifyVolumeStatus" => Field::Key_modify_volume_status,
    127                            "phase" => Field::Key_phase,
    128                            _ => Field::Other,
    129                        })
    130                    }
    131                }
    132
    133                deserializer.deserialize_identifier(Visitor)
    134            }
    135        }
    136
    137        struct Visitor;
    138
    139        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    140            type Value = PersistentVolumeClaimStatus;
    141
    142            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    143                f.write_str("PersistentVolumeClaimStatus")
    144            }
    145
    146            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    147                let mut value_access_modes: Option<std::vec::Vec<std::string::String>> = None;
    148                let mut value_allocated_resource_statuses: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
    149                let mut value_allocated_resources: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
    150                let mut value_capacity: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
    151                let mut value_conditions: Option<std::vec::Vec<crate::api::core::v1::PersistentVolumeClaimCondition>> = None;
    152                let mut value_current_volume_attributes_class_name: Option<std::string::String> = None;
    153                let mut value_modify_volume_status: Option<crate::api::core::v1::ModifyVolumeStatus> = None;
    154                let mut value_phase: Option<std::string::String> = None;
    155
    156                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    157                    match key {
    158                        Field::Key_access_modes => value_access_modes = crate::serde::de::MapAccess::next_value(&mut map)?,
    159                        Field::Key_allocated_resource_statuses => value_allocated_resource_statuses = crate::serde::de::MapAccess::next_value(&mut map)?,
    160                        Field::Key_allocated_resources => value_allocated_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
    161                        Field::Key_capacity => value_capacity = crate::serde::de::MapAccess::next_value(&mut map)?,
    162                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
    163                        Field::Key_current_volume_attributes_class_name => value_current_volume_attributes_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    164                        Field::Key_modify_volume_status => value_modify_volume_status = crate::serde::de::MapAccess::next_value(&mut map)?,
    165                        Field::Key_phase => value_phase = crate::serde::de::MapAccess::next_value(&mut map)?,
    166                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    167                    }
    168                }
    169
    170                Ok(PersistentVolumeClaimStatus {
    171                    access_modes: value_access_modes,
    172                    allocated_resource_statuses: value_allocated_resource_statuses,
    173                    allocated_resources: value_allocated_resources,
    174                    capacity: value_capacity,
    175                    conditions: value_conditions,
    176                    current_volume_attributes_class_name: value_current_volume_attributes_class_name,
    177                    modify_volume_status: value_modify_volume_status,
    178                    phase: value_phase,
    179                })
    180            }
    181        }
    182
    183        deserializer.deserialize_struct(
    184            "PersistentVolumeClaimStatus",
    185            &[
    186                "accessModes",
    187                "allocatedResourceStatuses",
    188                "allocatedResources",
    189                "capacity",
    190                "conditions",
    191                "currentVolumeAttributesClassName",
    192                "modifyVolumeStatus",
    193                "phase",
    194            ],
    195            Visitor,
    196        )
    197    }
    198}
    199
    200impl crate::serde::Serialize for PersistentVolumeClaimStatus {
    201    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    202        let mut state = serializer.serialize_struct(
    203            "PersistentVolumeClaimStatus",
    204            self.access_modes.as_ref().map_or(0, |_| 1) +
    205            self.allocated_resource_statuses.as_ref().map_or(0, |_| 1) +
    206            self.allocated_resources.as_ref().map_or(0, |_| 1) +
    207            self.capacity.as_ref().map_or(0, |_| 1) +
    208            self.conditions.as_ref().map_or(0, |_| 1) +
    209            self.current_volume_attributes_class_name.as_ref().map_or(0, |_| 1) +
    210            self.modify_volume_status.as_ref().map_or(0, |_| 1) +
    211            self.phase.as_ref().map_or(0, |_| 1),
    212        )?;
    213        if let Some(value) = &self.access_modes {
    214            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "accessModes", value)?;
    215        }
    216        if let Some(value) = &self.allocated_resource_statuses {
    217            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatedResourceStatuses", value)?;
    218        }
    219        if let Some(value) = &self.allocated_resources {
    220            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatedResources", value)?;
    221        }
    222        if let Some(value) = &self.capacity {
    223            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "capacity", value)?;
    224        }
    225        if let Some(value) = &self.conditions {
    226            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
    227        }
    228        if let Some(value) = &self.current_volume_attributes_class_name {
    229            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "currentVolumeAttributesClassName", value)?;
    230        }
    231        if let Some(value) = &self.modify_volume_status {
    232            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "modifyVolumeStatus", value)?;
    233        }
    234        if let Some(value) = &self.phase {
    235            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "phase", value)?;
    236        }
    237        crate::serde::ser::SerializeStruct::end(state)
    238    }
    239}
    240
    241#[cfg(feature = "schemars")]
    242impl crate::schemars::JsonSchema for PersistentVolumeClaimStatus {
    243    fn schema_name() -> std::borrow::Cow<'static, str> {
    244        "io.k8s.api.core.v1.PersistentVolumeClaimStatus".into()
    245    }
    246
    247    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    248        crate::schemars::json_schema!({
    249            "description": "PersistentVolumeClaimStatus is the current status of a persistent volume claim.",
    250            "type": "object",
    251            "properties": {
    252                "accessModes": {
    253                    "description": "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",
    254                    "type": "array",
    255                    "items": {
    256                        "type": "string",
    257                    },
    258                },
    259                "allocatedResourceStatuses": {
    260                    "description": "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.",
    261                    "type": "object",
    262                    "additionalProperties": {
    263                        "type": "string",
    264                    },
    265                },
    266                "allocatedResources": {
    267                    "description": "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.",
    268                    "type": "object",
    269                    "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
    270                },
    271                "capacity": {
    272                    "description": "capacity represents the actual resources of the underlying volume.",
    273                    "type": "object",
    274                    "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
    275                },
    276                "conditions": {
    277                    "description": "conditions is the current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'Resizing'.",
    278                    "type": "array",
    279                    "items": (__gen.subschema_for::<crate::api::core::v1::PersistentVolumeClaimCondition>()),
    280                },
    281                "currentVolumeAttributesClassName": {
    282                    "description": "currentVolumeAttributesClassName is the current name of the VolumeAttributesClass the PVC is using. When unset, there is no VolumeAttributeClass applied to this PersistentVolumeClaim",
    283                    "type": "string",
    284                },
    285                "modifyVolumeStatus": ({
    286                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ModifyVolumeStatus>();
    287                    schema_obj.ensure_object().insert("description".into(), "ModifyVolumeStatus represents the status object of ControllerModifyVolume operation. When this is unset, there is no ModifyVolume operation being attempted.".into());
    288                    schema_obj
    289                }),
    290                "phase": {
    291                    "description": "phase represents the current phase of PersistentVolumeClaim.",
    292                    "type": "string",
    293                },
    294            },
    295        })
    296    }
    297}