k8s_openapi_ext/get/pod/condition.rs
1use super::*;
2
3pub trait PodConditionGetExt {
4 // These are built-in conditions of pod. An application may use a custom condition not listed here.
5
6 /// PodScheduled represents status of the scheduling process for this pod
7 const POD_SCHEDULED: &str = "PodScheduled";
8
9 /// PodReadyToStartContainers pod sandbox is successfully configured and
10 /// the pod is ready to launch containers (beta feature; enabled by default)
11 const POD_READY_TO_START_CONTAINERS: &str = "PodReadyToStartContainers";
12
13 /// ContainersReady indicates whether all containers in the pod are ready
14 const CONTAINERS_READY: &str = "ContainersReady";
15
16 /// PodInitialized means that all init containers in the pod have started successfully
17 const POD_INITIALIZED: &str = "Initialized";
18
19 /// PodReady means the pod is able to service requests and should be added to the
20 /// load balancing pools of all matching services
21 const POD_READY: &str = "Ready";
22
23 /// DisruptionTarget indicates the pod is about to be terminated due to a
24 /// disruption (such as preemption, eviction API or garbage-collection)
25 const DISRUPTION_TARGET: &str = "DisruptionTarget";
26
27 /// PodResizePending indicates that the pod has been resized, but kubelet has not
28 /// yet allocated the resources. If both PodResizePending and PodResizeInProgress
29 /// are set, it means that a new resize was requested in the middle of a previous
30 /// pod resize that is still in progress.
31 const POD_RESIZE_PENDING: &str = "PodResizePending";
32
33 /// PodResizeInProgress indicates that a resize is in progress, and is present whenever
34 /// the Kubelet has allocated resources for the resize, but has not yet actuated all of
35 /// the required changes.
36 /// If both PodResizePending and PodResizeInProgress are set, it means that a new resize was
37 /// requested in the middle of a previous pod resize that is still in progress.
38 const POD_RESIZE_IN_PROGRESS: &str = "PodResizeInProgress";
39
40 // These are reasons for a pod's transition to a condition.
41
42 /// PodReasonUnschedulable reason in PodScheduled PodCondition means that the scheduler
43 /// can't schedule the pod right now, for example due to insufficient resources in the cluster.
44 const POD_REASON_UNSCHEDULABLE: &str = "Unschedulable";
45
46 /// PodReasonSchedulingGated reason in PodScheduled PodCondition means that the scheduler
47 /// skips scheduling the pod because one or more scheduling gates are still present.
48 const POD_REASON_SCHEDULING_GATED: &str = "SchedulingGated";
49
50 /// PodReasonSchedulerError reason in PodScheduled PodCondition means that some internal error happens
51 /// during scheduling, for example due to nodeAffinity parsing errors.
52 const POD_REASON_SCHEDULER_ERROR: &str = "SchedulerError";
53
54 /// PodReasonTerminationByKubelet reason in DisruptionTarget pod condition indicates that the termination
55 /// is initiated by kubelet
56 const POD_REASON_TERMINATION_BY_KUBELET: &str = "TerminationByKubelet";
57
58 /// PodReasonPreemptionByScheduler reason in DisruptionTarget pod condition indicates that the
59 /// disruption was initiated by scheduler's preemption.
60 const POD_REASON_PREEMPTION_BY_SCHEDULER: &str = "PreemptionByScheduler";
61
62 /// PodReasonDeferred reason in PodResizePending pod condition indicates the proposed resize is feasible in
63 /// theory (it fits on this node) but is not possible right now.
64 const POD_REASON_DEFERRED: &str = "Deferred";
65
66 /// PodReasonInfeasible reason in PodResizePending pod condition indicates the proposed resize is not
67 /// feasible and is rejected; it may not be re-evaluated
68 const POD_REASON_INFEASIBLE: &str = "Infeasible";
69
70 /// PodReasonError reason in PodResizeInProgress pod condition indicates that an error occurred while
71 /// actuating the resize.
72 const POD_REASON_ERROR: &str = "Error";
73
74 fn myself(&self) -> &corev1::PodCondition;
75
76 fn status(&self) -> &str {
77 &self.myself().status
78 }
79
80 fn r#type(&self) -> &str {
81 &self.myself().type_
82 }
83
84 fn message(&self) -> Option<&str> {
85 self.myself().message.as_deref()
86 }
87
88 fn reason(&self) -> Option<&str> {
89 self.myself().reason.as_deref()
90 }
91
92 fn last_probe_time(&self) -> Option<&metav1::Time> {
93 self.myself().last_probe_time.as_ref()
94 }
95
96 fn last_transition_time(&self) -> Option<&metav1::Time> {
97 self.myself().last_transition_time.as_ref()
98 }
99
100 fn is_true(&self) -> bool {
101 self.status() == "True"
102 }
103
104 fn is_false(&self) -> bool {
105 self.status() == "False"
106 }
107
108 fn is_unknown(&self) -> bool {
109 self.status() == "Unknown"
110 }
111}
112
113impl PodConditionGetExt for corev1::PodCondition {
114 #[inline(always)]
115 fn myself(&self) -> &corev1::PodCondition {
116 self
117 }
118}