@serve.zone/interfaces 32.21.0 → 32.23.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/changelog.md +91 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/clusteringress.d.ts +58 -0
- package/dist_ts/data/clusteringress.js +96 -2
- package/dist_ts/data/clusteringressdesignation.d.ts +64 -0
- package/dist_ts/data/clusteringressdesignation.js +84 -0
- package/dist_ts/data/corestorelegacyadoption.d.ts +178 -0
- package/dist_ts/data/corestorelegacyadoption.js +289 -0
- package/dist_ts/data/index.d.ts +6 -0
- package/dist_ts/data/index.js +6 -1
- package/dist_ts/data/networkprojection.d.ts +18 -0
- package/dist_ts/data/networkprojection.js +31 -2
- package/dist_ts/data/networkprotection.d.ts +13 -0
- package/dist_ts/data/networkprotection.js +8 -2
- package/dist_ts/data/networkworkloadingress.d.ts +61 -0
- package/dist_ts/data/networkworkloadingress.js +54 -0
- package/dist_ts/data/runtimelocalstorageclaim.d.ts +124 -0
- package/dist_ts/data/runtimelocalstorageclaim.js +167 -0
- package/dist_ts/data/service.d.ts +15 -1
- package/dist_ts/data/service.js +1 -1
- package/dist_ts/data/serviceruntime.d.ts +15 -3
- package/dist_ts/data/serviceruntime.js +7 -2
- package/dist_ts/data/servicevolumeinitialization.d.ts +91 -0
- package/dist_ts/data/servicevolumeinitialization.js +93 -0
- package/dist_ts/platform/types.d.ts +45 -0
- package/dist_ts/platform/types.js +27 -2
- package/dist_ts/private/storagecontract.d.ts +1 -0
- package/dist_ts/private/storagecontract.js +2 -1
- package/dist_ts/requests/clusteringress.d.ts +52 -0
- package/dist_ts/requests/clusteringress.js +1 -1
- package/dist_ts/requests/corestore.d.ts +60 -0
- package/dist_ts/requests/corestore.js +1 -1
- package/dist_ts/requests/platform.d.ts +6 -1
- package/dist_ts/requests/runtimesession.d.ts +12 -0
- package/dist_ts/requests/service.d.ts +23 -0
- package/package.json +1 -1
- package/readme.md +262 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/clusteringress.ts +136 -1
- package/ts/data/clusteringressdesignation.ts +141 -0
- package/ts/data/corestorelegacyadoption.ts +471 -0
- package/ts/data/index.ts +7 -0
- package/ts/data/networkprojection.ts +49 -1
- package/ts/data/networkprotection.ts +20 -1
- package/ts/data/networkworkloadingress.ts +107 -0
- package/ts/data/runtimelocalstorageclaim.ts +275 -0
- package/ts/data/service.ts +16 -0
- package/ts/data/serviceruntime.ts +19 -2
- package/ts/data/servicevolumeinitialization.ts +159 -0
- package/ts/platform/types.ts +75 -0
- package/ts/private/storagecontract.ts +1 -0
- package/ts/requests/clusteringress.ts +65 -0
- package/ts/requests/corestore.ts +79 -0
- package/ts/requests/platform.ts +6 -0
- package/ts/requests/runtimesession.ts +16 -0
- package/ts/requests/service.ts +28 -0
package/readme.md
CHANGED
|
@@ -572,6 +572,41 @@ overlapping current grants reject, and up to 4,096 retained withdrawals carry
|
|
|
572
572
|
forward until the caller supplies its exact joined application of the preceding
|
|
573
573
|
projection.
|
|
574
574
|
|
|
575
|
+
The optional `IRuntimeNetworkProjection.workloadIngress` member exists only on
|
|
576
|
+
`cloudly` projections; any other controller kind carrying it rejects. It is how
|
|
577
|
+
the cluster ingress workload reaches the workloads it routes to without a
|
|
578
|
+
published host port: each `grants` entry names the exact lease reference of the
|
|
579
|
+
ingress workload (`source`), the exact lease reference of the target workload
|
|
580
|
+
(`destination`), a protocol, the target's own listening port and an
|
|
581
|
+
`authorization` reference. Unlike the full-mesh workload grants, it needs neither
|
|
582
|
+
the same organization nor a shared private network, it opens exactly one port,
|
|
583
|
+
and it is one-way: nothing flows back except the replies of a connection the
|
|
584
|
+
ingress opened. Both leases must be endpoints of the projection, they must
|
|
585
|
+
differ, and at least one of them must be placed on the projection's own node.
|
|
586
|
+
Entries are unique and strictly ordered by `[source.id, destination.id, protocol,
|
|
587
|
+
port]`; at most 1,024 are allowed (`runtimeNetworkWorkloadIngressContract`). The
|
|
588
|
+
authorization is signed content, not grant identity. A projection that omits the
|
|
589
|
+
member retains its exact canonical bytes, digest and signature.
|
|
590
|
+
`getRuntimeNetworkProjectionWorkloadIngressPacketGrants` validates the complete
|
|
591
|
+
projection and returns detached `IRuntimeNetworkWorkloadIngressPacketGrant`s
|
|
592
|
+
(`{ source, destination: { lease, protocol, port } }`). Their withdrawals follow
|
|
593
|
+
the host rules: an omitted grant needs its exact withdrawal, unknown or current
|
|
594
|
+
denials reject, and up to 4,096 retained withdrawals carry forward until the
|
|
595
|
+
exact joined application of the preceding projection is supplied. Cloudly routes
|
|
596
|
+
a cluster ingress route to the target lease address and port once the grant
|
|
597
|
+
exists.
|
|
598
|
+
|
|
599
|
+
The optional `IRuntimeNetworkProjection.hostPlatformEndpointIds` lists the ids of
|
|
600
|
+
the protected authority's platform endpoints whose address the projection's
|
|
601
|
+
node's own host carries, such as a relay listener or a Corestore beside the node
|
|
602
|
+
on one machine. A node delivers workload flows to those endpoints locally instead
|
|
603
|
+
of forwarding them. The list is sorted, unique, never empty when present, and
|
|
604
|
+
every id must be a current platform endpoint; omitting it keeps the canonical
|
|
605
|
+
bytes and states that no endpoint is local. It grants nothing: a workload still
|
|
606
|
+
reaches only the endpoints it selects. The platform endpoint contract itself
|
|
607
|
+
(`{ id, address, protocol, port }`) names no node, which is why this statement is
|
|
608
|
+
per projection.
|
|
609
|
+
|
|
575
610
|
`admitRuntimeNetworkProjection` checks exact predecessor/replay identity and
|
|
576
611
|
rejects changed same-generation content, regressed membership/readiness evidence,
|
|
577
612
|
changed immutable address/DNS keys, and omitted packet grants without explicit
|
|
@@ -811,6 +846,15 @@ named once; an empty `hubs` composes the authority of a runtime network whose cl
|
|
|
811
846
|
yet. One hub costs one of the authority's 64 platform endpoints, so 64 clusters fit one
|
|
812
847
|
authority.
|
|
813
848
|
|
|
849
|
+
A single host that carries both a cluster's hub and platform endpoints, for example the relay
|
|
850
|
+
listener and a Corestore, holds more than one address. The hub address sits inside `vpn.hubPrefix`,
|
|
851
|
+
as every hub's does. The plan's own platform endpoints may not: they sit on another address of the
|
|
852
|
+
same host, inside `prefixes`, outside every pool and outside both VPN prefixes. Several endpoints may
|
|
853
|
+
share that one address on distinct ports, because the authority requires only each
|
|
854
|
+
`address:port:protocol` to be unique. For example, with `hubPrefix` `192.0.2.0/28`, the hub binds
|
|
855
|
+
`192.0.2.1` and the plan lists the relay listener and Corestore on `192.0.2.17` with two ports. The
|
|
856
|
+
node's projection then names those endpoints in `hostPlatformEndpointIds`.
|
|
857
|
+
|
|
814
858
|
`admitRuntimeNetworkAddressPlanChange(previous | null, next)` is the pure decision for a plan write at
|
|
815
859
|
the following revision; any other revision is a contract violation. Leases and the managed VPN
|
|
816
860
|
outlive a plan revision, so it answers:
|
|
@@ -1373,12 +1417,23 @@ phase, settlement, release or authority booleans or evidence.
|
|
|
1373
1417
|
`data.IServiceRuntimeStatus { id, specRevision, state, reason, changedAt }` is the producer's verdict
|
|
1374
1418
|
on one spec revision, and each reason belongs to exactly one state. `converged` and `converging`
|
|
1375
1419
|
carry `reason: null`. `waiting` carries a `TServiceRuntimeWaitingReason`: `node-network-pending`,
|
|
1376
|
-
`conflict
|
|
1420
|
+
`conflict`, `failure-backoff`, `storage-import-pending` (an `import` local storage claim whose bytes
|
|
1421
|
+
have not arrived on its node), `bindings-pending` (the secret manifest does not cover every enabled
|
|
1422
|
+
binding of the service yet) or `legacy-adoption-pending` (a Corestore binding of the service waits for
|
|
1423
|
+
the offline adoption of its legacy resource, see
|
|
1424
|
+
[Corestore Legacy Resource Adoption](#corestore-legacy-resource-adoption)). `refused` carries a
|
|
1425
|
+
`TServiceRuntimeRefusal`:
|
|
1377
1426
|
`cluster-runtime-missing`, `organization-missing`, `image-plan-missing`, `platform-unsupported`,
|
|
1378
1427
|
`secrets-unsupported`, `volumes-unsupported`, `port-protocol-unsupported`, `ports-too-many`,
|
|
1379
1428
|
`readiness-target-undeclared`, `environment-too-large`, `no-eligible-node`, `replica-limit`,
|
|
1380
1429
|
`node-authority-unsupported`, `network-policy-missing`, `network-policy-mismatch`,
|
|
1381
|
-
`network-workload-pool-missing
|
|
1430
|
+
`network-workload-pool-missing`, `network-workload-pool-exhausted`, `volume-driver-unsupported`,
|
|
1431
|
+
`volume-options-unsupported`, `volume-shared-unsupported`, `volume-placement-unsupported`,
|
|
1432
|
+
`volume-initialization-unknown` or `volume-ownership-unknown`. The first four volume refusals name
|
|
1433
|
+
what a local storage claim cannot express: a volume driver other than a node-local directory, driver
|
|
1434
|
+
or mount options, one volume mounted by more than one replica or service, and a placement that does
|
|
1435
|
+
not pin each volume to one node. The last two name what Cloudly will not guess, see
|
|
1436
|
+
[Service Volume Initialization](#service-volume-initialization). `ports-too-many` is a service declaring more target ports than the
|
|
1382
1437
|
`runtimeConfigContract.maximumTargetPorts` (64) a config carries, where `port-protocol-unsupported`
|
|
1383
1438
|
is about one port's protocol; `node-authority-unsupported` is a node whose session resolved fewer
|
|
1384
1439
|
workload authorities than the spec needs, refused at the admit step rather than handed to a node
|
|
@@ -1390,6 +1445,52 @@ is `network-policy-missing`, and a disagreement with the requested egress or pla
|
|
|
1390
1445
|
retires running slots.
|
|
1391
1446
|
`snapshotServiceRuntimeStatus` enforces the pairing.
|
|
1392
1447
|
|
|
1448
|
+
### Service Volume Initialization
|
|
1449
|
+
|
|
1450
|
+
A local storage claim has to say how its volume starts: `empty` with an owner and mode, or `import`
|
|
1451
|
+
of bytes that already exist. `IServiceVolume.initialization` (`TServiceVolumeInitialization`) is
|
|
1452
|
+
where the service states it, per volume, beside the mount path it belongs to:
|
|
1453
|
+
|
|
1454
|
+
- `{ kind: 'empty', ownership }` creates an empty root. `ownership` is
|
|
1455
|
+
`{ kind: 'explicit', uid, gid, mode }`, or `{ kind: 'run-as', mode }`, which takes the owner from
|
|
1456
|
+
the runtime spec's `profile.runAs`. The mode is always stated; it holds directory permission bits
|
|
1457
|
+
only (`serviceVolumeInitializationContract.directoryModeBits`, `0o3777`, setuid refused).
|
|
1458
|
+
- `{ kind: 'import', source: { kind: 'docker-volume', volumeName } }` waits for the bytes of an
|
|
1459
|
+
existing Docker volume on the claim node's host, named exactly as Docker lists it (a
|
|
1460
|
+
Corestore-driver volume included). The operator copies that tree into the node's import directory;
|
|
1461
|
+
the claim does not carry the source, and the node never reads it.
|
|
1462
|
+
|
|
1463
|
+
It lives on the volume and not on the runtime spec because it is a fact about the volume's data,
|
|
1464
|
+
which the service declares, while the runtime spec carries only execution policy and is stored
|
|
1465
|
+
exactly, so a new member there would refuse every stored spec. It is server-managed:
|
|
1466
|
+
`setServiceVolumeInitialization { identity, serviceId, mountPath, expected, initialization }` is its
|
|
1467
|
+
only write. The volume is named by its exact mount path; `expected` is the value the caller read, or
|
|
1468
|
+
`null` for none, and any other stored value refuses. `createService` and `updateService` take volumes
|
|
1469
|
+
as `TServiceWritableVolume` (no `initialization`) and Cloudly refuses one that states it; a stored
|
|
1470
|
+
initialization stays with the volume of the same mount path and goes with the volume. Refusals travel
|
|
1471
|
+
as `IServiceVolumeInitializationErrorData { code, retryable: false }`: `volume-not-found`,
|
|
1472
|
+
`conflict`, `volume-initialization-invalid`, and `volume-initialization-bound`, a change while a
|
|
1473
|
+
bound local storage claim of the volume exists.
|
|
1474
|
+
|
|
1475
|
+
`validateServiceVolumeInitialization(value, path?)` names every reason a value is refused.
|
|
1476
|
+
`deriveServiceVolumeClaimInitialization(initialization, runAs)` is the one rule for the claim fields,
|
|
1477
|
+
and nothing in it is a default:
|
|
1478
|
+
|
|
1479
|
+
| Volume initialization | `runAs` | Claim `initialization` / `initialOwnership` |
|
|
1480
|
+
| --- | --- | --- |
|
|
1481
|
+
| absent | any | refused `volume-initialization-unknown` |
|
|
1482
|
+
| `empty`, `explicit` | any | `empty` / the stated `{ uid, gid, mode }` |
|
|
1483
|
+
| `empty`, `run-as` | `{ user, group }` | `empty` / `{ uid: user, gid: group, mode }` |
|
|
1484
|
+
| `empty`, `run-as` | `null` | refused `volume-ownership-unknown` |
|
|
1485
|
+
| `import` | any | `import` / `null` |
|
|
1486
|
+
|
|
1487
|
+
An absent initialization is refused rather than created empty, because an empty volume in front of a
|
|
1488
|
+
service whose data sits in a legacy Docker volume would start that service without its data. A
|
|
1489
|
+
`run-as` ownership under `runAs: null` is refused because the image's own user is not a number
|
|
1490
|
+
Cloudly knows. The rule decides the first generation of a claim only: every later generation carries
|
|
1491
|
+
that claim's own initialization and ownership, whatever `runAs` says by then, since the node refuses
|
|
1492
|
+
a claim whose initial ownership changed.
|
|
1493
|
+
|
|
1393
1494
|
### Runtime Assignment Views
|
|
1394
1495
|
|
|
1395
1496
|
`data.IServiceRuntimeAssignmentView` is one replica slot's current assignment as an administrator
|
|
@@ -1881,6 +1982,47 @@ storage provider's binding identity/generation, selected policy, matching observ
|
|
|
1881
1982
|
join: callers still authenticate Cloudly and the provider, check current readiness and retain the
|
|
1882
1983
|
native fence.
|
|
1883
1984
|
|
|
1985
|
+
### Runtime local storage claims
|
|
1986
|
+
|
|
1987
|
+
`data.IRuntimeLocalStorageClaim` is a controller's authority for one retained, node-local volume of
|
|
1988
|
+
one service. Cloudly and Onebox issue it alike (`controller.kind` is `cloudly` or `onebox`). It names
|
|
1989
|
+
the claim revision (`id`, `generation`, `previous`), the organization, cluster, node, runtime
|
|
1990
|
+
namespace, service and the service's own `volumeId`, and it states:
|
|
1991
|
+
|
|
1992
|
+
- `source`: `{ kind: 'directory' }`, a node-local directory the node derives from the claim's
|
|
1993
|
+
identity under a root only the node knows. Network filesystems join this union later as further
|
|
1994
|
+
kinds, with their credentials delivered as secrets and never inside a claim;
|
|
1995
|
+
- `initialization`: `empty` creates an empty root with `initialOwnership { uid, gid, mode }`, which
|
|
1996
|
+
an `empty` claim must state, so a workload without `runAs` never meets a root-owned directory by
|
|
1997
|
+
accident; `import` waits for the volume's bytes to be imported and states `initialOwnership: null`,
|
|
1998
|
+
because an imported tree keeps its own ownership. `mode` holds directory permission bits only
|
|
1999
|
+
(`runtimeLocalStorageClaimContract.directoryModeBits`, `0o3777`; setuid is refused);
|
|
2000
|
+
- `mount { mountPath, readOnly }`, judged by the storage request's own mount path rule: canonical,
|
|
2001
|
+
absolute, not `/`, and never overlapping `/run/secrets`;
|
|
2002
|
+
- `accessMode: 'ReadWriteOnce'`, `reclaimPolicy: 'retain'`, and `lifecycle`: `bound` keeps the
|
|
2003
|
+
volume, `purge` orders its bytes deleted and always follows a bound generation of the same claim.
|
|
2004
|
+
|
|
2005
|
+
The claim carries no host path, device, mount option or credential.
|
|
2006
|
+
`snapshotRuntimeLocalStorageClaim` makes a detached exact-schema snapshot,
|
|
2007
|
+
`computeRuntimeLocalStorageClaimDigest` hashes it under `serve.zone/runtime-local-storage-claim`,
|
|
2008
|
+
`validateRuntimeLocalStorageClaim` verifies the stated digest, and
|
|
2009
|
+
`getRuntimeLocalStorageClaimReference` is the `{ id, generation, digest }` an assignment seals in
|
|
2010
|
+
`workload.storage`. `bindRuntimeLocalStorageClaimToAssignment(claim, assignment, expectedClusterId)`
|
|
2011
|
+
checks that reference and the exact controller, organization, node, runtime namespace, service and
|
|
2012
|
+
cluster; a `purge` claim binds to no assignment, because no workload may mount a volume being deleted.
|
|
2013
|
+
|
|
2014
|
+
`requests.runtimesession.IReq_Controller_Pallet_ApplyRuntimeLocalStorageClaim`
|
|
2015
|
+
(`applyRuntimeLocalStorageClaim`) pushes one claim over the node's authenticated session:
|
|
2016
|
+
`{ session, claim }` → `{ status, state, claim }`. `status` is `accepted`, `replay` or `historical`;
|
|
2017
|
+
`state` is `ready`, `import-required`, `purged` or `uncertain` (a volume the node can vouch for
|
|
2018
|
+
neither way, which it neither mounts nor deletes until an operator decides); `claim` is the sent
|
|
2019
|
+
claim's reference. `bindApplyRuntimeLocalStorageClaimRequest(request, trustedSession)` requires the
|
|
2020
|
+
request's session to equal the node's current one and the claim to name its controller, cluster,
|
|
2021
|
+
node and runtime namespace. `bindApplyRuntimeLocalStorageClaimResponse(response, request)` binds the
|
|
2022
|
+
answer to the sent claim and, for `accepted` and `replay`, to a state the claim can be in: a bound
|
|
2023
|
+
claim is `ready`, `import-required` (an `import` claim only) or `uncertain`, a purge is `purged` or
|
|
2024
|
+
`uncertain`. A `historical` answer describes the newer generation the node holds.
|
|
2025
|
+
|
|
1884
2026
|
`platform.storagemigration` defines the provider-neutral cutover contract for a
|
|
1885
2027
|
named object-storage binding. Corestore atomically owns and fences the source
|
|
1886
2028
|
binding after validating a distinct, unfenced active-object snapshot. Onebox
|
|
@@ -2440,6 +2582,9 @@ credential is excluded.
|
|
|
2440
2582
|
| `registerClusterIngress` | ingress → relay → Cloudly | `{ bearer, version, nodeId, capabilities?, protocol }` → `{ accepted: true, revision \| null, protocol }` |
|
|
2441
2583
|
| `getClusterIngressRouteTable` | ingress → relay | `{ knownRevision \| null }` → `{ table \| null }` |
|
|
2442
2584
|
| `getClusterTrafficStatistics` | Cloudly → relay → ingress | `{ fromDayUtc, toDayUtc, cursor?, limit }` → `{ statistics, nextCursor? }` |
|
|
2585
|
+
| `pushClusterIngressRouteTableChanged` | relay → ingress | `{ revision }` → `{}` |
|
|
2586
|
+
| `designateClusterIngress` | admin → Cloudly | `{ identity, designation }` → `{ designation, spec, replayed }` |
|
|
2587
|
+
| `getClusterIngressDesignation` | admin → Cloudly | `{ identity, clusterId }` → `{ designation \| null }` |
|
|
2443
2588
|
|
|
2444
2589
|
`null` for a table means Cloudly has computed none yet — a fact, not an empty table, and an
|
|
2445
2590
|
ingress must not serve it as one. An ingress announces itself with a **method**, not a connection
|
|
@@ -2465,6 +2610,45 @@ the body in the one server order `protocol.readProtocolOffer` states — the off
|
|
|
2465
2610
|
before this shape check and before the bearer — so a relay refuses a peer it cannot serve without
|
|
2466
2611
|
asking Cloudly, and an accepted registration carries the accepting side's own offer back.
|
|
2467
2612
|
|
|
2613
|
+
A refused registration is named. A protocol mismatch stays the `IProtocolRefusal` every hop already
|
|
2614
|
+
carries; every other refusal travels as `IClusterIngressRegistrationRefusal { code:
|
|
2615
|
+
'cluster-ingress-registration-refused', reason, retryAfterMs }` in `TypedResponseError.errorData`,
|
|
2616
|
+
forwarded by the relay untouched. `clusterIngressRegistrationRefusalReasons` lists the reasons in
|
|
2617
|
+
the order Cloudly judges them: `not-ready` (Cloudly cannot judge registrations yet), `registration-invalid`
|
|
2618
|
+
(the body fails `validateClusterIngressRegistration`), `relay-not-connected` (the forwarding relay is
|
|
2619
|
+
not the connection Cloudly elected for its cluster), `ingress-not-designated`, `node-mismatch` (the
|
|
2620
|
+
node is not one the designation lets the ingress run on), `assignment-not-running` (no ready
|
|
2621
|
+
assignment of the ingress service runs on that node under its current session, or it does not carry
|
|
2622
|
+
the designation's current credential), `bearer-refused` and `conflict` (the designation, assignment
|
|
2623
|
+
or session changed while the registration was judged). `retryAfterMs` is how long the ingress waits
|
|
2624
|
+
before it registers again, 1 s to 300 s (`clusterIngressRegistrationContract`).
|
|
2625
|
+
`validateClusterIngressRegistrationRefusal` names every violation and
|
|
2626
|
+
`readClusterIngressRegistrationRefusal(errorData)` answers the refusal or `null`, reading plain data
|
|
2627
|
+
only, as `protocol.readProtocolRefusal` does. No refusal quotes the bearer.
|
|
2628
|
+
|
|
2629
|
+
`pushClusterIngressRouteTableChanged` is the relay's hint that it holds a newer table. It carries the
|
|
2630
|
+
revision alone (`IClusterIngressRouteTableChange`, `validateClusterIngressRouteTableChange`) and
|
|
2631
|
+
nothing secret; the ingress answers it by pulling `getClusterIngressRouteTable` with the revision it
|
|
2632
|
+
already applied and ignores a hint that is not newer, so a lost or repeated hint costs nothing.
|
|
2633
|
+
|
|
2634
|
+
`clusterIngressEnvironmentNames` spells the ingress workload's environment once for both sides:
|
|
2635
|
+
`SERVEZONE_CLUSTER_INGRESS_BEARER` (the registration bearer, delivered as a secret),
|
|
2636
|
+
`SERVEZONE_CLUSTER_RELAY_ORIGIN` (the exact `IClusterRelay.origin`) and `SERVEZONE_CLUSTER_NODE_ID`
|
|
2637
|
+
(the node the assignment runs on). Cloudly writes them; the ingress reads them.
|
|
2638
|
+
|
|
2639
|
+
A cluster born on Pallet has no cutover scope, census or target set, so its ingress is designated by
|
|
2640
|
+
`IClusterIngressDesignation { id, generation, previous, clusterId, runtime, ingressServiceId,
|
|
2641
|
+
preparedSpecRevision, credential, actorId, acceptedAt, digest }` instead of the fleet-cutover
|
|
2642
|
+
designation. `runtime` is the cluster's `pallet` phase reference and `credential`
|
|
2643
|
+
(`IClusterIngressCredentialReference`) the public identity of the managed bearer, never its value.
|
|
2644
|
+
`snapshotClusterIngressDesignation`, `computeClusterIngressDesignationDigest` (domain
|
|
2645
|
+
`serve.zone/cluster-ingress-designation`) and `validateClusterIngressDesignation` judge it, and
|
|
2646
|
+
`snapshotClusterIngressDesignationRequest` the administrator's compare-and-swap intent
|
|
2647
|
+
(`IClusterIngressDesignationRequest { mutationId, clusterId, ingressServiceId, currentRuntime,
|
|
2648
|
+
expectedSpecRevision, expectedDesignation }`). **A cluster holds exactly one kind of designation**:
|
|
2649
|
+
Cloudly refuses to designate a cluster that holds a fleet-cutover ingress designation, and the
|
|
2650
|
+
reverse. Which nodes the ingress runs on is the ingress service's runtime spec placement.
|
|
2651
|
+
|
|
2468
2652
|
`IClusterTrafficStatistics` is one UTC day of one hostname's traffic on one node —
|
|
2469
2653
|
`requests`, `bytesIn`, `bytesOut`, `connections` and the backend failures the proxy can observe
|
|
2470
2654
|
(`connect`, `handshake`, `request`). Day buckets rather than rates: a rate answers "how busy is it
|
|
@@ -2499,6 +2683,15 @@ from one that states a value, and nothing downstream defaults or infers one. Clo
|
|
|
2499
2683
|
the node stated and resolves it into the route table; the relay never substitutes an address of
|
|
2500
2684
|
its own.
|
|
2501
2685
|
|
|
2686
|
+
The same report carries the optional `hostAddresses`: every IPv4 address the node's host carries on
|
|
2687
|
+
interfaces the node does not manage itself, sorted as strings, unique, never empty when present, at
|
|
2688
|
+
most `runtimeNetworkProtectionContract.maximumHostAddresses` (32), each one admitted by
|
|
2689
|
+
`runtimeNodeUplinkAddress`. Workload bridges and the managed VPN interface are the node's own and
|
|
2690
|
+
are left out. Cloudly names a plan platform endpoint in that node's `hostPlatformEndpointIds` when
|
|
2691
|
+
the endpoint's address is one of them. A relay registration already tells Cloudly which host carries
|
|
2692
|
+
the relay listener and hub; `hostAddresses` is how a host without a relay, such as a node with a
|
|
2693
|
+
Corestore beside it on one machine, states the same. Absent states nothing and is never defaulted.
|
|
2694
|
+
|
|
2502
2695
|
Shared service port helpers are exported from `data` so Cloudly, App Store resolution, Coreflow, Coretraffic, Onebox, and dcrouter agree on the same normalization rules:
|
|
2503
2696
|
|
|
2504
2697
|
```typescript
|
|
@@ -3183,6 +3376,73 @@ recipient the relay enrolled with `beginSecretRecipientEnrollment` and
|
|
|
3183
3376
|
`completeSecretRecipientEnrollment` — see [Corestore Runtime Credentials](#corestore-runtime-credentials).
|
|
3184
3377
|
No credential travels in the cluster document, and none is read from the relay's environment.
|
|
3185
3378
|
|
|
3379
|
+
### Corestore Legacy Resource Adoption
|
|
3380
|
+
|
|
3381
|
+
A Corestore root converted from a release before 32 still holds the databases and buckets
|
|
3382
|
+
`/resources/provision` created, one per service and capability, in its manifest. Corestore refuses a
|
|
3383
|
+
credential binding beside such a resource until an operator authorizes that exact binding to adopt
|
|
3384
|
+
it, offline, with a plan file; a fresh binding would otherwise start from an empty database or bucket
|
|
3385
|
+
while the data stays behind. These contracts carry that flow across Corestore, the relay, Cloudly and
|
|
3386
|
+
Coreflow, all exported from `data` and `platform`:
|
|
3387
|
+
|
|
3388
|
+
1. **Inventory.** Corestore answers `GET /control/legacy-resources`
|
|
3389
|
+
(`corestoreLegacyAdoptionContract.inventoryPath`, bearer-authenticated like every control path)
|
|
3390
|
+
with `ICorestoreLegacyResourceInventory { services }`: every service, sorted by id, with one or
|
|
3391
|
+
two `TCorestoreLegacyResource` entries, `database` before `objectstorage`. A database is named by
|
|
3392
|
+
`databaseName`, a bucket by `bucketName` and `retention` (its `IObjectStorageRetentionIntent`, or
|
|
3393
|
+
`null`). Each carries its `adoption`: `{ state: 'unadopted', blocker }` or
|
|
3394
|
+
`{ state: 'authorized', bindingId }`. The blocker names what would stop the offline adoption,
|
|
3395
|
+
`null` when nothing would: `not-adoptable` (an allocation-managed database, another provider, a
|
|
3396
|
+
resource name that is not its database or bucket name, or a bucket name that is not a canonical S3
|
|
3397
|
+
name), `ordinary-credentials-rotated` or `owned-by-binding`. An adoptable bucket must have a
|
|
3398
|
+
canonical S3 name, because a binding request carries only such a name. A consumed adoption removes
|
|
3399
|
+
the legacy entry, so it never appears.
|
|
3400
|
+
2. **Relay.** `getClusterCorestoreLegacyResources { nodeId }` asks the relay for one node's
|
|
3401
|
+
inventory, answered as `TClusterCorestoreLegacyResourceInventory`: `reachable: true` with the
|
|
3402
|
+
services, or `reachable: false` with `errorCode` `CORESTORE_ENDPOINT_UNKNOWN` or
|
|
3403
|
+
`CORESTORE_UNREACHABLE` and no list. `getCorestoreLegacyResources { identity, clusterId, nodeId }`
|
|
3404
|
+
is the administrator's read through Cloudly, with `inventorySha256`
|
|
3405
|
+
(`computeClusterCorestoreLegacyResourceInventorySha256`, over the node id and the services, not
|
|
3406
|
+
the read time; `null` for an unreachable node).
|
|
3407
|
+
3. **Adoption.** `adoptCorestoreLegacyResources { identity, clusterId, nodeId,
|
|
3408
|
+
expectedInventorySha256, resources }` is the only path that creates a binding carrying a legacy
|
|
3409
|
+
bucket name. `resources` is a sorted, unique `{ serviceId, capability }` selection
|
|
3410
|
+
(`validateCorestoreLegacyResourceSelections`). Cloudly reads the inventory again, requires the
|
|
3411
|
+
expected digest, and creates each adopting binding in one transaction: enabled, placed on `nodeId`,
|
|
3412
|
+
with `corestoreLegacyAdoption { nodeId, resourceName, inventorySha256 }`, and for a bucket
|
|
3413
|
+
`objectstorageBucketName` set to the legacy bucket and `objectstorageRetention.intent` set to the
|
|
3414
|
+
legacy intent exactly, or absent when the legacy bucket has none.
|
|
3415
|
+
`validatePlatformBindingCorestoreLegacyAdoption(binding, inventory, sha)` is that rule. A resource
|
|
3416
|
+
whose adopting binding already exists is answered unchanged. `upsertPlatformBinding` keeps refusing
|
|
3417
|
+
`objectstorageBucketName`, and refuses `corestoreLegacyAdoption` and `statusReason` as well. The
|
|
3418
|
+
answer lists the bindings and the `plan`. Refusals travel as
|
|
3419
|
+
`ICorestoreLegacyAdoptionErrorData { code, retryable }`: `legacy-inventory-unreachable` (the only
|
|
3420
|
+
retryable one), `legacy-inventory-changed`, `legacy-resource-absent`, `legacy-resource-blocked`,
|
|
3421
|
+
`legacy-resource-authorized-elsewhere`, `service-absent` and `binding-exists`.
|
|
3422
|
+
4. **Plan.** `ICorestoreLegacyResourceAdoptionPlanEntry` is exactly the
|
|
3423
|
+
`{ serviceId, capability, bindingId }` object Corestore's `legacy-resource-adoption` migration
|
|
3424
|
+
reads. `validateCorestoreLegacyResourceAdoptionPlan` applies that migration's rules: a non-empty
|
|
3425
|
+
array of at most 4096 exact entries, canonical identifiers, no service capability or binding id
|
|
3426
|
+
twice, any order. `createCorestoreLegacyResourceAdoptionPlan(bindings)` builds it from the adopting
|
|
3427
|
+
bindings, sorted by service then capability. The plan restates no legacy name or retention intent:
|
|
3428
|
+
Corestore holds those itself, and the binding request that later reaches it carries the bucket and
|
|
3429
|
+
intent it compares.
|
|
3430
|
+
5. **Status.** Until the operator has run the migration, Corestore refuses the binding with a 409
|
|
3431
|
+
whose body is `{ ok: false, error, code }`. `readCorestoreLegacyAdoptionRefusal(statusCode, body)`
|
|
3432
|
+
reads `code` as a `TPlatformBindingStatusReason`, and Coreflow reports it through
|
|
3433
|
+
`updatePlatformBindingStatus { statusReason }`; `validatePlatformBindingStatusReason` pairs each
|
|
3434
|
+
reason with its one status (`getPlatformBindingStatusOfReason`):
|
|
3435
|
+
|
|
3436
|
+
| `statusReason` | Status | Corestore refusal |
|
|
3437
|
+
| --- | --- | --- |
|
|
3438
|
+
| `legacy-adoption-pending` | `provisioning` | the service owns a legacy resource of this capability that no adoption authorizes |
|
|
3439
|
+
| `legacy-adoption-conflict` | `failed` | the adoption authorizes another binding id, or it was already consumed |
|
|
3440
|
+
| `legacy-adoption-mismatch` | `failed` | the legacy identity changed since authorization, its database tenant is absent, or the bucket or retention intent differs |
|
|
3441
|
+
|
|
3442
|
+
`IPlatformBinding.statusReason` holds the reported reason; a status report without one clears it.
|
|
3443
|
+
While a binding of a service reports `legacy-adoption-pending`, the service's runtime status waits as
|
|
3444
|
+
`legacy-adoption-pending` instead of `bindings-pending`.
|
|
3445
|
+
|
|
3186
3446
|
### Launcher Environment Delivery
|
|
3187
3447
|
|
|
3188
3448
|
Launcher environment delivery uses stable `szsv-<base32-sha256>` Docker
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isPlausibleUnicastIpv4 } from '../private/ipv4.js';
|
|
2
2
|
import { isUtcCalendarDay } from '../private/utccalendarday.js';
|
|
3
3
|
import { validateProtocolOfferOn } from '../protocol.js';
|
|
4
|
-
import { hasExactKeys } from '../private/dataproperties.js';
|
|
4
|
+
import { hasExactKeys, readExactDataRecord } from '../private/dataproperties.js';
|
|
5
5
|
import { isClusterNodeId } from '../private/nodeidentifier.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -424,3 +424,138 @@ export const validateClusterIngressRegistration = (
|
|
|
424
424
|
}
|
|
425
425
|
return errors;
|
|
426
426
|
};
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* The environment variable names of the cluster ingress workload.
|
|
430
|
+
*
|
|
431
|
+
* Cloudly writes them into the ingress workload's assignment environment and the ingress reads
|
|
432
|
+
* them, so both sides spell each name once, here. `bearer` is the credential the ingress presents
|
|
433
|
+
* to `registerClusterIngress`; it is a secret and is delivered as one. `relayOrigin` is the exact
|
|
434
|
+
* `IClusterRelay.origin` of the cluster's relay, and `nodeId` is the node the assignment runs on,
|
|
435
|
+
* which the registration's `nodeId` repeats.
|
|
436
|
+
*/
|
|
437
|
+
export const clusterIngressEnvironmentNames = Object.freeze({
|
|
438
|
+
bearer: 'SERVEZONE_CLUSTER_INGRESS_BEARER',
|
|
439
|
+
relayOrigin: 'SERVEZONE_CLUSTER_RELAY_ORIGIN',
|
|
440
|
+
nodeId: 'SERVEZONE_CLUSTER_NODE_ID',
|
|
441
|
+
} as const);
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Every reason Cloudly refuses a cluster ingress registration, in the order it judges them.
|
|
445
|
+
*
|
|
446
|
+
* A protocol mismatch is not among them: it is refused first, as the `IProtocolRefusal` every
|
|
447
|
+
* TypedRequest hop already carries, and a second name for it would be a second answer to one fact.
|
|
448
|
+
*/
|
|
449
|
+
export const clusterIngressRegistrationRefusalReasons = Object.freeze([
|
|
450
|
+
/** Cloudly cannot judge registrations yet: it is starting, stopping or missing its environment. */
|
|
451
|
+
'not-ready',
|
|
452
|
+
/** The body fails `validateClusterIngressRegistration`. */
|
|
453
|
+
'registration-invalid',
|
|
454
|
+
/** The relay that forwarded the registration is not the connection Cloudly elected for its cluster. */
|
|
455
|
+
'relay-not-connected',
|
|
456
|
+
/** The cluster holds no current ingress designation. */
|
|
457
|
+
'ingress-not-designated',
|
|
458
|
+
/** The named node is not one the designation lets the ingress run on. */
|
|
459
|
+
'node-mismatch',
|
|
460
|
+
/**
|
|
461
|
+
* No ready assignment of the designated ingress service runs on the named node under that node's
|
|
462
|
+
* current session, or the one that runs does not carry the designation's current credential.
|
|
463
|
+
*/
|
|
464
|
+
'assignment-not-running',
|
|
465
|
+
/** The bearer is not the designation's current credential. */
|
|
466
|
+
'bearer-refused',
|
|
467
|
+
/** The designation, the assignment or the session changed while the registration was judged. */
|
|
468
|
+
'conflict',
|
|
469
|
+
] as const);
|
|
470
|
+
|
|
471
|
+
export type TClusterIngressRegistrationRefusalReason = typeof clusterIngressRegistrationRefusalReasons[number];
|
|
472
|
+
|
|
473
|
+
export const clusterIngressRegistrationContract = Object.freeze({
|
|
474
|
+
refusalCode: 'cluster-ingress-registration-refused',
|
|
475
|
+
minimumRetryAfterMs: 1_000,
|
|
476
|
+
maximumRetryAfterMs: 300_000,
|
|
477
|
+
} as const);
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* The named refusal of `registerClusterIngress`, carried as `TypedResponseError.errorData` from
|
|
481
|
+
* Cloudly and forwarded by the relay untouched. `retryAfterMs` is how long the ingress waits before
|
|
482
|
+
* it registers again; it never quotes the bearer or anything derived from it.
|
|
483
|
+
*/
|
|
484
|
+
export interface IClusterIngressRegistrationRefusal {
|
|
485
|
+
code: 'cluster-ingress-registration-refused';
|
|
486
|
+
reason: TClusterIngressRegistrationRefusalReason;
|
|
487
|
+
retryAfterMs: number;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const isRetryAfterMs = (valueArg: unknown): valueArg is number => (
|
|
491
|
+
Number.isSafeInteger(valueArg)
|
|
492
|
+
&& (valueArg as number) >= clusterIngressRegistrationContract.minimumRetryAfterMs
|
|
493
|
+
&& (valueArg as number) <= clusterIngressRegistrationContract.maximumRetryAfterMs
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
/** Validates one registration refusal and names every reason it is refused. */
|
|
497
|
+
export const validateClusterIngressRegistrationRefusal = (
|
|
498
|
+
valueArg: unknown,
|
|
499
|
+
pathArg = 'cluster ingress registration refusal',
|
|
500
|
+
): string[] => {
|
|
501
|
+
if (!isRecord(valueArg) || !hasExactKeys(valueArg, ['code', 'reason', 'retryAfterMs'])) {
|
|
502
|
+
return [`${pathArg} must use its exact schema`];
|
|
503
|
+
}
|
|
504
|
+
const errors: string[] = [];
|
|
505
|
+
if (valueArg.code !== clusterIngressRegistrationContract.refusalCode) {
|
|
506
|
+
errors.push(`${pathArg} code must be ${clusterIngressRegistrationContract.refusalCode}`);
|
|
507
|
+
}
|
|
508
|
+
if (!(clusterIngressRegistrationRefusalReasons as readonly unknown[]).includes(valueArg.reason)) {
|
|
509
|
+
errors.push(`${pathArg} reason must be a cluster ingress registration refusal reason`);
|
|
510
|
+
}
|
|
511
|
+
if (!isRetryAfterMs(valueArg.retryAfterMs)) {
|
|
512
|
+
errors.push(`${pathArg} retryAfterMs must be an integer from `
|
|
513
|
+
+ `${clusterIngressRegistrationContract.minimumRetryAfterMs} to `
|
|
514
|
+
+ `${clusterIngressRegistrationContract.maximumRetryAfterMs}`);
|
|
515
|
+
}
|
|
516
|
+
return errors;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* The refusal inside an error payload, or `null` when the value is not one.
|
|
521
|
+
*
|
|
522
|
+
* It reads a value that survived serialization, the way `protocol.readProtocolRefusal` does, so an
|
|
523
|
+
* ingress tells a named registration refusal apart from a protocol refusal and every other error.
|
|
524
|
+
*/
|
|
525
|
+
export const readClusterIngressRegistrationRefusal = (
|
|
526
|
+
valueArg: unknown,
|
|
527
|
+
): IClusterIngressRegistrationRefusal | null => {
|
|
528
|
+
const refusal = readExactDataRecord(valueArg, ['code', 'reason', 'retryAfterMs']);
|
|
529
|
+
if (refusal === null || validateClusterIngressRegistrationRefusal(refusal).length > 0) {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
return Object.freeze({
|
|
533
|
+
code: clusterIngressRegistrationContract.refusalCode,
|
|
534
|
+
reason: refusal.reason as TClusterIngressRegistrationRefusalReason,
|
|
535
|
+
retryAfterMs: refusal.retryAfterMs as number,
|
|
536
|
+
});
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* The relay's hint that it holds a newer route table.
|
|
541
|
+
*
|
|
542
|
+
* It carries the revision alone and no route, certificate or key, so it is safe to log; the
|
|
543
|
+
* ingress answers it by pulling `getClusterIngressRouteTable` with the revision it already applied,
|
|
544
|
+
* and ignores a hint whose revision is not greater than that one.
|
|
545
|
+
*/
|
|
546
|
+
export interface IClusterIngressRouteTableChange {
|
|
547
|
+
revision: number;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** Validates one route-table change hint. */
|
|
551
|
+
export const validateClusterIngressRouteTableChange = (
|
|
552
|
+
valueArg: unknown,
|
|
553
|
+
pathArg = 'cluster ingress route table change',
|
|
554
|
+
): string[] => {
|
|
555
|
+
if (!isRecord(valueArg) || !hasExactKeys(valueArg, ['revision'])) {
|
|
556
|
+
return [`${pathArg} must use its exact schema`];
|
|
557
|
+
}
|
|
558
|
+
return isCounter(valueArg.revision)
|
|
559
|
+
? []
|
|
560
|
+
: [`${pathArg} revision must be a non-negative safe integer`];
|
|
561
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { TSha256Digest } from './immutableimage.js';
|
|
2
|
+
import type { IClusterRuntimeReference } from './clusterruntime.js';
|
|
3
|
+
import { snapshotClusterRuntimeReference } from './clusterruntime.js';
|
|
4
|
+
import type { IRuntimeAuthorityReference } from './runtimeassignment.js';
|
|
5
|
+
import type { ISecretVersionReference } from './secret.js';
|
|
6
|
+
import { captureNetwork, networkCounter, networkDigest, networkHash, networkId, networkRecord, networkReference,
|
|
7
|
+
networkRevision, requireNetwork } from '../private/networkcontract.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The ingress designation of a cluster born on Pallet.
|
|
11
|
+
*
|
|
12
|
+
* A cluster that never ran Swarm has no cutover scope, census or target set, so its ingress is
|
|
13
|
+
* designated by this record instead of `IFleetCutoverIngressDesignation`. A cluster holds exactly
|
|
14
|
+
* one kind of designation at a time: Cloudly refuses to designate a cluster that holds the other
|
|
15
|
+
* kind. Which nodes the ingress runs on is the ingress service's runtime spec placement; the
|
|
16
|
+
* designation names the service and the credential, and nothing else.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Public identity of the active ingress credential generation; it contains no credential value. */
|
|
20
|
+
export interface IClusterIngressCredentialReference {
|
|
21
|
+
credentialId: string;
|
|
22
|
+
generation: number;
|
|
23
|
+
secretVersion: ISecretVersionReference;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Cloudly's accepted designation of one service as a Pallet cluster's ingress. It grants no
|
|
28
|
+
* assignment, session or registration: the ingress still registers with the credential it names.
|
|
29
|
+
*/
|
|
30
|
+
export interface IClusterIngressDesignation {
|
|
31
|
+
id: string;
|
|
32
|
+
generation: number;
|
|
33
|
+
previous: IRuntimeAuthorityReference | null;
|
|
34
|
+
clusterId: string;
|
|
35
|
+
runtime: IClusterRuntimeReference & { phase: 'pallet' };
|
|
36
|
+
ingressServiceId: string;
|
|
37
|
+
/** The ingress service's runtime spec revision the designation was accepted against. */
|
|
38
|
+
preparedSpecRevision: number;
|
|
39
|
+
credential: IClusterIngressCredentialReference;
|
|
40
|
+
actorId: string;
|
|
41
|
+
acceptedAt: number;
|
|
42
|
+
digest: TSha256Digest;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Administrator intent to designate one service as the cluster's ingress. The caller supplies only
|
|
47
|
+
* compare-and-swap inputs; Cloudly owns credential generation and acceptance.
|
|
48
|
+
*/
|
|
49
|
+
export interface IClusterIngressDesignationRequest {
|
|
50
|
+
mutationId: string;
|
|
51
|
+
clusterId: string;
|
|
52
|
+
ingressServiceId: string;
|
|
53
|
+
currentRuntime: IClusterRuntimeReference & { phase: 'pallet' };
|
|
54
|
+
expectedSpecRevision: number;
|
|
55
|
+
/** Null for creation; the exact current designation for rotation or a change of service. */
|
|
56
|
+
expectedDesignation: IRuntimeAuthorityReference | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const clusterIngressDesignationContract = Object.freeze({
|
|
60
|
+
digestDomain: 'serve.zone/cluster-ingress-designation',
|
|
61
|
+
error: 'Cluster ingress designation contract rejected.',
|
|
62
|
+
} as const);
|
|
63
|
+
|
|
64
|
+
const fail = (): never => { throw new Error(clusterIngressDesignationContract.error); };
|
|
65
|
+
const safe = <T>(operationArg: () => T): T => { try { return operationArg(); } catch { return fail(); } };
|
|
66
|
+
|
|
67
|
+
const palletRuntime = (valueArg: unknown, clusterIdArg: string): IClusterRuntimeReference & { phase: 'pallet' } => {
|
|
68
|
+
const runtime = snapshotClusterRuntimeReference(valueArg);
|
|
69
|
+
requireNetwork(runtime.id === clusterIdArg && runtime.phase === 'pallet');
|
|
70
|
+
return { id: runtime.id, phase: 'pallet', generation: runtime.generation };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const credentialOf = (valueArg: unknown): IClusterIngressCredentialReference => {
|
|
74
|
+
const value = networkRecord(valueArg, ['credentialId', 'generation', 'secretVersion']);
|
|
75
|
+
const secretVersion = networkRecord(value.secretVersion, ['secretId', 'secretVersionId']);
|
|
76
|
+
return {
|
|
77
|
+
credentialId: networkId(value.credentialId),
|
|
78
|
+
generation: networkCounter(value.generation),
|
|
79
|
+
secretVersion: {
|
|
80
|
+
secretId: networkId(secretVersion.secretId),
|
|
81
|
+
secretVersionId: networkId(secretVersion.secretVersionId),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Detached exact-schema snapshot of a designation request. */
|
|
87
|
+
export const snapshotClusterIngressDesignationRequest = (
|
|
88
|
+
valueArg: unknown,
|
|
89
|
+
): IClusterIngressDesignationRequest => safe(() => {
|
|
90
|
+
const value = networkRecord(captureNetwork(valueArg), ['mutationId', 'clusterId', 'ingressServiceId',
|
|
91
|
+
'currentRuntime', 'expectedSpecRevision', 'expectedDesignation']);
|
|
92
|
+
const clusterId = networkId(value.clusterId);
|
|
93
|
+
return {
|
|
94
|
+
mutationId: networkId(value.mutationId),
|
|
95
|
+
clusterId,
|
|
96
|
+
ingressServiceId: networkId(value.ingressServiceId),
|
|
97
|
+
currentRuntime: palletRuntime(value.currentRuntime, clusterId),
|
|
98
|
+
expectedSpecRevision: networkCounter(value.expectedSpecRevision),
|
|
99
|
+
expectedDesignation: value.expectedDesignation === null ? null : networkReference(value.expectedDesignation),
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/** Detached exact-schema snapshot. The digest is a separate check. */
|
|
104
|
+
export const snapshotClusterIngressDesignation = (valueArg: unknown): IClusterIngressDesignation => safe(() => {
|
|
105
|
+
const value = networkRecord(captureNetwork(valueArg), ['id', 'generation', 'previous', 'clusterId', 'runtime',
|
|
106
|
+
'ingressServiceId', 'preparedSpecRevision', 'credential', 'actorId', 'acceptedAt', 'digest']);
|
|
107
|
+
const { id, generation, previous } = networkRevision(value);
|
|
108
|
+
const clusterId = networkId(value.clusterId);
|
|
109
|
+
return {
|
|
110
|
+
id,
|
|
111
|
+
generation,
|
|
112
|
+
previous,
|
|
113
|
+
clusterId,
|
|
114
|
+
runtime: palletRuntime(value.runtime, clusterId),
|
|
115
|
+
ingressServiceId: networkId(value.ingressServiceId),
|
|
116
|
+
preparedSpecRevision: networkCounter(value.preparedSpecRevision),
|
|
117
|
+
credential: credentialOf(value.credential),
|
|
118
|
+
actorId: networkId(value.actorId),
|
|
119
|
+
acceptedAt: networkCounter(value.acceptedAt),
|
|
120
|
+
digest: networkDigest(value.digest),
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const computeClusterIngressDesignationDigest = async (valueArg: unknown): Promise<TSha256Digest> => {
|
|
125
|
+
const designation = snapshotClusterIngressDesignation(valueArg);
|
|
126
|
+
try {
|
|
127
|
+
return await networkHash(clusterIngressDesignationContract.digestDomain, designation);
|
|
128
|
+
} catch {
|
|
129
|
+
return fail();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const validateClusterIngressDesignation = async (valueArg: unknown): Promise<string[]> => {
|
|
134
|
+
try {
|
|
135
|
+
const designation = snapshotClusterIngressDesignation(valueArg);
|
|
136
|
+
return designation.digest === await computeClusterIngressDesignationDigest(designation)
|
|
137
|
+
? [] : ['cluster ingress designation digest does not match'];
|
|
138
|
+
} catch {
|
|
139
|
+
return ['cluster ingress designation must use its exact canonical schema'];
|
|
140
|
+
}
|
|
141
|
+
};
|