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
//! The stable code of each failure.
use serde::{Deserialize, Serialize};
/// The stable code of a failure, the same in the Rust API and the event stream (`error.code`).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum ErrorCode {
/// The folder isn't a project Isothrum runs: it holds no Compose file, Vagrantfile or
/// Terraform module, or the files of several formats with none named.
ProjectInvalid,
/// The manifest needs something this runner doesn't do (a target that doesn't run on this
/// host, a delivery its driver doesn't take, an action of another driver's, a step with no
/// command for this host), or the call asks the run for something its target can't do (a
/// console into a Compose service with no VM, a Vagrant VM joined to another network).
Unsupported,
/// A file or folder couldn't be read or written, or a socket on this computer bound.
Io,
/// Another process runs an operation on this run, or holds the home's slot pick.
Locked,
/// A tool a step runs isn't installed.
ToolMissing,
/// A step's tool ran and failed.
ToolFailed,
/// A tool the run needs is installed, but got no answer from its service: Docker's engine
/// stopped, or quit while a step ran (the `step` says which): the message says what the tool
/// said.
ToolUnanswered,
/// A tool answers at a version older than the run needs.
ToolTooOld,
/// A tool refused this account (Docker's engine its socket or named pipe): the account needs
/// the access (a group), not the tool started.
ToolDenied,
/// A cloud refused the sign-in the run's tools use: a CLI or SSO session that ran out, an
/// expired token, application-default credentials gone stale, a profile never signed in.
/// Signing in again fixes it; the cloud refused before Terraform changed anything.
CredentialsExpired,
/// A network the run makes needs an address block another network on the engine already
/// holds (Docker's `Pool overlaps with other one on this address space`).
AddressPoolOverlap,
/// A step showed no progress for its time limit, or ran to the ceiling every step stops at,
/// and was stopped, with what it started (the `error` event's `detail` says which).
Timeout,
/// A download (what a step needs, fetched in a phase of its own before it: a Compose start's
/// images, a Vagrant start's boxes; or a step the manifest marks a download) showed no
/// progress for as long as a download may, and was stopped.
DownloadStalled,
/// A download couldn't be made: its tool failed (the message says why: a registry or a box
/// catalog refusing it, a name it doesn't know, the network). A failure for the network that
/// passes (a connection reset, refused or timed out, a gateway's 502, 503 or 504) was tried
/// again first, up to three more times: the message is the last try's.
DownloadFailed,
/// The run is already up.
AlreadyRunning,
/// The run is recorded on another place (server or account) than the one asked for.
RunningElsewhere,
/// A host port the run publishes is taken.
PortInUse,
/// The manifest has no park steps for that mode.
NotParkable,
/// Nothing of the run, or not every one of its machines, is left to resume.
NothingToResume,
/// The run isn't up.
NotRunning,
/// A ready condition didn't hold.
NotReady,
/// A required secret or input has no value.
SecretMissing,
/// A value or secret that can't be handed to the tools (its name empty or holding `=`, a
/// NUL in it).
InputInvalid,
/// A run name that can't name a run.
RunName,
/// The run's Vagrant provider is missing, unknown, not on this host, refused by the run, or
/// lacks its plugin, or the hypervisor lacks what it needs on this computer (virtiofsd, for a
/// shared folder on Linux: the `detail`'s `need`).
ProviderRefused,
/// The elevation Hyper-V's commands need couldn't be had or was lost: the permission prompt
/// declined or unanswered, the elevated session not started or ended before the operation
/// (the message says which).
ElevationFailed,
/// A machine the run doesn't have.
MachineUnknown,
/// The run has several machines the call could mean, and it named none.
MachineAmbiguous,
/// A network the run doesn't have.
NetworkUnknown,
/// A deployment can't be taken over as a run.
AdoptRefused,
/// The operation was cut short before it ended (its future dropped: an embedder's cancel, the
/// command line's Ctrl-C or SIGTERM); the tools it started were asked to stop, and are ended
/// once they have, or 30 seconds later.
Cancelled,
/// The embedder was asked for something that makes no sense (the command line: a run folder
/// with no manifest, a value missing or malformed), so no operation started.
Usage,
/// The machine has no graphical console to reach: its target or provider gives none (the
/// error says why), it isn't running, or its hypervisor doesn't say where it is.
NoConsole,
/// The server the run is on (Proxmox VE, ESXi) refused the run's credentials: its API
/// answered 401 or 403, or its tool said the sign-in failed (an API token revoked, a password
/// changed).
ServerAuthFailed,
/// A file of the runner's own (a record, a ledger entry) is there but isn't what it wrote:
/// not JSON, or another version's shape.
Corrupt,
/// The run's state machine has no such move (a park of a parked run, a resume of a ready
/// one), or a resource row can't move that way.
IllegalTransition,
/// The run moved between the read and the write that would have moved it: try again.
StateConflict,
/// The home's store was written by a newer runner.
StoreVersion,
/// The home's store isn't a database this runner reads, or holds what it doesn't write.
StoreCorrupt,
/// A live process holds the lease asked for.
LeaseHeld,
}
impl ErrorCode {
/// The code as written in JSON (`port_in_use`).
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
ErrorCode::ProjectInvalid => "project_invalid",
ErrorCode::Unsupported => "unsupported",
ErrorCode::Io => "io",
ErrorCode::Corrupt => "corrupt",
ErrorCode::Locked => "locked",
ErrorCode::ToolMissing => "tool_missing",
ErrorCode::ToolFailed => "tool_failed",
ErrorCode::ToolUnanswered => "tool_unanswered",
ErrorCode::ToolTooOld => "tool_too_old",
ErrorCode::ToolDenied => "tool_denied",
ErrorCode::CredentialsExpired => "credentials_expired",
ErrorCode::AddressPoolOverlap => "address_pool_overlap",
ErrorCode::Timeout => "timeout",
ErrorCode::DownloadStalled => "download_stalled",
ErrorCode::DownloadFailed => "download_failed",
ErrorCode::AlreadyRunning => "already_running",
ErrorCode::RunningElsewhere => "running_elsewhere",
ErrorCode::PortInUse => "port_in_use",
ErrorCode::NotParkable => "not_parkable",
ErrorCode::NothingToResume => "nothing_to_resume",
ErrorCode::NotRunning => "not_running",
ErrorCode::NotReady => "not_ready",
ErrorCode::SecretMissing => "secret_missing",
ErrorCode::InputInvalid => "input_invalid",
ErrorCode::RunName => "run_name",
ErrorCode::ProviderRefused => "provider_refused",
ErrorCode::ElevationFailed => "elevation_failed",
ErrorCode::MachineUnknown => "machine_unknown",
ErrorCode::MachineAmbiguous => "machine_ambiguous",
ErrorCode::NetworkUnknown => "network_unknown",
ErrorCode::AdoptRefused => "adopt_refused",
ErrorCode::NoConsole => "no_console",
ErrorCode::Cancelled => "cancelled",
ErrorCode::Usage => "usage",
ErrorCode::ServerAuthFailed => "server_auth_failed",
ErrorCode::IllegalTransition => "illegal_transition",
ErrorCode::StateConflict => "state_conflict",
ErrorCode::StoreVersion => "store_version",
ErrorCode::StoreCorrupt => "store_corrupt",
ErrorCode::LeaseHeld => "lease_held",
}
}
}
impl std::fmt::Display for ErrorCode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}