Skip to main content

k8s_openapi/v1_37/api/lifecycle/v1alpha1/
target_responder.rs

1// Generated from definition io.k8s.api.lifecycle.v1alpha1.TargetResponder
2
3/// TargetResponder allows you to specify the responder reacting to the Eviction. Responders should observe and communicate through the Eviction API (see .state) to help with the graceful eviction of a target (e.g. termination of a pod).
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct TargetResponder {
6    /// name allows you to identify the responder reacting to the Eviction.
7    ///
8    /// It must be a valid domain-prefixed key (such as "acme.io/foo"). This field must be unique for each responder. This field is required.
9    pub name: std::string::String,
10
11    /// priority for this responder. Higher priorities are selected first by the evictionrequest-controller. If there are responders with the same priority, the responder whose domain name comes first in the alphabetical higher domain order, will be picked. This means that the top domain labels are compared alphabetically first, followed by the lower domain labels. The key is compared last.
12    ///
13    /// The responder that is the managing controller of the pod should set the value of this field to 10000 to allow both for preemption or fallback registration by other responders.
14    ///
15    /// The minimum value is 0 and the maximum value is 100000. The interval 0-999 is reserved for responders with *.k8s.io suffix. This field is required and immutable.
16    pub priority: i32,
17
18    /// state specifies a state that is assigned by the evictionrequest-controller. Responders should observe this state in order to navigate their lifecycle. - Inactive means that the responder should not yet process this eviction request. - Active means that the responder is either running or expected to start soon.
19    ///   Also, startTime has been set in the ResponderStatus by the evictionrequest-controller.
20    ///
21    ///   An active responder should currently interact with the eviction process by updating
22    ///   .status.responders, where .name is the active responder name. ResponderStatus fields
23    ///   should be periodically updated to indicate the progress or completion of the eviction process.
24    ///   If .status.responders\[\].heartbeatTime field is not updated within the heartbeat deadline defined
25    ///   by the Eviction API (currently 20 minutes), the eviction is passed over to the next responder
26    ///      with a lower priority. Only one responder can be active at a time.
27    /// - Interrupted means that the responder has failed to start or failed to update
28    ///   heartbeatTime in ResponderStatus in a timely manner.
29    /// - Canceled means that the responder has been canceled. In other words, there    is no
30    ///   EvictionRequest with the same target and Eviction intent in .spec.intent.
31    /// - Completed means that the responder has successfully completed and set completionTime
32    ///   in ResponderStatus.
33    ///
34    /// Please refer to the ResponderStatus in .status.responders for more details on each responder.
35    pub state: std::string::String,
36}
37
38impl crate::DeepMerge for TargetResponder {
39    fn merge_from(&mut self, other: Self) {
40        crate::DeepMerge::merge_from(&mut self.name, other.name);
41        crate::DeepMerge::merge_from(&mut self.priority, other.priority);
42        crate::DeepMerge::merge_from(&mut self.state, other.state);
43    }
44}
45
46impl<'de> crate::serde::Deserialize<'de> for TargetResponder {
47    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
48        #[allow(non_camel_case_types)]
49        enum Field {
50            Key_name,
51            Key_priority,
52            Key_state,
53            Other,
54        }
55
56        impl<'de> crate::serde::Deserialize<'de> for Field {
57            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
58                struct Visitor;
59
60                impl crate::serde::de::Visitor<'_> for Visitor {
61                    type Value = Field;
62
63                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
64                        f.write_str("field identifier")
65                    }
66
67                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
68                        Ok(match v {
69                            "name" => Field::Key_name,
70                            "priority" => Field::Key_priority,
71                            "state" => Field::Key_state,
72                            _ => Field::Other,
73                        })
74                    }
75                }
76
77                deserializer.deserialize_identifier(Visitor)
78            }
79        }
80
81        struct Visitor;
82
83        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
84            type Value = TargetResponder;
85
86            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
87                f.write_str("TargetResponder")
88            }
89
90            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
91                let mut value_name: Option<std::string::String> = None;
92                let mut value_priority: Option<i32> = None;
93                let mut value_state: Option<std::string::String> = None;
94
95                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
96                    match key {
97                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
99                        Field::Key_state => value_state = crate::serde::de::MapAccess::next_value(&mut map)?,
100                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
101                    }
102                }
103
104                Ok(TargetResponder {
105                    name: value_name.unwrap_or_default(),
106                    priority: value_priority.unwrap_or_default(),
107                    state: value_state.unwrap_or_default(),
108                })
109            }
110        }
111
112        deserializer.deserialize_struct(
113            "TargetResponder",
114            &[
115                "name",
116                "priority",
117                "state",
118            ],
119            Visitor,
120        )
121    }
122}
123
124impl crate::serde::Serialize for TargetResponder {
125    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
126        let mut state = serializer.serialize_struct(
127            "TargetResponder",
128            3,
129        )?;
130        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
131        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", &self.priority)?;
132        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "state", &self.state)?;
133        crate::serde::ser::SerializeStruct::end(state)
134    }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for TargetResponder {
139    fn schema_name() -> std::borrow::Cow<'static, str> {
140        "io.k8s.api.lifecycle.v1alpha1.TargetResponder".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144        crate::schemars::json_schema!({
145            "description": "TargetResponder allows you to specify the responder reacting to the Eviction. Responders should observe and communicate through the Eviction API (see .state) to help with the graceful eviction of a target (e.g. termination of a pod).",
146            "type": "object",
147            "properties": {
148                "name": {
149                    "description": "name allows you to identify the responder reacting to the Eviction.\n\nIt must be a valid domain-prefixed key (such as \"acme.io/foo\"). This field must be unique for each responder. This field is required.",
150                    "type": "string",
151                },
152                "priority": {
153                    "description": "priority for this responder. Higher priorities are selected first by the evictionrequest-controller. If there are responders with the same priority, the responder whose domain name comes first in the alphabetical higher domain order, will be picked. This means that the top domain labels are compared alphabetically first, followed by the lower domain labels. The key is compared last.\n\nThe responder that is the managing controller of the pod should set the value of this field to 10000 to allow both for preemption or fallback registration by other responders.\n\nThe minimum value is 0 and the maximum value is 100000. The interval 0-999 is reserved for responders with *.k8s.io suffix. This field is required and immutable.",
154                    "type": "integer",
155                    "format": "int32",
156                },
157                "state": {
158                    "description": "state specifies a state that is assigned by the evictionrequest-controller. Responders should observe this state in order to navigate their lifecycle. - Inactive means that the responder should not yet process this eviction request. - Active means that the responder is either running or expected to start soon.\n  Also, startTime has been set in the ResponderStatus by the evictionrequest-controller.\n\n  An active responder should currently interact with the eviction process by updating\n  .status.responders, where .name is the active responder name. ResponderStatus fields\n  should be periodically updated to indicate the progress or completion of the eviction process.\n  If .status.responders[].heartbeatTime field is not updated within the heartbeat deadline defined\n  by the Eviction API (currently 20 minutes), the eviction is passed over to the next responder\n\t with a lower priority. Only one responder can be active at a time.\n- Interrupted means that the responder has failed to start or failed to update\n  heartbeatTime in ResponderStatus in a timely manner.\n- Canceled means that the responder has been canceled. In other words, there\tis no\n  EvictionRequest with the same target and Eviction intent in .spec.intent.\n- Completed means that the responder has successfully completed and set completionTime\n  in ResponderStatus.\n\nPlease refer to the ResponderStatus in .status.responders for more details on each responder.",
159                    "type": "string",
160                },
161            },
162            "required": [
163                "name",
164                "priority",
165                "state",
166            ],
167        })
168    }
169}