k8s_cluster_api/
errors.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4#[derive(Clone, Debug, Deserialize, Serialize, Error)]
5pub enum MachineStatusError {
6    /// InvalidConfigurationMachineError represents that the combination
7    /// of configuration in the MachineSpec is not supported by this cluster.
8    /// This is not a transient error, but
9    /// indicates a state that must be fixed before progress can be made.
10    ///
11    /// Example: the ProviderSpec specifies an instance type that doesn't exist,.
12
13    #[error("InvalidConfiguration")]
14    InvalidConfiguration, // MachineError MachineStatusError = "InvalidConfiguration"
15
16    // UnsupportedChangeMachineError indicates that the MachineSpec has been updated in a way that
17    // is not supported for reconciliation on this cluster. The spec may be
18    // completely valid from a configuration standpoint, but the controller
19    // does not support changing the real world state to match the new
20    // spec.
21    //
22    // Example: the responsible controller is not capable of changing the
23    // container runtime from docker to rkt.
24    #[error("UnsupportedChange")]
25    UnsupportedChange, // MachineError MachineStatusError = "UnsupportedChange"
26
27    // InsufficientResourcesMachineError generally refers to exceeding one's quota in a cloud provider,
28    // or running out of physical machines in an on-premise environment.
29    #[error("InsufficientResources")]
30    InsufficientResources, // MachineError MachineStatusError = "InsufficientResources"
31
32    // CreateMachineError indicates an error while trying to create a Node to match this
33    // Machine. This may indicate a transient problem that will be fixed
34    // automatically with time, such as a service outage, or a terminal
35    // error during creation that doesn't match a more specific
36    // MachineStatusError value.
37    //
38    // Example: timeout trying to connect to GCE.
39    #[error("CreateMachineError")]
40    CreateError, // MachineStatusError = "CreateError"
41
42    // UpdateMachineError indicates an error while trying to update a Node that this
43    // Machine represents. This may indicate a transient problem that will be
44    // fixed automatically with time, such as a service outage,
45    //
46    // Example: error updating load balancers.
47    #[error("UpdateMachineError")]
48    UpdateError, // MachineStatusError = "UpdateError"
49
50    // DeleteMachineError indicates an error was encountered while trying to delete the Node that this
51    // Machine represents. This could be a transient or terminal error, but
52    // will only be observable if the provider's Machine controller has
53    // added a finalizer to the object to more gracefully handle deletions.
54    //
55    // Example: cannot resolve EC2 IP address.
56    #[error("DeleteMachineError")]
57    DeleteError, // MachineStatusError = "DeleteError"
58
59    // JoinClusterTimeoutMachineError indicates that the machine did not join the cluster
60    // as a new node within the expected timeframe after instance
61    // creation at the provider succeeded
62    //
63    // Example use case: A controller that deletes Machines which do
64    // not result in a Node joining the cluster within a given timeout
65    // and that are managed by a MachineSet.
66    #[error("JoinClusterTimeoutMachineError")]
67    JoinClusterTimeoutError, // = "JoinClusterTimeoutError",
68}
69
70/* ***********************
71
72// MachineStatusError defines errors states for Machine objects.
73type MachineStatusError string
74
75// Constants aren't automatically generated for unversioned packages.
76// Instead share the same constant for all versioned packages.
77
78const (
79)
80
81*********************** */
82
83// ClusterStatusError defines errors states for Cluster objects.
84#[derive(Clone, Debug, Error, Serialize, Deserialize)]
85pub enum ClusterStatusError {
86    // InvalidConfigurationClusterError indicates that the cluster
87    // configuration is invalid.
88    #[error("InvalidConfiguration")]
89    InvalidConfigurationClusterError,
90
91    // UnsupportedChangeClusterError indicates that the cluster
92    // spec has been updated in an unsupported way. That cannot be
93    // reconciled.
94    #[error("UnsupportedChange")]
95    UnsupportedChangeClusterError,
96
97    // CreateClusterError indicates that an error was encountered
98    // when trying to create the cluster.
99    #[error("CreateError")]
100    CreateClusterError,
101
102    // UpdateClusterError indicates that an error was encountered
103    // when trying to update the cluster.
104    #[error("UpdateError")]
105    UpdateClusterError,
106
107    // DeleteClusterError indicates that an error was encountered
108    // when trying to delete the cluster.
109    #[error("DeleteError")]
110    DeleteClusterError,
111}
112
113// KubeadmControlPlaneStatusError defines errors states for KubeadmControlPlane objects.
114#[derive(Clone, Debug, Error, Serialize, Deserialize)]
115pub enum KubeadmControlPlaneStatusError {
116    /// InvalidConfigurationKubeadmControlPlaneError indicates that the kubeadm control plane
117    /// configuration is invalid.
118    #[error("InvalidConfiguration")]
119    InvalidConfiguration,
120
121    /// UnsupportedChangeKubeadmControlPlaneError indicates that the kubeadm control plane
122    /// spec has been updated in an unsupported way that cannot be
123    /// reconciled.
124    #[error("UnsupportedChange")]
125    UnsupportedChange,
126
127    /// CreateKubeadmControlPlaneError indicates that an error was encountered
128    /// when trying to create the kubeadm control plane.
129    #[error("CreateError")]
130    CreateError,
131
132    /// UpdateKubeadmControlPlaneError indicates that an error was encountered
133    /// when trying to update the kubeadm control plane.
134    #[error("UpdateError")]
135    UpdateError,
136
137    /// DeleteKubeadmControlPlaneError indicates that an error was encountered
138    /// when trying to delete the kubeadm control plane.
139    #[error("DeleteError")]
140    DeleteError,
141}
142
143/* ***********************
144// MachineSetStatusError defines errors states for MachineSet objects.
145type MachineSetStatusError string
146
147const (
148    // InvalidConfigurationMachineSetError represents
149    // the combination of configuration in the MachineTemplateSpec
150    // is not supported by this cluster. This is not a transient error, but
151    // indicates a state that must be fixed before progress can be made.
152    //
153    // Example: the ProviderSpec specifies an instance type that doesn't exist.
154    InvalidConfigurationMachineSetError MachineSetStatusError = "InvalidConfiguration"
155)
156
157// MachinePoolStatusFailure defines errors states for MachinePool objects.
158type MachinePoolStatusFailure string
159
160const (
161    // InvalidConfigurationMachinePoolError represemts
162    // the combination of configuration in the MachineTemplateSpec
163    // is not supported by this cluster. This is not a transient error, but
164    // indicates a state that must be fixed before progress can be made.
165    //
166    // Example: the ProviderSpec specifies an instance type that doesn't exist.
167    InvalidConfigurationMachinePoolError MachinePoolStatusFailure = "InvalidConfiguration"
168)
169
170*********************** */