@serve.zone/interfaces 32.81.0 → 32.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.smartconfig.json +1 -1
- package/changelog.md +22 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/cloudlyconfig.d.ts +4 -2
- package/dist_ts/data/cloudlyconfig.js +26 -2
- package/dist_ts/data/cluster.d.ts +7 -0
- package/dist_ts/data/cluster.js +1 -1
- package/dist_ts/data/clusternode.d.ts +14 -1
- package/dist_ts/data/clusternode.js +8 -2
- package/dist_ts/data/controller.d.ts +49 -5
- package/dist_ts/data/controller.js +54 -1
- package/dist_ts/data/gatewayconnector.d.ts +3 -3
- package/dist_ts/data/gatewayconnector.js +16 -3
- package/dist_ts/data/witness.d.ts +14 -1
- package/dist_ts/data/witness.js +9 -1
- package/dist_ts/requests/controller.d.ts +52 -0
- package/dist_ts/requests/controller.js +2 -0
- package/dist_ts/requests/index.d.ts +2 -1
- package/dist_ts/requests/index.js +3 -2
- package/package.json +1 -1
- package/readme.md +66 -5
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/cloudlyconfig.ts +25 -1
- package/ts/data/cluster.ts +7 -0
- package/ts/data/clusternode.ts +14 -1
- package/ts/data/controller.ts +74 -5
- package/ts/data/gatewayconnector.ts +15 -2
- package/ts/data/witness.ts +14 -1
- package/ts/requests/controller.ts +66 -0
- package/ts/requests/index.ts +2 -0
package/readme.md
CHANGED
|
@@ -3265,7 +3265,11 @@ without; together they are
|
|
|
3265
3265
|
every variable Cloudly reads. The five `cloudlyHostPlatformOidcEnvironment` names are all or
|
|
3266
3266
|
none, with the redirect URI `${publicOrigin}/auth/oidc/callback`. Cloudly binds
|
|
3267
3267
|
`SERVEZONE_LISTENPORT` (`cloudlyDefaultListenPort`, 3000, when unset) and answers its health
|
|
3268
|
-
on `cloudlyStatusPath` (`/status`).
|
|
3268
|
+
on `cloudlyStatusPath` (`/status`), which never reads the witness. A controller site names its own
|
|
3269
|
+
origin with `SERVEZONE_SITE_ORIGIN` and its witness with `SERVEZONE_WITNESS_ORIGIN` and
|
|
3270
|
+
`SERVEZONE_WITNESS_BEARER_PATH` (both or neither; the bearer file is a private file the host
|
|
3271
|
+
creates, holding the 43-character base64url of 32 random bytes); a start whose controller row lists
|
|
3272
|
+
another site as a shadow reads the witness and is refused without it. `SERVEZONE_ADMINACCOUNT` is deprecated and read until
|
|
3269
3273
|
Cloudly 34.0.0; `SERVEZONE_INSTALL_DEMO_DATA` is outside the contract. No host extras exist:
|
|
3270
3274
|
they arrive only through a list the host advertises, so an app never branches on `hostType`.
|
|
3271
3275
|
`ICloudlyConfig.letsEncryptEmail`, `letsEncryptPrivateKey`, `jwtKeypair` and the `sslMode`
|
|
@@ -4381,8 +4385,10 @@ guard that names roles excludes it by type.
|
|
|
4381
4385
|
(send the newest status again after the interval), `controller-gateway-adopted`, `request-invalid`
|
|
4382
4386
|
(the text carries the validator's sentences), `desired-state-stale` (the text names the applied
|
|
4383
4387
|
epoch and revision), `gateway-mismatch`, `unsupported-area` (an export of an area the gateway does
|
|
4384
|
-
not take)
|
|
4385
|
-
(`
|
|
4388
|
+
not take), `gateway-client-unbound`, `controller-epoch-older` (a pushed peer set older than the
|
|
4389
|
+
stored one) and `forward-sources-exceed-allowlist` (a `new` adoption whose forward sources would
|
|
4390
|
+
make the union of every gateway's forward source prefixes exceed one cluster ingress allowlist; the
|
|
4391
|
+
code stays unconsumed). An unknown location stays `location-not-found` (`data.locationRefusals`).
|
|
4386
4392
|
- Revisions: `data.IControllerRevision` is one record of the controller-wide sequence, validated
|
|
4387
4393
|
exactly by `data.validateControllerRevision`: the actor's `sub` is `null` exactly for `system`,
|
|
4388
4394
|
the bounds of `data.controllerRevisionContract` only ever rise,
|
|
@@ -4411,7 +4417,8 @@ guard that names roles excludes it by type.
|
|
|
4411
4417
|
gateway client id of 1 to 253 visible ASCII characters, exact keys at every level. No refusal
|
|
4412
4418
|
carries the bearer.
|
|
4413
4419
|
- Peers: a gateway stores the peer set (`controllerId`, `epoch`, `activeOrigin`, `shadowOrigins`) and
|
|
4414
|
-
refuses any other controller and any older epoch.
|
|
4420
|
+
refuses any other controller and any older epoch (`data.judgeControllerPeerSet`, see
|
|
4421
|
+
[Controller Peer Set](#controller-peer-set)). A takeover and a database restore raise the
|
|
4415
4422
|
epoch. Later controller contracts extend `data.IControllerPeerSet` and never define a second one.
|
|
4416
4423
|
- Desired state: the controller pushes the whole `data.IGatewayDesiredState` (`applyDesiredState`):
|
|
4417
4424
|
`{ gatewayId, controllerId, epoch, revision, areas }`, one whole table per controller-owned area.
|
|
@@ -4479,6 +4486,58 @@ const desired: requests.gatewayconnector.IReq_Cloudly_Gateway_ApplyDesiredState[
|
|
|
4479
4486
|
data.validateGatewayDesiredState(desired.desired); // []
|
|
4480
4487
|
```
|
|
4481
4488
|
|
|
4489
|
+
### Controller Peer Set
|
|
4490
|
+
|
|
4491
|
+
`data.IControllerPeerSet` (`controllerId`, `epoch`, `activeOrigin`, `shadowOrigins`) is where the
|
|
4492
|
+
components that dial a controller reach it: a gateway, a relay and a Spark node. AGL-1192 adds the
|
|
4493
|
+
ways the controller states it beyond the gateway's adoption and hello answers, and one rule for
|
|
4494
|
+
admitting it.
|
|
4495
|
+
|
|
4496
|
+
- Judge: `data.judgeControllerPeerSet(stored, next)` answers, in this order, `controller-mismatch`
|
|
4497
|
+
for another `controllerId`, `controller-epoch-older` for an older `epoch`, `equal` when all four
|
|
4498
|
+
keys are equal with `shadowOrigins` in the same order (it is the dialling order), and otherwise
|
|
4499
|
+
`replace`. A newer epoch replaces, and so does a changed origin or shadow list at an equal epoch.
|
|
4500
|
+
`equal` writes nothing. The refusals are `data.controllerPeerSetRefusals`
|
|
4501
|
+
(`data.TControllerPeerSetRefusal`); a refusal leaves the stored set as it was.
|
|
4502
|
+
- Push: `requests.controller.IReq_Cloudly_Any_PushControllerPeerSet` (`pushControllerPeerSet`,
|
|
4503
|
+
`{ controller }`, answered `{}`) is declared once and travels on gateway and relay sessions. The
|
|
4504
|
+
controller sends it before any document of the set's epoch on that session. A gateway refuses it
|
|
4505
|
+
as a connector refusal: `controller-mismatch`, `controller-epoch-older`, or `request-invalid` for a
|
|
4506
|
+
set that fails `data.validateControllerPeerSet`. A relay answers the same two names the way its
|
|
4507
|
+
session states every refusal (`data.applyClusterVpnNetworkRefusals`): the error text leads with
|
|
4508
|
+
`<name>: <reason>` and Cloudly matches the name. A set that fails `data.validateControllerPeerSet`
|
|
4509
|
+
is refused by a relay with the validator's sentences and no refusal name: that is Cloudly's
|
|
4510
|
+
defect, and Cloudly has nothing to act on.
|
|
4511
|
+
- Answers: `data.IRegisterClusterRelayResponse.controller` and
|
|
4512
|
+
`data.ISparkSwarmNodeHeartbeatResponse.controller` are optional. A Cloudly before them sends
|
|
4513
|
+
none, and a relay or Spark that receives none keeps what it dials. Cloudly always sends the whole
|
|
4514
|
+
set, so `data.sparkSwarmNodeContracts.heartbeat.maxResponseBytes` is 40_960: the largest set
|
|
4515
|
+
`data.validateControllerPeerSet` admits (a 200-character id, a 16-digit epoch, 17 origins of
|
|
4516
|
+
2048 characters) on top of the 2048 bytes the rest of the answer takes.
|
|
4517
|
+
- Adding a shadow: `requests.controller.IReq_Admin_Cloudly_AddControllerShadow`
|
|
4518
|
+
(`addControllerShadow`, `{ identity, origin, bearerSha256 }`) names the shadow's site origin and
|
|
4519
|
+
the SHA-256 of the witness bearer that site created for itself, never the bearer. The active
|
|
4520
|
+
enrolls the site with its witness, then sets `shadowOrigins` to the witness members other than
|
|
4521
|
+
itself in one transaction with a revision, and answers `{ controller }`, the set it stored.
|
|
4522
|
+
- Shared rules: `data.validateControllerIdentifier(value, path)` is the canonical identifier rule
|
|
4523
|
+
every controller contract applies to a controller id, `data.validateControllerOrigin(value, path,
|
|
4524
|
+
maximumLength)` the canonical `https` origin rule of every peer-set and witness origin (no
|
|
4525
|
+
userinfo, path, query, fragment, trailing slash or default port), and
|
|
4526
|
+
`data.compareWireTokens(left, right)` the canonical order (UTF-16 code units ascending) of
|
|
4527
|
+
`data.IWitnessRecord.memberOrigins` and every other canonical list here. Sort and check with
|
|
4528
|
+
these, never with a copy.
|
|
4529
|
+
|
|
4530
|
+
```typescript
|
|
4531
|
+
import { data, requests } from '@serve.zone/interfaces';
|
|
4532
|
+
|
|
4533
|
+
declare const stored: data.IControllerPeerSet;
|
|
4534
|
+
declare const pushed: requests.controller.IReq_Cloudly_Any_PushControllerPeerSet['request'];
|
|
4535
|
+
if (data.validateControllerPeerSet(pushed.controller).length === 0) {
|
|
4536
|
+
const judgement = data.judgeControllerPeerSet(stored, pushed.controller);
|
|
4537
|
+
// 'equal': write nothing; 'replace': store pushed.controller; otherwise refuse with judgement.
|
|
4538
|
+
}
|
|
4539
|
+
```
|
|
4540
|
+
|
|
4482
4541
|
### Witness
|
|
4483
4542
|
|
|
4484
4543
|
The witness (AGL-1195) is a small service of its own at a third site that keeps one compare-and-set
|
|
@@ -4526,7 +4585,9 @@ holds no controller data and no controller credential.
|
|
|
4526
4585
|
record before acting on it. `data.readWitnessRefusalErrorData` reads anything but exactly one
|
|
4527
4586
|
refusal as no answer.
|
|
4528
4587
|
- Health: the unauthenticated `getWitnessHealth` answers `{ ready, witnessVersion, interfacesVersion }`
|
|
4529
|
-
and names no controller.
|
|
4588
|
+
and names no controller. `ready` is true while the witness's embedded storage engine runs and
|
|
4589
|
+
answers a bounded read; it does not claim the next write will be stored. A write the storage cannot
|
|
4590
|
+
make is answered on that write (`witness-unavailable` or `outcome-unknown`).
|
|
4530
4591
|
- Validators are exact and never carry a bearer or a pairing code in a refusal:
|
|
4531
4592
|
`data.validateWitnessRecord`, `data.validateWitnessState`, `data.validateWitnessMemberCredential`,
|
|
4532
4593
|
`data.validatePairWitnessControllerRequest`, `data.validateEnrollWitnessMemberRequest`,
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/data/cloudlyconfig.ts
CHANGED
|
@@ -150,6 +150,28 @@ export const cloudlyHostOptionalEnvironment = Object.freeze([
|
|
|
150
150
|
* when unset. A value that is not a positive number turns the periodic cleanup off.
|
|
151
151
|
*/
|
|
152
152
|
'CLOUDLY_BASEOS_IMAGE_CLEANUP_INTERVAL_MS',
|
|
153
|
+
/**
|
|
154
|
+
* This controller site's own origin (Linus rulings 69 Q3 and 79 Q1): a canonical `https` origin
|
|
155
|
+
* (`data.validateControllerOrigin`), the `IControllerPeerSet.activeOrigin` this site states while
|
|
156
|
+
* it is active and the origin the witness names it by. While unset, the site counts as
|
|
157
|
+
* `SERVEZONE_PUBLIC_ORIGIN`, but only while the controller row lists no shadow; once it lists one,
|
|
158
|
+
* a start refuses an unset value or one equal to `SERVEZONE_PUBLIC_ORIGIN`. A fact about this one
|
|
159
|
+
* site, never stored in the replicated controller database.
|
|
160
|
+
*/
|
|
161
|
+
'SERVEZONE_SITE_ORIGIN',
|
|
162
|
+
/**
|
|
163
|
+
* The canonical `https` origin of the witness this site reads (`requests.witness`). Set together
|
|
164
|
+
* with `SERVEZONE_WITNESS_BEARER_PATH` or not at all: a start with only one of them is refused,
|
|
165
|
+
* naming the one that is unset. Required once the controller row lists another site as a shadow.
|
|
166
|
+
*/
|
|
167
|
+
'SERVEZONE_WITNESS_ORIGIN',
|
|
168
|
+
/**
|
|
169
|
+
* The path of this site's witness bearer, a private file under the rules of the secret keyring
|
|
170
|
+
* (`SERVEZONE_SECRET_KEYRING_PATH`) holding the 43-character base64url of 32 random bytes
|
|
171
|
+
* (`data.witnessContract.bearerRandomBytes`). The host creates it; Cloudly only reads it and
|
|
172
|
+
* hashes it, never writes or logs it. Set together with `SERVEZONE_WITNESS_ORIGIN` or not at all.
|
|
173
|
+
*/
|
|
174
|
+
'SERVEZONE_WITNESS_BEARER_PATH',
|
|
153
175
|
] as const);
|
|
154
176
|
|
|
155
177
|
/** One variable the Cloudly server reads but starts without. */
|
|
@@ -159,7 +181,9 @@ export type TCloudlyHostOptionalEnvironmentName = typeof cloudlyHostOptionalEnvi
|
|
|
159
181
|
* Cloudly's health path on its listen port (`GET` or `HEAD`). It answers 200 with
|
|
160
182
|
* `{ healthy: true, checks }` while Cloudly runs and 503 otherwise; it states no version. Cloudly
|
|
161
183
|
* binds its port only late in its start, after its database migrations, so a host's start grace
|
|
162
|
-
* covers the longest migration.
|
|
184
|
+
* covers the longest migration. This path needs no outbound network access and never reads the
|
|
185
|
+
* witness. Starting needs none either, except that a start whose controller row lists another site
|
|
186
|
+
* as a shadow reads the witness at `SERVEZONE_WITNESS_ORIGIN`, and is refused without it.
|
|
163
187
|
*/
|
|
164
188
|
export const cloudlyStatusPath = '/status' as const;
|
|
165
189
|
|
package/ts/data/cluster.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as plugins from '../plugins.js';
|
|
|
2
2
|
|
|
3
3
|
import { type IDockerRegistryInfo } from '../data/docker.js';
|
|
4
4
|
import type { IClusterNode } from './clusternode.js';
|
|
5
|
+
import type { IControllerPeerSet } from './controller.js';
|
|
5
6
|
import type { IFleetCutoverAcceptedEvidenceReference } from './fleetcutover.js';
|
|
6
7
|
import type { TSha256Digest } from './immutableimage.js';
|
|
7
8
|
import type { IRuntimeAuthorityReference } from './runtimeassignment.js';
|
|
@@ -159,6 +160,12 @@ export interface IRegisterClusterRelayResponse {
|
|
|
159
160
|
credential: IRuntimeAuthorityReference;
|
|
160
161
|
/** The accepted registration record this answer wrote, as a retirement record later cites it. */
|
|
161
162
|
acceptedRegistration: IFleetCutoverAcceptedEvidenceReference;
|
|
163
|
+
/**
|
|
164
|
+
* The controller's current peer set (`validateControllerPeerSet`), which the relay admits by
|
|
165
|
+
* `judgeControllerPeerSet` and, once admitted, dials. Absent from a Cloudly before this member;
|
|
166
|
+
* a relay that receives none keeps what it dials, and one built before the member ignores it.
|
|
167
|
+
*/
|
|
168
|
+
controller?: IControllerPeerSet;
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
/**
|
package/ts/data/clusternode.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { isSha256Digest, type TSha256Digest, type TImmutableContainerPlatform }
|
|
|
3
3
|
import type { ISparkNodeReportRecord } from './sparknodereport.js';
|
|
4
4
|
import type { INodeActionExpiry, INodeActionLifecycle } from './nodeaction.js';
|
|
5
5
|
import type { IClusterNodeHostnameIntent } from './clusternodehostname.js';
|
|
6
|
+
import type { IControllerPeerSet } from './controller.js';
|
|
6
7
|
import type { IPlatformObjectStorageEndpoint } from '../platform/objectstorage.js';
|
|
7
8
|
import type { IPlatformDatabaseEndpoint } from '../platform/database.js';
|
|
8
9
|
import {
|
|
@@ -147,7 +148,13 @@ export const sparkSwarmNodeContracts = Object.freeze({
|
|
|
147
148
|
heartbeat: Object.freeze({
|
|
148
149
|
endpoint: '/spark/swarm-nodes/heartbeat',
|
|
149
150
|
maxRequestBytes: 32_768,
|
|
150
|
-
|
|
151
|
+
/**
|
|
152
|
+
* The answer may carry `controller` at its largest: 1 active origin plus 16 shadow origins
|
|
153
|
+
* (`controllerPeerSetContract.maximumShadowOrigins`), each up to
|
|
154
|
+
* `controllerPeerSetContract.maximumOriginLength` characters, a 200-character id and a 16-digit
|
|
155
|
+
* epoch, on top of the 2048 bytes the rest of the answer was bounded by.
|
|
156
|
+
*/
|
|
157
|
+
maxResponseBytes: 40_960,
|
|
151
158
|
} as const),
|
|
152
159
|
/** One sample up, every action the server holds for this node back down. */
|
|
153
160
|
metricsSample: Object.freeze({
|
|
@@ -202,6 +209,12 @@ export interface ISparkSwarmNodeHeartbeatResponse {
|
|
|
202
209
|
message?: string;
|
|
203
210
|
/** The answering server's offer; see `sparkSwarmNodeContracts`. */
|
|
204
211
|
protocol: IProtocolOffer;
|
|
212
|
+
/**
|
|
213
|
+
* The controller's current peer set (`validateControllerPeerSet`), which Spark admits by
|
|
214
|
+
* `judgeControllerPeerSet` and, once admitted, dials. Absent from a Cloudly before this member;
|
|
215
|
+
* a Spark that receives none keeps what it dials, and one built before the member ignores it.
|
|
216
|
+
*/
|
|
217
|
+
controller?: IControllerPeerSet;
|
|
205
218
|
}
|
|
206
219
|
|
|
207
220
|
/** Spark -> Cloudly body for `sparkSwarmNodeContracts.metricsSample.endpoint`. */
|
package/ts/data/controller.ts
CHANGED
|
@@ -8,15 +8,35 @@ import {
|
|
|
8
8
|
import { readDataElements, readDataProperty, readExactDataRecord } from '../private/dataproperties.js';
|
|
9
9
|
import type { TCompleteKeyList } from '../private/keylist.js';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The generic canonical identifier rule the controller contracts judge ids by (a controller id, an
|
|
13
|
+
* actor's `sub`, a revision's object kind and id), stated as refusals: an empty list for a valid
|
|
14
|
+
* id, otherwise one sentence naming `pathArg`. Public so a component that checks a controller id
|
|
15
|
+
* before any contract body carries it (a witness making a pairing code) runs this rule and never a
|
|
16
|
+
* copy of it.
|
|
17
|
+
*/
|
|
18
|
+
export { validateControllerIdentifier };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The canonical `https` origin rule of every controller contract (a peer set's active and shadow
|
|
22
|
+
* origins, a witness member), stated as refusals: an empty list for a string of 1 to
|
|
23
|
+
* `maximumLengthArg` characters that is an `https` URL without userinfo and equal to its own
|
|
24
|
+
* origin (no path, query, fragment, trailing slash or default port), otherwise one sentence per
|
|
25
|
+
* reason naming `pathArg`. Public so a component that checks an origin before any contract body
|
|
26
|
+
* carries it (Cloudly's `SERVEZONE_SITE_ORIGIN` and `SERVEZONE_WITNESS_ORIGIN` at start) runs this
|
|
27
|
+
* rule and never a copy of it.
|
|
28
|
+
*/
|
|
29
|
+
export { validateControllerOrigin };
|
|
30
|
+
|
|
11
31
|
/**
|
|
12
32
|
* The controller as the components that dial it know it: which controller they belong to, which
|
|
13
33
|
* epoch it is in and where to reach it.
|
|
14
34
|
*
|
|
15
|
-
* A dialling component (a gateway
|
|
16
|
-
* answer the controller gives it
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* never define a second one.
|
|
35
|
+
* A dialling component (a gateway, a relay, a Spark node) stores this when it is adopted and
|
|
36
|
+
* replaces it with every answer the controller gives it, as `judgeControllerPeerSet` admits it. It
|
|
37
|
+
* refuses any other `controllerId` and any older `epoch`: a takeover and a database restore both
|
|
38
|
+
* raise the epoch, so the controller that answers with the highest one is the one whose revisions
|
|
39
|
+
* count. Later controller contracts extend this shape and never define a second one.
|
|
20
40
|
*/
|
|
21
41
|
export interface IControllerPeerSet {
|
|
22
42
|
/** Fixed for the controller's life; stored at adoption. */
|
|
@@ -34,6 +54,55 @@ export const controllerPeerSetContract = Object.freeze({
|
|
|
34
54
|
maximumShadowOrigins: 16,
|
|
35
55
|
} as const);
|
|
36
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Every reason a dialling component refuses a peer set the controller states
|
|
59
|
+
* (`judgeControllerPeerSet`); the stored peer set stays as it was.
|
|
60
|
+
*/
|
|
61
|
+
export const controllerPeerSetRefusals = Object.freeze([
|
|
62
|
+
/** The peer set names another controller than the one the component stored. */
|
|
63
|
+
'controller-mismatch',
|
|
64
|
+
/** The peer set's epoch is older than the one the component stored. */
|
|
65
|
+
'controller-epoch-older',
|
|
66
|
+
] as const);
|
|
67
|
+
|
|
68
|
+
/** One of the reasons a dialling component refuses a peer set. */
|
|
69
|
+
export type TControllerPeerSetRefusal = typeof controllerPeerSetRefusals[number];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* What a dialling component does with a peer set the controller states: `equal` writes nothing,
|
|
73
|
+
* `replace` stores it in place of the stored one, and a refusal leaves the stored one as it was.
|
|
74
|
+
*/
|
|
75
|
+
export type TControllerPeerSetJudgement = 'equal' | 'replace' | TControllerPeerSetRefusal;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Whether a dialling component takes `nextArg` in place of its stored peer set: the one admission
|
|
79
|
+
* rule for every peer set a controller states, in an adoption answer, a hello answer, a relay
|
|
80
|
+
* registration answer, a Spark heartbeat answer or `pushControllerPeerSet`, so no receiver keeps a
|
|
81
|
+
* copy of it.
|
|
82
|
+
*
|
|
83
|
+
* It judges values that passed `validateControllerPeerSet`, and answers the first of these that
|
|
84
|
+
* applies, in this order: `controller-mismatch` for another `controllerId`; `controller-epoch-older`
|
|
85
|
+
* for an older `epoch`; `equal` when all four keys are equal, `shadowOrigins` in the same order
|
|
86
|
+
* (the order is the dialling order, so a reordered list is a different set); otherwise `replace`. A
|
|
87
|
+
* newer epoch replaces, and so does a changed origin or shadow list at an equal epoch.
|
|
88
|
+
*/
|
|
89
|
+
export const judgeControllerPeerSet = (
|
|
90
|
+
storedArg: Readonly<IControllerPeerSet>,
|
|
91
|
+
nextArg: Readonly<IControllerPeerSet>,
|
|
92
|
+
): TControllerPeerSetJudgement => {
|
|
93
|
+
if (nextArg.controllerId !== storedArg.controllerId) {
|
|
94
|
+
return 'controller-mismatch';
|
|
95
|
+
}
|
|
96
|
+
if (nextArg.epoch < storedArg.epoch) {
|
|
97
|
+
return 'controller-epoch-older';
|
|
98
|
+
}
|
|
99
|
+
const equal = nextArg.epoch === storedArg.epoch
|
|
100
|
+
&& nextArg.activeOrigin === storedArg.activeOrigin
|
|
101
|
+
&& nextArg.shadowOrigins.length === storedArg.shadowOrigins.length
|
|
102
|
+
&& nextArg.shadowOrigins.every((originArg, indexArg) => originArg === storedArg.shadowOrigins[indexArg]);
|
|
103
|
+
return equal ? 'equal' : 'replace';
|
|
104
|
+
};
|
|
105
|
+
|
|
37
106
|
/**
|
|
38
107
|
* Negative, zero or positive as the left controller position is older than, the same as or newer
|
|
39
108
|
* than the right one: the epoch decides first and the revision only within one epoch, so a higher
|
|
@@ -241,8 +241,8 @@ export interface IGatewayDesiredState {
|
|
|
241
241
|
* answers them instead of `adoptGateway`, `registerGatewaySession`, `pushGatewayStatus` and
|
|
242
242
|
* `createGatewayAdoptionCode`, and instead of a legacy gateway setting it no longer owns. The
|
|
243
243
|
* gateway answers them instead of a whole `applyDesiredState` document, an `exportGatewayArea`, a
|
|
244
|
-
* gateway-client call on the connector socket, or an HTTP call
|
|
245
|
-
* controller-bound gateway client.
|
|
244
|
+
* `pushControllerPeerSet`, a gateway-client call on the connector socket, or an HTTP call
|
|
245
|
+
* authenticated with a token of its controller-bound gateway client.
|
|
246
246
|
*
|
|
247
247
|
* Each is answered as a `TypedResponseError` whose `errorData` is
|
|
248
248
|
* `IGatewayConnectorRefusalErrorData` and whose text carries the detail, so a peer acts on the code
|
|
@@ -322,6 +322,19 @@ export const gatewayConnectorRefusals = Object.freeze([
|
|
|
322
322
|
* (`controllerGatewayClientId: null`).
|
|
323
323
|
*/
|
|
324
324
|
'gateway-client-unbound',
|
|
325
|
+
/**
|
|
326
|
+
* A peer set whose epoch is older than the controller epoch the gateway stored
|
|
327
|
+
* (`controllerPeerSetRefusals`, `judgeControllerPeerSet`): a `pushControllerPeerSet` the gateway
|
|
328
|
+
* refuses and stores nothing of.
|
|
329
|
+
*/
|
|
330
|
+
'controller-epoch-older',
|
|
331
|
+
/**
|
|
332
|
+
* An `adoptGateway` for a `new` gateway whose stated `forwardSourceAddresses` would make the union
|
|
333
|
+
* of every gateway's forward source prefixes exceed one cluster ingress allowlist
|
|
334
|
+
* (`clusterIngressLimits.maximumSourceAllowListEntries` prefixes). Nothing is adopted and the code
|
|
335
|
+
* stays unconsumed.
|
|
336
|
+
*/
|
|
337
|
+
'forward-sources-exceed-allowlist',
|
|
325
338
|
] as const);
|
|
326
339
|
|
|
327
340
|
/** One of the reasons one side of the gateway connector answers instead of a request. */
|
package/ts/data/witness.ts
CHANGED
|
@@ -9,6 +9,15 @@ import type { TCompleteKeyList } from '../private/keylist.js';
|
|
|
9
9
|
import { controllerPeerSetContract } from './controller.js';
|
|
10
10
|
import { isReleaseVersion } from './releaseversion.js';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The canonical order of two wire tokens (UTF-16 code units ascending): negative, zero or positive
|
|
14
|
+
* as `leftArg` sorts before, equal to or after `rightArg`. It is the order of
|
|
15
|
+
* `IWitnessRecord.memberOrigins` and of every other canonical list this package judges, public so a
|
|
16
|
+
* witness or a controller sorts a member list by this rule and never by a copy of it: a copy that
|
|
17
|
+
* drifted would build lists the validators refuse.
|
|
18
|
+
*/
|
|
19
|
+
export { compareWireTokens };
|
|
20
|
+
|
|
12
21
|
/*
|
|
13
22
|
* The witness (AGL-1195, Linus rulings 69 Q5, Q6 and 73): a small service of its own, at a third site, that
|
|
14
23
|
* keeps one compare-and-set record per controller. Cloudly is its only caller and reaches it with
|
|
@@ -156,7 +165,11 @@ export interface ICompareAndSetWitnessRecordRequest {
|
|
|
156
165
|
|
|
157
166
|
/** What the witness answers `getWitnessHealth` (`validateWitnessHealth`); it names no controller. */
|
|
158
167
|
export interface IWitnessHealth {
|
|
159
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* True while the witness's embedded storage engine runs and answers a bounded read. It does not
|
|
170
|
+
* claim the next write will be stored: a write the storage cannot make is answered on that write
|
|
171
|
+
* (`witness-unavailable` or `outcome-unknown`).
|
|
172
|
+
*/
|
|
160
173
|
ready: boolean;
|
|
161
174
|
/** The witness release the site runs (`data.isReleaseVersion`). */
|
|
162
175
|
witnessVersion: string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import type { IControllerPeerSet } from '../data/controller.js';
|
|
3
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* The controller peer set (AGL-1192, Linus ruling 79): where the components that dial a controller
|
|
7
|
+
* reach it. `data.IControllerPeerSet` is the one shape, and `data.judgeControllerPeerSet` the one
|
|
8
|
+
* rule by which a receiver admits it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The controller states its current peer set on a session a component opened to it: a gateway's
|
|
13
|
+
* connector socket and a relay's session both carry this one request. The receiver judges it
|
|
14
|
+
* against the peer set it stored with `data.judgeControllerPeerSet`, the same admission as a hello
|
|
15
|
+
* or registration answer: `replace` stores it, `equal` writes nothing, and either is answered `{}`.
|
|
16
|
+
*
|
|
17
|
+
* The controller sends it before any document of the set's epoch on that session, so a receiver
|
|
18
|
+
* never holds a document of an epoch whose peer set it has not admitted.
|
|
19
|
+
*
|
|
20
|
+
* The receiver refuses it with the judge's refusal (`data.controllerPeerSetRefusals`) and keeps the
|
|
21
|
+
* set it stored: `controller-mismatch` for another controller, `controller-epoch-older` for an
|
|
22
|
+
* older epoch. A gateway answers it as a connector refusal (`data.IGatewayConnectorRefusalErrorData`),
|
|
23
|
+
* and `request-invalid` for a set that fails `data.validateControllerPeerSet`. A relay answers the
|
|
24
|
+
* same two names the way its session states every refusal (`data.applyClusterVpnNetworkRefusals`):
|
|
25
|
+
* the error text leads with `<name>: <reason>` and Cloudly matches the name. A relay refuses a set
|
|
26
|
+
* that fails `data.validateControllerPeerSet` with the validator's sentences and names no refusal:
|
|
27
|
+
* that is Cloudly's defect, and Cloudly has nothing to act on.
|
|
28
|
+
*/
|
|
29
|
+
export interface IReq_Cloudly_Any_PushControllerPeerSet extends plugins.typedrequestInterfaces.implementsTR<
|
|
30
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
31
|
+
IReq_Cloudly_Any_PushControllerPeerSet
|
|
32
|
+
> {
|
|
33
|
+
method: 'pushControllerPeerSet';
|
|
34
|
+
request: {
|
|
35
|
+
/** `data.validateControllerPeerSet`. */
|
|
36
|
+
controller: IControllerPeerSet;
|
|
37
|
+
};
|
|
38
|
+
response: {};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An administrator adds a shadow controller site to the active controller. `origin` is the shadow's
|
|
43
|
+
* site origin, a canonical `https` origin other than the controller's public origin and the active's
|
|
44
|
+
* own site origin; `bearerSha256` is the SHA-256 of the witness bearer that site created for itself,
|
|
45
|
+
* as 64 lowercase hex characters (`data.IEnrollWitnessMemberRequest.bearerSha256`), never the bearer.
|
|
46
|
+
*
|
|
47
|
+
* The active enrolls the site with its witness (`enrollWitnessMember`), then in one transaction sets
|
|
48
|
+
* the peer set's `shadowOrigins` to the witness members other than the active, in the witness's
|
|
49
|
+
* member order, and writes a revision. It answers the peer set it stored, which reaches every
|
|
50
|
+
* dialling component before any later document of its epoch. Running it again after the enrollment
|
|
51
|
+
* was stored and the transaction was not completes it.
|
|
52
|
+
*/
|
|
53
|
+
export interface IReq_Admin_Cloudly_AddControllerShadow extends plugins.typedrequestInterfaces.implementsTR<
|
|
54
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
55
|
+
IReq_Admin_Cloudly_AddControllerShadow
|
|
56
|
+
> {
|
|
57
|
+
method: 'addControllerShadow';
|
|
58
|
+
request: {
|
|
59
|
+
identity: IIdentityCredential;
|
|
60
|
+
origin: string;
|
|
61
|
+
bearerSha256: string;
|
|
62
|
+
};
|
|
63
|
+
response: {
|
|
64
|
+
controller: IControllerPeerSet;
|
|
65
|
+
};
|
|
66
|
+
}
|
package/ts/requests/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import * as certificateRequests from './certificate.js';
|
|
|
9
9
|
import * as clusterRequests from './cluster.js';
|
|
10
10
|
import * as clusterIngressRequests from './clusteringress.js';
|
|
11
11
|
import * as configRequests from './config.js';
|
|
12
|
+
import * as controllerRequests from './controller.js';
|
|
12
13
|
import * as coreMailRequests from './coremail.js';
|
|
13
14
|
import * as coreMailAdminRequests from './coremail.admin.js';
|
|
14
15
|
import * as corestoreRequests from './corestore.js';
|
|
@@ -53,6 +54,7 @@ export {
|
|
|
53
54
|
clusterRequests as cluster,
|
|
54
55
|
clusterIngressRequests as clusteringress,
|
|
55
56
|
configRequests as config,
|
|
57
|
+
controllerRequests as controller,
|
|
56
58
|
coreMailRequests as coremail,
|
|
57
59
|
coreMailAdminRequests as coremailAdmin,
|
|
58
60
|
corestoreRequests as corestore,
|