1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
use std::io::Error as IoError;

use fluvio::FluvioError;
use k8_config::{ConfigError as K8ConfigError};
use k8_client::{ClientError as K8ClientError};
use fluvio_helm::HelmError;
use crate::check::{CheckResults, CheckStatuses};
use fluvio_command::CommandError;

/// The types of errors that can occur during cluster management
#[derive(thiserror::Error, Debug)]
pub enum ClusterError {
    /// An error occurred while trying to install Fluvio on Kubernetes
    #[error("Failed to install Fluvio on Kubernetes")]
    InstallK8(#[from] K8InstallError),
    /// An error occurred while trying to install Fluvio locally
    #[error("Failed to install Fluvio locally")]
    InstallLocal(#[from] LocalInstallError),
    /// An error occurred while trying to install Fluvio system charts
    #[error("Failed to install Fluvio system charts")]
    InstallSys(#[from] SysInstallError),
    /// An error occurred while trying to uninstall Fluvio
    #[error("Failed to uninstall Fluvio")]
    Uninstall(#[from] UninstallError),
}

/// Errors that may occur while trying to install Fluvio system charts
#[derive(thiserror::Error, Debug)]
pub enum SysInstallError {
    /// An error occurred while running helm.
    #[error("Helm client error")]
    HelmError(#[from] HelmError),
    /// Attempted to construct a Config object without all required fields
    #[error("Missing required config option {0}")]
    MissingRequiredConfig(String),
}

/// Errors that may occur while trying to install Fluvio on Kubernetes
#[derive(thiserror::Error, Debug)]
pub enum K8InstallError {
    /// An IO error occurred, such as opening a file or running a command.
    #[error(transparent)]
    IoError(#[from] IoError),
    /// An error occurred with the Fluvio client.
    #[error("Fluvio client error")]
    FluvioError(#[from] FluvioError),
    /// An error occurred with the Kubernetes config.
    #[error("Kubernetes config error")]
    K8ConfigError(#[from] K8ConfigError),
    /// An error occurred with the Kubernetes client.
    #[error("Kubernetes client error")]
    K8ClientError(#[from] K8ClientError),
    /// An error occurred while running helm.
    #[error("Helm client error")]
    HelmError(#[from] HelmError),
    /// Failed to execute a command
    #[error(transparent)]
    CommandError(#[from] CommandError),
    /// One or more pre-checks (successfully) failed when trying to start the cluster
    #[error("Pre-checks failed during cluster startup")]
    FailedPrecheck(CheckStatuses),
    /// Encountered an error while performing one or more pre-checks
    #[error("Failed to perform one or more pre-checks")]
    PrecheckErrored(CheckResults),
    /// Failed to update Fluvio cluster
    #[error("Expected to find cluster with platform version {0}")]
    FailedPlatformVersion(String),
    /// Timed out when waiting for SC service.
    #[error("Timed out when waiting for SC service")]
    SCServiceTimeout,
    /// Timed out when waiting for SC port check.
    #[error("Timed out when waiting for SC port check")]
    SCPortCheckTimeout,
    /// Timed out when waiting for DNS resolution.
    #[error("Timed out when waiting for DNS resolution")]
    SCDNSTimeout,
    /// Timed out when waiting for SPU.
    #[error("Timed out when waiting for SPU")]
    SPUTimeout,
    /// Unable to find Fluvio SC service in Kubernetes
    #[error("Unable to detect Fluvio SC K8 service")]
    UnableToDetectService,
    /// Unable to find a needed Helm chart
    #[error("Unable to find chart in Helm: {0}")]
    HelmChartNotFound(String),
    /// Attempted to construct a Config object without all required fields
    #[error("Missing required config option {0}")]
    MissingRequiredConfig(String),
    /// A different kind of error occurred.
    #[error("An unknown error occurred: {0}")]
    Other(String),
}

/// Errors that may occur while trying to install Fluvio locally
#[derive(thiserror::Error, Debug)]
pub enum LocalInstallError {
    /// An IO error occurred, such as opening a file or running a command.
    #[error(transparent)]
    IoError(#[from] IoError),
    /// An error occurred with the Fluvio client.
    #[error("Fluvio client error")]
    FluvioError(#[from] FluvioError),
    /// An error occurred with the Kubernetes config.
    #[error("Kubernetes config error")]
    K8ConfigError(#[from] K8ConfigError),
    /// An error occurred with the Kubernetes client.
    #[error("Kubernetes client error")]
    K8ClientError(#[from] K8ClientError),
    /// An error occurred while running helm.
    #[error("Helm client error")]
    HelmError(#[from] HelmError),
    /// Failed to execute a command
    #[error(transparent)]
    CommandError(#[from] CommandError),
    /// One or more pre-checks (successfully) failed when trying to start the cluster
    #[error("Pre-checks failed during cluster startup")]
    FailedPrecheck(CheckStatuses),
    /// Encountered an error while performing one or more pre-checks
    #[error("Failed to perform one or more pre-checks")]
    PrecheckErrored(CheckResults),
    /// Timed out when waiting for SC service.
    #[error("Timed out when waiting for SC service")]
    SCServiceTimeout,
    /// Timed out when waiting for SC port check.
    #[error("Timed out when waiting for SC port check")]
    SCPortCheckTimeout,
    /// Timed out when waiting for DNS resolution.
    #[error("Timed out when waiting for DNS resolution")]
    SCDNSTimeout,
    /// Timed out when waiting for SPU.
    #[error("Timed out when waiting for SPU")]
    SPUTimeout,
    /// Unable to find Fluvio SC service in Kubernetes
    #[error("Unable to detect Fluvio SC K8 service")]
    UnableToDetectService,
    /// Unable to find a needed Helm chart
    #[error("Unable to find chart in Helm: {0}")]
    HelmChartNotFound(String),
    /// Attempted to construct a Config object without all required fields
    #[error("Missing required config option {0}")]
    MissingRequiredConfig(String),
    /// A different kind of error occurred.
    #[error("An unknown error occurred: {0}")]
    Other(String),
}

/// Errors that may occur while trying to unintsall Fluvio
#[derive(thiserror::Error, Debug)]
pub enum UninstallError {
    /// An IO error occurred, such as opening a file or running a command.
    #[error(transparent)]
    IoError(#[from] IoError),
    /// An error occurred with the Fluvio client.
    #[error("Fluvio client error")]
    FluvioError(#[from] FluvioError),
    /// An error occurred with the Kubernetes config.
    #[error("Kubernetes config error")]
    K8ConfigError(#[from] K8ConfigError),
    /// An error occurred with the Kubernetes client.
    #[error("Kubernetes client error")]
    K8ClientError(#[from] K8ClientError),
    /// An error occurred while running helm.
    #[error("Helm client error")]
    HelmError(#[from] HelmError),
    /// Timed out when waiting for SC service.
    #[error("Timed out when waiting for SC service")]
    SCServiceTimeout,
    /// Timed out when waiting for SC port check.
    #[error("Timed out when waiting for SC port check")]
    SCPortCheckTimeout,
    /// Timed out when waiting for DNS resolution.
    #[error("Timed out when waiting for DNS resolution")]
    SCDNSTimeout,
    /// Timed out when waiting for SPU.
    #[error("Timed out when waiting for SPU")]
    SPUTimeout,
    /// Unable to find Fluvio SC service in Kubernetes
    #[error("Unable to detect Fluvio SC K8 service")]
    UnableToDetectService,
    /// Unable to find a needed Helm chart
    #[error("Unable to find chart in Helm: {0}")]
    HelmChartNotFound(String),
    /// A different kind of error occurred.
    #[error("An unknown error occurred: {0}")]
    Other(String),
}