k8s_openapi/v1_37/api/lifecycle/v1alpha1/
eviction_status.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EvictionStatus {
6 pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
15
16 pub observed_generation: Option<i64>,
18
19 pub requesters: Option<std::vec::Vec<crate::api::lifecycle::v1alpha1::Requester>>,
23
24 pub responders: Option<std::vec::Vec<crate::api::lifecycle::v1alpha1::ResponderStatus>>,
30
31 pub target_responders: Option<std::vec::Vec<crate::api::lifecycle::v1alpha1::TargetResponder>>,
42}
43
44impl crate::DeepMerge for EvictionStatus {
45 fn merge_from(&mut self, other: Self) {
46 crate::merge_strategies::list::map(
47 &mut self.conditions,
48 other.conditions,
49 &[|lhs, rhs| lhs.type_ == rhs.type_],
50 |current_item, other_item| {
51 crate::DeepMerge::merge_from(current_item, other_item);
52 },
53 );
54 crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
55 crate::merge_strategies::list::map(
56 &mut self.requesters,
57 other.requesters,
58 &[|lhs, rhs| lhs.name == rhs.name],
59 |current_item, other_item| {
60 crate::DeepMerge::merge_from(current_item, other_item);
61 },
62 );
63 crate::merge_strategies::list::map(
64 &mut self.responders,
65 other.responders,
66 &[|lhs, rhs| lhs.name == rhs.name],
67 |current_item, other_item| {
68 crate::DeepMerge::merge_from(current_item, other_item);
69 },
70 );
71 crate::merge_strategies::list::map(
72 &mut self.target_responders,
73 other.target_responders,
74 &[|lhs, rhs| lhs.name == rhs.name],
75 |current_item, other_item| {
76 crate::DeepMerge::merge_from(current_item, other_item);
77 },
78 );
79 }
80}
81
82impl<'de> crate::serde::Deserialize<'de> for EvictionStatus {
83 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
84 #[allow(non_camel_case_types)]
85 enum Field {
86 Key_conditions,
87 Key_observed_generation,
88 Key_requesters,
89 Key_responders,
90 Key_target_responders,
91 Other,
92 }
93
94 impl<'de> crate::serde::Deserialize<'de> for Field {
95 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
96 struct Visitor;
97
98 impl crate::serde::de::Visitor<'_> for Visitor {
99 type Value = Field;
100
101 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
102 f.write_str("field identifier")
103 }
104
105 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
106 Ok(match v {
107 "conditions" => Field::Key_conditions,
108 "observedGeneration" => Field::Key_observed_generation,
109 "requesters" => Field::Key_requesters,
110 "responders" => Field::Key_responders,
111 "targetResponders" => Field::Key_target_responders,
112 _ => Field::Other,
113 })
114 }
115 }
116
117 deserializer.deserialize_identifier(Visitor)
118 }
119 }
120
121 struct Visitor;
122
123 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
124 type Value = EvictionStatus;
125
126 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
127 f.write_str("EvictionStatus")
128 }
129
130 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
131 let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
132 let mut value_observed_generation: Option<i64> = None;
133 let mut value_requesters: Option<std::vec::Vec<crate::api::lifecycle::v1alpha1::Requester>> = None;
134 let mut value_responders: Option<std::vec::Vec<crate::api::lifecycle::v1alpha1::ResponderStatus>> = None;
135 let mut value_target_responders: Option<std::vec::Vec<crate::api::lifecycle::v1alpha1::TargetResponder>> = None;
136
137 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
138 match key {
139 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
140 Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
141 Field::Key_requesters => value_requesters = crate::serde::de::MapAccess::next_value(&mut map)?,
142 Field::Key_responders => value_responders = crate::serde::de::MapAccess::next_value(&mut map)?,
143 Field::Key_target_responders => value_target_responders = crate::serde::de::MapAccess::next_value(&mut map)?,
144 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
145 }
146 }
147
148 Ok(EvictionStatus {
149 conditions: value_conditions,
150 observed_generation: value_observed_generation,
151 requesters: value_requesters,
152 responders: value_responders,
153 target_responders: value_target_responders,
154 })
155 }
156 }
157
158 deserializer.deserialize_struct(
159 "EvictionStatus",
160 &[
161 "conditions",
162 "observedGeneration",
163 "requesters",
164 "responders",
165 "targetResponders",
166 ],
167 Visitor,
168 )
169 }
170}
171
172impl crate::serde::Serialize for EvictionStatus {
173 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
174 let mut state = serializer.serialize_struct(
175 "EvictionStatus",
176 self.conditions.as_ref().map_or(0, |_| 1) +
177 self.observed_generation.as_ref().map_or(0, |_| 1) +
178 self.requesters.as_ref().map_or(0, |_| 1) +
179 self.responders.as_ref().map_or(0, |_| 1) +
180 self.target_responders.as_ref().map_or(0, |_| 1),
181 )?;
182 if let Some(value) = &self.conditions {
183 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
184 }
185 if let Some(value) = &self.observed_generation {
186 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
187 }
188 if let Some(value) = &self.requesters {
189 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "requesters", value)?;
190 }
191 if let Some(value) = &self.responders {
192 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "responders", value)?;
193 }
194 if let Some(value) = &self.target_responders {
195 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "targetResponders", value)?;
196 }
197 crate::serde::ser::SerializeStruct::end(state)
198 }
199}
200
201#[cfg(feature = "schemars")]
202impl crate::schemars::JsonSchema for EvictionStatus {
203 fn schema_name() -> std::borrow::Cow<'static, str> {
204 "io.k8s.api.lifecycle.v1alpha1.EvictionStatus".into()
205 }
206
207 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
208 crate::schemars::json_schema!({
209 "description": "EvictionStatus represents the last observed status of the eviction request.",
210 "type": "object",
211 "properties": {
212 "conditions": {
213 "description": "conditions contain information about the eviction request.\n\nEviction specific conditions are: TargetEvicted or Failed (managed by evictionrequest-controller). - Failed means that the eviction request is no longer being processed\n by any eviction responder. This can happen if the request is canceled or if no responder\n managed to evict the target (e.g. terminate or delete a pod).\n- TargetEvicted means that the target has been evicted (e.g. a pod has been terminated or deleted).\n\n\tThe maximum length of the conditions list is 100.",
214 "type": "array",
215 "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
216 },
217 "observedGeneration": {
218 "description": "observedGeneration is Eviction's .metadata.generation observed by the evictionrequest-controller. The observed generation value cannot be negative and can only be incremented. The minimum value is 1. This field is managed by evictionrequest-controller.",
219 "type": "integer",
220 "format": "int64",
221 },
222 "requesters": {
223 "description": "requesters allow you to identify the entities, that requested the eviction of the target. If all the requesters withdraw their eviction intent, the eviction will be canceled.\n\nThe maximum length of the requesters list is 100. If this limit is exceeded, requesters with Withdrawn intent should be dropped first.",
224 "type": "array",
225 "items": (__gen.subschema_for::<crate::api::lifecycle::v1alpha1::Requester>()),
226 },
227 "responders": {
228 "description": "responders represents the eviction process status of each declared responder.\n\nThe responder list should be the same length and have the same .name fields as .status.targetResponders. Only responders with .name that have Active state in .targetResponders[].state should be updated and can be mutated. First initialization of the list is allowed.\n\nEach ResponderStatus is initialized by evictionrequest-controller and then managed by the designated responder.",
229 "type": "array",
230 "items": (__gen.subschema_for::<crate::api::lifecycle::v1alpha1::ResponderStatus>()),
231 },
232 "targetResponders": {
233 "description": "targetResponders reference responders that should eventually respond to this eviction to help with the graceful eviction of a target. These responders are selected sequentially, according to their specified priority by setting the Active state to the TargetResponder .state field. The maximum number of active responders allowed is 1. Eventually each responder can end up in an Interrupted, Canceled or, Completed state. Responders should observe these states in order to navigate their lifecycle.\n\nIf the target is a pod, the field is populated from Pod's .spec.evictionResponders. Default responders may be added to the list according to the target.\n\nDefault responders: - imperative-eviction.k8s.io/evictor responder with a priority of 100 is added to the list if the\n target is a pod. It will call the imperative Eviction API (pods/<name>/eviction subresource).\n This call may not succeed due to PodDisruptionBudgets, which may block the pod termination.\n It will update the responder message and try again with a backoff.\n\nThe maximum length of the responders list is 11. The length and keys of the list cannot change once set. This field is managed by evictionrequest-controller.",
234 "type": "array",
235 "items": (__gen.subschema_for::<crate::api::lifecycle::v1alpha1::TargetResponder>()),
236 },
237 },
238 })
239 }
240}