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
//! The process exit codes of `stratum`, stable across releases.
//!
//! | Code | Meaning |
//! |---|---|
//! | 0 | Success; for `status`, the node is `ready` |
//! | 1 | Local failure: a key, token or resume file, the clock, or writing output |
//! | 2 | The node could not be reached |
//! | 3 | `status`: the node is `unconfigured` |
//! | 4 | `status`: the node is `degraded` |
//! | 5 | The node sent a response that does not follow the API contract |
//! | 6 | Changes were previewed but not applied: no confirmation |
//! | 7 | A local check refused the node's answer (claim body, manifest signature, admission notice, probe) |
//! | 8 | `join`: the pod was not provisioned within `--wait-secs` |
//! | 9 | `export`: the archive was written, but an entry changed, vanished or was skipped during the walk |
//! | 10 | Server error `bad_request` |
//! | 11 | Server error `unauthorized` |
//! | 12 | Server error `forbidden` |
//! | 13 | Server error `not_found` |
//! | 14 | Server error `conflict` |
//! | 15 | Server error `payload_too_large` |
//! | 16 | Server error `unsupported_media_type` |
//! | 17 | Server error `invalid`, or a preview that reports validation errors |
//! | 18 | Server error `too_many_challenges` |
//! | 19 | Server error `backup_refused` |
//! | 20 | Server error `internal` |
//! | 21 | A server error code this client does not know |
//! | 22 | Server error `request_timeout` |
//! | 23 | Server error `capacity_exhausted` |
//! | 24 | Server error `invitation_refused` |
//! | 25 | Server error `invitations_disabled` |
//! | 26 | Server error `gate_unavailable` |
//! | 27 | Server error `too_many_requests` |
//! | 28 | Server error `misdirected_request` |
//! | 29 | Server error `method_not_allowed` |
//! | 30 | Server error `insufficient_storage` |
//! | 31 | `precondition_failed`: a conditional pod write found another version |
//! | 32 | Server error `bad_gateway` (the gate got no valid answer upstream) |
//! | 33 | Server error `gateway_timeout` (the gate's upstream did not answer in time) |
//! | 64 | Invalid command line |
/// Success. For `status`, the node is `ready`.
pub const OK: u8 = 0;
/// A local failure: a key, token or resume file, the clock, or output.
pub const FAILURE: u8 = 1;
/// The node could not be reached.
pub const UNREACHABLE: u8 = 2;
/// `status`: the node is `unconfigured`.
pub const UNCONFIGURED: u8 = 3;
/// `status`: the node is `degraded`.
pub const DEGRADED: u8 = 4;
/// The node's response does not follow the API contract.
pub const PROTOCOL: u8 = 5;
/// Changes were previewed but not applied because nothing confirmed them.
pub const NOT_CONFIRMED: u8 = 6;
/// A local check refused the node's answer.
pub const REFUSED: u8 = 7;
/// `join`: the pod was not provisioned within the wait; rerun `join` to
/// continue.
pub const TIMED_OUT: u8 = 8;
/// `export`: the archive and manifest were written, but at least one entry
/// changed, vanished or was skipped during the walk; the manifest lists
/// them.
pub const EXPORT_INCOMPLETE: u8 = 9;
/// Server error `bad_request` (HTTP 400).
pub const BAD_REQUEST: u8 = 10;
/// Server error `unauthorized` (HTTP 401).
pub const UNAUTHORIZED: u8 = 11;
/// Server error `forbidden` (HTTP 403).
pub const FORBIDDEN: u8 = 12;
/// Server error `not_found` (HTTP 404).
pub const NOT_FOUND: u8 = 13;
/// Server error `conflict` (HTTP 409): stale revision, already bound or
/// operation conflict.
pub const CONFLICT: u8 = 14;
/// Server error `payload_too_large` (HTTP 413).
pub const PAYLOAD_TOO_LARGE: u8 = 15;
/// Server error `unsupported_media_type` (HTTP 415).
pub const UNSUPPORTED_MEDIA_TYPE: u8 = 16;
/// Server error `invalid` (HTTP 422), or a preview with validation errors.
pub const INVALID: u8 = 17;
/// Server error `too_many_challenges` (HTTP 429).
pub const TOO_MANY_CHALLENGES: u8 = 18;
/// Server error `backup_refused` (HTTP 409): no backup recipient configured.
pub const BACKUP_REFUSED: u8 = 19;
/// Server error `internal` (HTTP 500).
pub const INTERNAL: u8 = 20;
/// A server error code this client does not know.
pub const UNKNOWN_SERVER_ERROR: u8 = 21;
/// Server error `request_timeout` (HTTP 408): the node gave up waiting for
/// the request to arrive.
pub const REQUEST_TIMEOUT: u8 = 22;
/// Server error `capacity_exhausted` (HTTP 409): every tenant slot is
/// taken; the invitation is still `issued`.
pub const CAPACITY_EXHAUSTED: u8 = 23;
/// Server error `invitation_refused` (HTTP 403): the invitation is unknown,
/// expired, revoked, used or for another identity.
pub const INVITATION_REFUSED: u8 = 24;
/// Server error `invitations_disabled` (HTTP 403):
/// `membership.invitations_enabled` is off.
pub const INVITATIONS_DISABLED: u8 = 25;
/// Server error `gate_unavailable` (HTTP 503): the gate could not be paused
/// and drained for a backup.
pub const GATE_UNAVAILABLE: u8 = 26;
/// Server error `too_many_requests` (HTTP 429): over the admission rate
/// limit.
pub const TOO_MANY_REQUESTS: u8 = 27;
/// Server error `misdirected_request` (HTTP 421): `Host` is not the node's
/// canonical authority, so `--origin` is wrong.
pub const MISDIRECTED_REQUEST: u8 = 28;
/// Server error `method_not_allowed` (HTTP 405), including a `DELETE` of
/// the root ACL.
pub const METHOD_NOT_ALLOWED: u8 = 29;
/// Server error `insufficient_storage` (HTTP 507): the pod volume is low
/// and writes are stopped.
pub const INSUFFICIENT_STORAGE: u8 = 30;
/// `precondition_failed` (HTTP 412): `--if-match` named another version,
/// or `--create-only` found the resource already there.
pub const PRECONDITION_FAILED: u8 = 31;
/// Server error `bad_gateway` (HTTP 502): the gate got no valid answer
/// from the pod server or the controller.
pub const BAD_GATEWAY: u8 = 32;
/// Server error `gateway_timeout` (HTTP 504): the pod server or the
/// controller did not answer the gate in time. A write may or may not have
/// happened; read before writing again.
pub const GATEWAY_TIMEOUT: u8 = 33;
/// The command line could not be parsed.
pub const USAGE: u8 = 64;
/// Returns the exit code for a server error code from the API contract.
///
/// # Examples
///
/// ```
/// use stratum_node_cli::exit;
///
/// assert_eq!(exit::for_server_code("conflict"), exit::CONFLICT);
/// assert_eq!(exit::for_server_code("request_timeout"), exit::REQUEST_TIMEOUT);
/// assert_eq!(exit::for_server_code("capacity_exhausted"), exit::CAPACITY_EXHAUSTED);
/// assert_eq!(exit::for_server_code("something_new"), exit::UNKNOWN_SERVER_ERROR);
/// ```